]> git.sesse.net Git - vlc/commitdiff
auhal: Added more debug logs and removed invalid memory access due to wrong range
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Wed, 30 Jul 2014 15:04:37 +0000 (17:04 +0200)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Wed, 30 Jul 2014 16:46:18 +0000 (18:46 +0200)
Search range for the new devices array was wrong, which led to nonworking
detection of removed devices, up to strange deadlocks when quitting VLC.

modules/audio_output/auhal.c

index a81c2b38505d7aa6f1a8fc20ae9ce25e612c1745..625305240abfc66ea5db00dc84873e25bccf32b0 100644 (file)
@@ -1086,6 +1086,8 @@ static void Stop(audio_output_t *p_aout)
     OSStatus            err = noErr;
     UInt32              i_param_size = 0;
 
+    msg_Dbg(p_aout, "Stopping the auhal module");
+
     if (p_sys->au_unit) {
         verify_noerr(AudioOutputUnitStop(p_sys->au_unit));
         verify_noerr(AudioUnitUninitialize(p_sys->au_unit));
@@ -1185,6 +1187,8 @@ static void RebuildDeviceList(audio_output_t * p_aout)
 
     struct aout_sys_t   *p_sys = p_aout->sys;
 
+    msg_Dbg(p_aout, "Rebuild device list");
+
     ReportDevice(p_aout, 0, _("System Sound Output Device"));
 
     /* setup local array */
@@ -1286,16 +1290,18 @@ static void RebuildDeviceList(audio_output_t * p_aout)
     CFIndex count = 0;
     if (p_sys->device_list)
         count = CFArrayGetCount(p_sys->device_list);
+    CFRange newListSearchRange = CFRangeMake(0, CFArrayGetCount(currentListOfDevices));
 
     if (count > 0) {
+        msg_Dbg(p_aout, "Looking for removed devices");
         CFNumberRef cfn_device_id;
         int i_device_id = 0;
         for (CFIndex x = 0; x < count; x++) {
-            if (!CFArrayContainsValue(currentListOfDevices, CFRangeMake(0, count), CFArrayGetValueAtIndex(p_sys->device_list, x))) {
+            if (!CFArrayContainsValue(currentListOfDevices, newListSearchRange, CFArrayGetValueAtIndex(p_sys->device_list, x))) {
                 cfn_device_id = CFArrayGetValueAtIndex(p_sys->device_list, x);
-
                 if (cfn_device_id) {
                     CFNumberGetValue(cfn_device_id, kCFNumberSInt32Type, &i_device_id);
+                    msg_Dbg(p_aout, "Device ID %i is not found in new array, deleting.", i_device_id);
                     ReportDevice(p_aout, i_device_id, NULL);
                 }
             }