[vlc-commits] auhal: synchronize access to devices_list

David Fuhrmann git at videolan.org
Mon May 13 20:18:01 CEST 2013


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Mon May 13 20:14:53 2013 +0200| [d5861971b5dbd3f0e91ef8e3cbf270b9dd4ddb32] | committer: David Fuhrmann

auhal: synchronize access to devices_list

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

 modules/audio_output/auhal.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index c7af12d..fadb5f0 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -111,6 +111,7 @@ struct aout_sys_t
     int                         i_bytes_per_sample;
 
     CFArrayRef                  device_list;
+    vlc_mutex_t                 device_list_lock;
 
     float                       f_volume;
     bool                        b_mute;
@@ -180,6 +181,7 @@ static int Open(vlc_object_t *obj)
 
     OSStatus err = noErr;
 
+    vlc_mutex_init(&p_sys->device_list_lock);
     vlc_mutex_init(&p_sys->lock);
     vlc_cond_init(&p_sys->cond);
     p_sys->b_digital = false;
@@ -226,6 +228,7 @@ static void Close(vlc_object_t *obj)
     if (err != noErr)
         msg_Err(p_aout, "AudioHardwareRemovePropertyListener failed [%4.4s]", (char *)&err);
 
+    vlc_mutex_lock(&p_sys->device_list_lock);
     /* remove streams callbacks */
     CFIndex count = CFArrayGetCount(p_sys->device_list);
     if (count > 0) {
@@ -242,10 +245,13 @@ static void Close(vlc_object_t *obj)
         }
     }
 
+    CFRelease(p_sys->device_list);
+    vlc_mutex_unlock(&p_sys->device_list_lock);
+
     config_PutPsz(p_aout, "auhal-audio-device", aout_DeviceGet(p_aout));
 
-    CFRelease(p_sys->device_list);
 
+    vlc_mutex_destroy(&p_sys->device_list_lock);
     vlc_mutex_destroy(&p_sys->lock);
     vlc_cond_destroy(&p_sys->cond);
 
@@ -1186,6 +1192,7 @@ static void RebuildDeviceList(audio_output_t * p_aout)
         free(psz_name);
     }
 
+    vlc_mutex_lock(&p_sys->device_list_lock);
     CFIndex count = 0;
     if (p_sys->device_list)
         count = CFArrayGetCount(p_sys->device_list);
@@ -1211,6 +1218,8 @@ static void RebuildDeviceList(audio_output_t * p_aout)
     if(!CFArrayContainsValue(p_sys->device_list, CFRangeMake(0, CFArrayGetCount(p_sys->device_list)),CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &p_sys->i_selected_dev)))
         aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
 
+    vlc_mutex_unlock(&p_sys->device_list_lock);
+
     free(deviceIDs);
 }
 



More information about the vlc-commits mailing list