[vlc-devel] commit: Fixed invalid locking order when activating visualization. ( Laurent Aimar )

git version control git at videolan.org
Mon Dec 21 00:02:30 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Dec 20 14:26:35 2009 +0100| [9fcd7b2f09163beb39d0b053fcb27a24c8784f73] | committer: Laurent Aimar 

Fixed invalid locking order when activating visualization.

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

 src/audio_output/aout_internal.h |    1 +
 src/audio_output/dec.c           |    6 +++
 src/audio_output/input.c         |   66 ++++++++++++++++++++------------------
 3 files changed, 42 insertions(+), 31 deletions(-)

diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 976b730..17231fc 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -108,6 +108,7 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input, const aout_
 int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input );
 int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                     aout_buffer_t * p_buffer, int i_input_rate );
+void aout_InputCheckAndRestart( aout_instance_t * p_aout, aout_input_t * p_input );
 
 /* From filters.c : */
 int aout_FiltersCreatePipeline ( aout_instance_t * p_aout, filter_t ** pp_filters, int * pi_nb_filters, const audio_sample_format_t * p_input_format, const audio_sample_format_t * p_output_format );
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 823cce0..ddd2f69 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -305,11 +305,14 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
     p_buffer->i_length = (mtime_t)p_buffer->i_nb_samples * 1000000
                                 / p_input->input.i_rate;
 
+    aout_lock_mixer( p_aout );
     aout_lock_input( p_aout, p_input );
 
     if( p_input->b_error )
     {
         aout_unlock_input( p_aout, p_input );
+        aout_unlock_mixer( p_aout );
+
         aout_BufferFree( p_buffer );
         return -1;
     }
@@ -333,6 +336,9 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
         p_input->b_changed = false;
     }
 
+    aout_InputCheckAndRestart( p_aout, p_input );
+    aout_unlock_mixer( p_aout );
+
     int i_ret = aout_InputPlay( p_aout, p_input, p_buffer, i_input_rate );
 
     aout_unlock_input( p_aout, p_input );
diff --git a/src/audio_output/input.c b/src/audio_output/input.c
index dd279cb..8e40756 100644
--- a/src/audio_output/input.c
+++ b/src/audio_output/input.c
@@ -456,7 +456,6 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input, const aout_
 
     /* Success */
     p_input->b_error = false;
-    p_input->b_restart = false;
     p_input->i_last_input_rate = INPUT_RATE_DEFAULT;
 
     return 0;
@@ -493,48 +492,53 @@ int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
 }
 
 /*****************************************************************************
- * aout_InputPlay : play a buffer
+ * aout_InputCheckAndRestart : restart an input
  *****************************************************************************
- * This function must be entered with the input lock.
+ * This function must be entered with the input and mixer lock.
  *****************************************************************************/
-/* XXX Do not activate it !! */
-//#define AOUT_PROCESS_BEFORE_CHEKS
-int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
-                    aout_buffer_t * p_buffer, int i_input_rate )
+void aout_InputCheckAndRestart( aout_instance_t * p_aout, aout_input_t * p_input )
 {
-    mtime_t start_date;
+    AOUT_ASSERT_MIXER_LOCKED;
     AOUT_ASSERT_INPUT_LOCKED;
 
-    if( p_input->b_restart )
-    {
-        aout_fifo_t fifo;
-        uint8_t     *p_first_byte_to_mix;
-        bool        b_paused;
-        mtime_t     i_pause_date;
+    if( !p_input->b_restart )
+        return;
 
-        aout_lock_mixer( p_aout );
-        aout_lock_input_fifos( p_aout );
+    aout_lock_input_fifos( p_aout );
 
-        /* A little trick to avoid loosing our input fifo and properties */
+    /* A little trick to avoid loosing our input fifo and properties */
 
-        p_first_byte_to_mix = p_input->mixer.begin;
-        fifo = p_input->mixer.fifo;
-        b_paused = p_input->b_paused;
-        i_pause_date = p_input->i_pause_date;
+    uint8_t *p_first_byte_to_mix = p_input->mixer.begin;
+    aout_fifo_t fifo = p_input->mixer.fifo;
+    bool b_paused = p_input->b_paused;
+    mtime_t i_pause_date = p_input->i_pause_date;
 
-        aout_FifoInit( p_aout, &p_input->mixer.fifo, p_aout->mixer_format.i_rate );
+    aout_FifoInit( p_aout, &p_input->mixer.fifo, p_aout->mixer_format.i_rate );
 
-        aout_InputDelete( p_aout, p_input );
+    aout_InputDelete( p_aout, p_input );
 
-        aout_InputNew( p_aout, p_input, &p_input->request_vout );
-        p_input->mixer.begin = p_first_byte_to_mix;
-        p_input->mixer.fifo = fifo;
-        p_input->b_paused = b_paused;
-        p_input->i_pause_date = i_pause_date;
+    aout_InputNew( p_aout, p_input, &p_input->request_vout );
+    p_input->mixer.begin = p_first_byte_to_mix;
+    p_input->mixer.fifo = fifo;
+    p_input->b_paused = b_paused;
+    p_input->i_pause_date = i_pause_date;
 
-        aout_unlock_input_fifos( p_aout );
-        aout_unlock_mixer( p_aout );
-    }
+    p_input->b_restart = false;
+
+    aout_unlock_input_fifos( p_aout );
+}
+/*****************************************************************************
+ * aout_InputPlay : play a buffer
+ *****************************************************************************
+ * This function must be entered with the input lock.
+ *****************************************************************************/
+/* XXX Do not activate it !! */
+//#define AOUT_PROCESS_BEFORE_CHEKS
+int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
+                    aout_buffer_t * p_buffer, int i_input_rate )
+{
+    mtime_t start_date;
+    AOUT_ASSERT_INPUT_LOCKED;
 
     if( i_input_rate != INPUT_RATE_DEFAULT && p_input->p_playback_rate_filter == NULL )
     {




More information about the vlc-devel mailing list