[vlc-commits] auhal: Added more debug logs and removed invalid memory access due to wrong range

David Fuhrmann git at videolan.org
Wed Jul 30 18:47:05 CEST 2014


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Wed Jul 30 17:04:37 2014 +0200| [a9863cf8276cb76804e4c1923aa2f0417c65402a] | committer: David Fuhrmann

auhal: Added more debug logs and removed invalid memory access due to wrong range

Search range for the new devices array was wrong, which led to nonworking
detection of removed devices, up to strange deadlocks when quitting VLC.

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

 modules/audio_output/auhal.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index a81c2b3..6253052 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -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);
                 }
             }



More information about the vlc-commits mailing list