Skip to content

Commit e680194

Browse files
committed
mac-capture: Show warning for macOS system effect on audio devices
1 parent c6466d9 commit e680194

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

plugins/mac-capture/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ target_link_libraries(
3131
"$<LINK_LIBRARY:FRAMEWORK,CoreMedia.framework>"
3232
"$<LINK_LIBRARY:FRAMEWORK,CoreVideo.framework>"
3333
"$<LINK_LIBRARY:FRAMEWORK,IOSurface.framework>"
34+
"$<LINK_LIBRARY:FRAMEWORK,AVFoundation.framework>"
3435
"$<LINK_LIBRARY:WEAK_FRAMEWORK,ScreenCaptureKit.framework>"
3536
)
3637

plugins/mac-capture/data/locale/en-US.ini

+2
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ SCK.AudioUnavailable="Audio capture requires macOS 13 or newer."
3737
SCK.CaptureTypeUnavailable="Selected capture type requires macOS 13 or newer."
3838
SCK.Method="Method"
3939
SCK.Restart="Restart capture"
40+
Warning.Effect.Audio.VoiceIsolation="The macOS system effect 'Voice Isolation' is active on the selected device"
41+
Warning.Effect.Audio.WideSpectrum="The macOS system effect 'Wide Spectrum' is active on the selected device"

plugins/mac-capture/mac-audio.m

+24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <AudioUnit/AudioUnit.h>
22
#include <CoreFoundation/CFString.h>
33
#include <CoreAudio/CoreAudio.h>
4+
#include <AVFoundation/AVCaptureDevice.h>
45
#include <unistd.h>
56
#include <errno.h>
67

@@ -51,6 +52,8 @@
5152
enum speaker_layout speakers;
5253
bool enable_downmix;
5354

55+
char *effect_warning;
56+
5457
pthread_t reconnect_thread;
5558
os_event_t *exit_event;
5659
volatile bool reconnecting;
@@ -996,6 +999,27 @@ static bool coreaudio_downmix_changed(void *data, obs_properties_t *props, obs_p
996999

9971000
obs_property_set_modified_callback2(property, coreaudio_device_changed, ca);
9981001

1002+
// This file is compiled as Objective-C so that we may more easily check this class property
1003+
if (@available(macOS 12.0, *)) {
1004+
AVCaptureMicrophoneMode activeMicrophoneMode = AVCaptureDevice.activeMicrophoneMode;
1005+
NSString *effectWarningKey = nil;
1006+
switch (activeMicrophoneMode) {
1007+
case AVCaptureMicrophoneModeStandard:
1008+
break;
1009+
case AVCaptureMicrophoneModeWideSpectrum:
1010+
effectWarningKey = @"Warning.Effect.Audio.WideSpectrum";
1011+
break;
1012+
case AVCaptureMicrophoneModeVoiceIsolation:
1013+
effectWarningKey = @"Warning.Effect.Audio.VoiceIsolation";
1014+
break;
1015+
}
1016+
if (effectWarningKey) {
1017+
property = obs_properties_add_text(props, "effect_warning", obs_module_text(effectWarningKey.UTF8String),
1018+
OBS_TEXT_INFO);
1019+
obs_property_text_set_info_type(property, OBS_TEXT_INFO_WARNING);
1020+
}
1021+
}
1022+
9991023
property = obs_properties_add_bool(props, "enable_downmix", obs_module_text("CoreAudio.Downmix"));
10001024
obs_property_set_modified_callback2(property, coreaudio_downmix_changed, ca);
10011025

0 commit comments

Comments
 (0)