]> git.sesse.net Git - vlc/commitdiff
auhal: use own thread for notification loop
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Fri, 22 Nov 2013 17:49:42 +0000 (18:49 +0100)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Fri, 22 Nov 2013 20:29:42 +0000 (21:29 +0100)
modules/audio_output/auhal.c

index f50ff530c1453d32fc67713486db6fc135cda72a..50f5411e1cd80fb950f9a3a0a565d71a78c8f28d 100644 (file)
@@ -202,6 +202,19 @@ static int Open(vlc_object_t *obj)
     p_aout->device_select = SwitchAudioDevice;
     p_sys->device_list = CFArrayCreate(kCFAllocatorDefault, NULL, 0, NULL);
 
+    /*
+     * Force an own run loop for callbacks.
+     *
+     * According to rtaudio, this is absolutely necessary since 10.6 to get correct notifications.
+     * It might fix issues when using the module as a library where a proper loop is not setup already.
+     */
+    CFRunLoopRef theRunLoop = NULL;
+    AudioObjectPropertyAddress property = { kAudioHardwarePropertyRunLoop, kAudioObjectPropertyScopeGlobal,kAudioObjectPropertyElementMaster };
+    err = AudioObjectSetPropertyData(kAudioObjectSystemObject, &property, 0, NULL, sizeof(CFRunLoopRef), &theRunLoop);
+    if (err != noErr) {
+        msg_Err(p_aout, "failed to set the run loop property [%4.4s]", (char *)&err);
+    }
+
     /* Attach a listener so that we are notified of a change in the device setup */
     AudioObjectPropertyAddress audioDevicesAddress = { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
     err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &audioDevicesAddress, DevicesListener, (void *)p_aout);