[vlc-commits] qtsound: Explicitly ask for consent before using the audio device

David Fuhrmann git at videolan.org
Sat Oct 27 17:49:06 CEST 2018


vlc/vlc-3.0 | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sun Oct 21 16:16:38 2018 +0200| [0299de24d70ca887e3cc7a10364673fa7dd3510e] | committer: David Fuhrmann

qtsound: Explicitly ask for consent before using the audio device

Same reasoning as for avcapture module, see
ad372574e5e3ce5562dc10eedbb7e2a55de93ac4.

(cherry picked from commit 80282b5a8a7794dfb49056eadafc3fe62d33d59d)
Signed-off-by: David Fuhrmann <dfuhrmann at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=0299de24d70ca887e3cc7a10364673fa7dd3510e
---

 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 ee46e0f1d6..507a8d9292 100644
--- a/modules/access/Makefile.am
+++ b/modules/access/Makefile.am
@@ -75,7 +75,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 947b566527..ac9279931c 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.
@@ -307,6 +308,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");



More information about the vlc-commits mailing list