Commit d5861971 authored by David Fuhrmann's avatar David Fuhrmann

auhal: synchronize access to devices_list

parent de2b5038
...@@ -111,6 +111,7 @@ struct aout_sys_t ...@@ -111,6 +111,7 @@ struct aout_sys_t
int i_bytes_per_sample; int i_bytes_per_sample;
CFArrayRef device_list; CFArrayRef device_list;
vlc_mutex_t device_list_lock;
float f_volume; float f_volume;
bool b_mute; bool b_mute;
...@@ -180,6 +181,7 @@ static int Open(vlc_object_t *obj) ...@@ -180,6 +181,7 @@ static int Open(vlc_object_t *obj)
OSStatus err = noErr; OSStatus err = noErr;
vlc_mutex_init(&p_sys->device_list_lock);
vlc_mutex_init(&p_sys->lock); vlc_mutex_init(&p_sys->lock);
vlc_cond_init(&p_sys->cond); vlc_cond_init(&p_sys->cond);
p_sys->b_digital = false; p_sys->b_digital = false;
...@@ -226,6 +228,7 @@ static void Close(vlc_object_t *obj) ...@@ -226,6 +228,7 @@ static void Close(vlc_object_t *obj)
if (err != noErr) if (err != noErr)
msg_Err(p_aout, "AudioHardwareRemovePropertyListener failed [%4.4s]", (char *)&err); msg_Err(p_aout, "AudioHardwareRemovePropertyListener failed [%4.4s]", (char *)&err);
vlc_mutex_lock(&p_sys->device_list_lock);
/* remove streams callbacks */ /* remove streams callbacks */
CFIndex count = CFArrayGetCount(p_sys->device_list); CFIndex count = CFArrayGetCount(p_sys->device_list);
if (count > 0) { if (count > 0) {
...@@ -242,10 +245,13 @@ static void Close(vlc_object_t *obj) ...@@ -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)); 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_mutex_destroy(&p_sys->lock);
vlc_cond_destroy(&p_sys->cond); vlc_cond_destroy(&p_sys->cond);
...@@ -1186,6 +1192,7 @@ static void RebuildDeviceList(audio_output_t * p_aout) ...@@ -1186,6 +1192,7 @@ static void RebuildDeviceList(audio_output_t * p_aout)
free(psz_name); free(psz_name);
} }
vlc_mutex_lock(&p_sys->device_list_lock);
CFIndex count = 0; CFIndex count = 0;
if (p_sys->device_list) if (p_sys->device_list)
count = CFArrayGetCount(p_sys->device_list); count = CFArrayGetCount(p_sys->device_list);
...@@ -1211,6 +1218,8 @@ static void RebuildDeviceList(audio_output_t * p_aout) ...@@ -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))) 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); aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
vlc_mutex_unlock(&p_sys->device_list_lock);
free(deviceIDs); free(deviceIDs);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment