Bug 1046470 - Properly unregister property listeners in AudioUnit cubeb backend. r=kinetik
authorPaul Adenot <paul@paul.cx>
Fri, 01 Aug 2014 14:12:17 +0200
changeset 197229 734d89f7cef3c8abac2a36b2a4a1ce0083063766
parent 197228 74a5786c55e67679fd1ac05b3db276e4d8a55057
child 197230 59f51f567be1a0e60443c00fa1a53b264d54a65f
push id47077
push userpaul@paul.cx
push dateFri, 01 Aug 2014 12:12:46 +0000
treeherdermozilla-inbound@734d89f7cef3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1046470
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1046470 - Properly unregister property listeners in AudioUnit cubeb backend. r=kinetik
media/libcubeb/src/cubeb_audiounit.c
--- a/media/libcubeb/src/cubeb_audiounit.c
+++ b/media/libcubeb/src/cubeb_audiounit.c
@@ -281,48 +281,48 @@ audiounit_install_device_changed_callbac
   if (r != noErr) {
     return CUBEB_ERROR;
   }
 
   return CUBEB_OK;
 }
 
 static int
-audiounit_uninstall_device_changed_callback()
+audiounit_uninstall_device_changed_callback(cubeb_stream * stm)
 {
   OSStatus r;
   AudioDeviceID id;
 
   AudioObjectPropertyAddress datasource_address = {
     kAudioDevicePropertyDataSource,
     kAudioObjectPropertyScopeGlobal,
     kAudioObjectPropertyElementMaster
   };
 
   if (audiounit_get_output_device_id(&id) != noErr) {
     return CUBEB_ERROR;
   }
 
   r = AudioObjectRemovePropertyListener(id, &datasource_address,
                                         &audiounit_property_listener_callback,
-                                        NULL);
+                                        stm);
   if (r != noErr) {
     return CUBEB_ERROR;
   }
 
   AudioObjectPropertyAddress default_device_address = {
     kAudioHardwarePropertyDefaultOutputDevice,
     kAudioObjectPropertyScopeGlobal,
     kAudioObjectPropertyElementMaster
   };
 
   r = AudioObjectRemovePropertyListener(kAudioObjectSystemObject,
                                         &default_device_address,
                                         &audiounit_property_listener_callback,
-                                        NULL);
+                                        stm);
   if (r != noErr) {
     return CUBEB_ERROR;
   }
 
   return CUBEB_OK;
 }
 
 /* Get the acceptable buffer size (in frames) that this device can work with. */
@@ -656,17 +656,17 @@ audiounit_stream_destroy(cubeb_stream * 
     AudioUnitUninitialize(stm->unit);
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
     CloseComponent(stm->unit);
 #else
     AudioComponentInstanceDispose(stm->unit);
 #endif
   }
 
-  audiounit_uninstall_device_changed_callback();
+  audiounit_uninstall_device_changed_callback(stm);
 
   r = pthread_mutex_destroy(&stm->mutex);
   assert(r == 0);
 
   pthread_mutex_lock(&stm->context->mutex);
   assert(stm->context->active_streams >= 1);
   stm->context->active_streams -= 1;
   pthread_mutex_unlock(&stm->context->mutex);