[MPlayer-dev-eng] [PATCH] Add locking to PulseAudio driver

Luca Barbieri luca.barbieri at gmail.com
Sun Sep 2 11:43:22 CEST 2007


The PulseAudio driver is missing locking in the control() function.
This is actually visible as failed assertions on dual-core CPUs.

Please apply the patch below.


--- mplayer-1.0~rc1/libao2/ao_pulse.c~  2007-09-02 11:20:45.000000000 +0200
+++ mplayer-1.0~rc1/libao2/ao_pulse.c   2007-09-01 23:58:05.000000000 +0200
@@ -501,6 +501,8 @@
             ao_control_vol_t *vol = (ao_control_vol_t*) arg;
             pa_operation *o;
 
+           pa_threaded_mainloop_lock(mainloop);
+
             if (!(o = pa_context_get_sink_input_info(context, pa_stream_get_index(stream), info_func, NULL))) {
                 mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] pa_stream_get_sink_input_info() failed: %s\n", pa_strerror(pa_context_errno(context)));
                 return CONTROL_ERROR;
@@ -514,6 +516,8 @@
         fail:
             pa_operation_unref(o);
 
+           pa_threaded_mainloop_unlock(mainloop);
+
             if (!volume_initialized) {
                 mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] pa_stream_get_sink_input_info() failed: %s\n", pa_strerror(pa_context_errno(context)));
                 return CONTROL_ERROR;
@@ -534,6 +538,8 @@
             const ao_control_vol_t *vol = (ao_control_vol_t*) arg;
             pa_operation *o;
 
+           pa_threaded_mainloop_lock(mainloop);
+
             if (!volume_initialized) {
                 pa_cvolume_reset(&volume, 2);
                 volume_initialized = 1;
@@ -546,13 +552,18 @@
                 volume.values[1] = ((pa_volume_t) vol->right*PA_VOLUME_NORM)/100;
             }
 
+           
             if (!(o = pa_context_set_sink_input_volume(context, pa_stream_get_index(stream), &volume, NULL, NULL))) {
                 mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] pa_context_set_sink_input_volume() failed: %s\n", pa_strerror(pa_context_errno(context)));
+
+               pa_threaded_mainloop_unlock(mainloop);
                 return CONTROL_ERROR;
             }
 
             pa_operation_unref(o);
 
+           pa_threaded_mainloop_unlock(mainloop);
+
             /* We don't wait for completion here */
             
             return CONTROL_OK;





More information about the MPlayer-dev-eng mailing list