vlc | branch: master | David Fuhrmann <[email protected]> | Sun Oct 21 16:16:38 2018 +0200| [80282b5a8a7794dfb49056eadafc3fe62d33d59d] | committer: David Fuhrmann
qtsound: Explicitly ask for consent before using the audio device Same reasoning as for avcapture module, see ad372574e5e3ce5562dc10eedbb7e2a55de93ac4. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=80282b5a8a7794dfb49056eadafc3fe62d33d59d --- modules/access/Makefile.am | 2 +- modules/access/qtsound.m | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/access/Makefile.am b/modules/access/Makefile.am index fb6564b61f..222aa16c6b 100644 --- a/modules/access/Makefile.am +++ b/modules/access/Makefile.am @@ -72,7 +72,7 @@ access_LTLIBRARIES += libpulsesrc_plugin.la endif libaccess_qtsound_plugin_la_SOURCES = access/qtsound.m -libaccess_qtsound_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(accessdir)' -Wl,-framework,Foundation -Wl,-framework,QTKit -Wl,-framework,CoreAudio +libaccess_qtsound_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(accessdir)' -Wl,-framework,Foundation -Wl,-framework,QTKit -Wl,-framework,AVFoundation -Wl,-framework,CoreAudio access_LTLIBRARIES += $(LTLIBaccess_qtsound) EXTRA_LTLIBRARIES += libaccess_qtsound_plugin.la diff --git a/modules/access/qtsound.m b/modules/access/qtsound.m index e4ac1bc34c..6113518f84 100644 --- a/modules/access/qtsound.m +++ b/modules/access/qtsound.m @@ -42,6 +42,7 @@ #define QTKIT_VERSION_MIN_REQUIRED 70603 #import <QTKit/QTKit.h> +#import <AVFoundation/AVFoundation.h> /***************************************************************************** * Local prototypes. @@ -310,6 +311,24 @@ static int Open(vlc_object_t *p_this) msg_Err(p_demux, "default audio capture device is exclusively in use by another application"); goto error; } + + if (@available(macOS 10.14, *)) { + msg_Dbg(p_demux, "Check user consent for access to the audio device"); + + dispatch_semaphore_t sema = dispatch_semaphore_create(0); + __block bool accessGranted = NO; + [AVCaptureDevice requestAccessForMediaType: AVMediaTypeAudio completionHandler:^(BOOL granted) { + accessGranted = granted; + dispatch_semaphore_signal(sema); + } ]; + dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); + dispatch_release(sema); + if (!accessGranted) { + msg_Err(p_demux, "Can't use the audio device as access has not been granted by the user"); + goto error; + } + } + audioInput = [[QTCaptureDeviceInput alloc] initWithDevice: p_sys->audiodevice]; if(!audioInput) { msg_Err(p_demux, "can't create a valid audio capture input facility"); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
