]> git.sesse.net Git - vlc/commitdiff
audio_output: Use help to lock and unlock so we can hopefully track bad locking scheme.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Fri, 15 Aug 2008 22:23:08 +0000 (00:23 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Fri, 15 Aug 2008 22:23:08 +0000 (00:23 +0200)
The audio output locking rule seems very vague. Moreover there could be some cross lock issues.

src/audio_output/aout_internal.h
src/audio_output/dec.c
src/audio_output/input.c
src/audio_output/intf.c
src/audio_output/mixer.c
src/audio_output/output.c

index b0b8449f0f9a0339ba80277f9e96c279d728e050..d07db6163f169674629d95dc2f66fde1b38df0e1 100644 (file)
@@ -28,6 +28,8 @@
 #ifndef __LIBVLC_AOUT_INTERNAL_H
 # define __LIBVLC_AOUT_INTERNAL_H 1
 
+#include <assert.h>
+
 #if defined( __APPLE__ ) || defined( SYS_BSD )
 #undef HAVE_ALLOCA
 #endif
@@ -140,16 +142,59 @@ int aout_DecPlay( aout_instance_t *, aout_input_t *, aout_buffer_t *, int i_inpu
 
 /* Helpers */
 
+static inline void aout_lock_mixer( aout_instance_t *p_aout )
+{
+    vlc_mutex_lock( &p_aout->mixer_lock );
+}
+
+static inline void aout_unlock_mixer( aout_instance_t *p_aout )
+{
+    vlc_mutex_unlock( &p_aout->mixer_lock );
+}
+
+static inline void aout_lock_input_fifos( aout_instance_t *p_aout )
+{
+    vlc_mutex_lock( &p_aout->input_fifos_lock );
+}
+
+static inline void aout_unlock_input_fifos( aout_instance_t *p_aout )
+{
+    vlc_mutex_unlock( &p_aout->input_fifos_lock );
+}
+
+static inline void aout_lock_output_fifo( aout_instance_t *p_aout )
+{
+    vlc_mutex_lock( &p_aout->output_fifo_lock );
+}
+
+static inline void aout_unlock_output_fifo( aout_instance_t *p_aout )
+{
+    vlc_mutex_unlock( &p_aout->output_fifo_lock );
+}
+
+static inline void aout_lock_input( aout_instance_t *p_aout, aout_input_t * p_input )
+{
+    (void)p_aout;
+    vlc_mutex_lock( &p_input->lock );
+}
+
+static inline void aout_unlock_input( aout_instance_t *p_aout, aout_input_t * p_input )
+{
+    (void)p_aout;
+    vlc_mutex_unlock( &p_input->lock );
+}
+
+
 /**
  * This function will safely mark aout input to be restarted as soon as
  * possible to take configuration changes into account */
 static inline void AoutInputsMarkToRestart( aout_instance_t *p_aout )
 {
     int i;
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
     for( i = 0; i < p_aout->i_nb_inputs; i++ )
         p_aout->pp_inputs[i]->b_restart = true;
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
 }
 
 /* This function will add or remove a a module from a string list (comma
index 7d032a2b7ac9b81dd2426a7280fe1c2e98c0fbfb..3ca6da1726b07091686c3484f3454ad34d9e1e7b 100644 (file)
@@ -80,7 +80,7 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
 
     /* We can only be called by the decoder, so no need to lock
      * p_input->lock. */
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
 
     if ( p_aout->i_nb_inputs >= AOUT_MAX_INPUTS )
     {
@@ -105,7 +105,7 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
     if( p_replay_gain )
         p_input->replay_gain = *p_replay_gain;
 
-    vlc_mutex_lock( &p_aout->input_fifos_lock );
+    aout_lock_input_fifos( p_aout );
     p_aout->pp_inputs[p_aout->i_nb_inputs] = p_input;
     p_aout->i_nb_inputs++;
 
@@ -121,22 +121,22 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
         {
             for ( i = 0; i < p_aout->i_nb_inputs - 1; i++ )
             {
-                vlc_mutex_lock( &p_aout->pp_inputs[i]->lock );
+                aout_lock_input( p_aout, p_aout->pp_inputs[i] );
                 aout_InputDelete( p_aout, p_aout->pp_inputs[i] );
-                vlc_mutex_unlock( &p_aout->pp_inputs[i]->lock );
+                aout_unlock_input( p_aout, p_aout->pp_inputs[i] );
             }
-            vlc_mutex_unlock( &p_aout->input_fifos_lock );
-            vlc_mutex_unlock( &p_aout->mixer_lock );
+            aout_unlock_input_fifos( p_aout );
+            aout_unlock_mixer( p_aout );
             return p_input;
         }
 
         /* Create other input streams. */
         for ( i = 0; i < p_aout->i_nb_inputs - 1; i++ )
         {
-            vlc_mutex_lock( &p_aout->pp_inputs[i]->lock );
+            aout_lock_input( p_aout, p_aout->pp_inputs[i] );
             aout_InputDelete( p_aout, p_aout->pp_inputs[i] );
             aout_InputNew( p_aout, p_aout->pp_inputs[i] );
-            vlc_mutex_unlock( &p_aout->pp_inputs[i]->lock );
+            aout_unlock_input( p_aout, p_aout->pp_inputs[i] );
         }
     }
     else
@@ -147,14 +147,14 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
     if ( aout_MixerNew( p_aout ) == -1 )
     {
         aout_OutputDelete( p_aout );
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
+        aout_unlock_input_fifos( p_aout );
         goto error;
     }
 
     aout_InputNew( p_aout, p_input );
-    vlc_mutex_unlock( &p_aout->input_fifos_lock );
+    aout_unlock_input_fifos( p_aout );
 
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
     p_input->i_desync = var_CreateGetInteger( p_this, "audio-desync" ) * 1000;
 
     p_input_thread = (input_thread_t *)vlc_object_find( p_this,
@@ -176,7 +176,7 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
     return p_input;
 
 error:
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
     return NULL;
 }
 
@@ -211,7 +211,7 @@ int aout_DecDelete( aout_instance_t * p_aout, aout_input_t * p_input )
 
     /* This function can only be called by the decoder itself, so no need
      * to lock p_input->lock. */
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
 
     for ( i_input = 0; i_input < p_aout->i_nb_inputs; i_input++ )
     {
@@ -224,7 +224,7 @@ int aout_DecDelete( aout_instance_t * p_aout, aout_input_t * p_input )
     if ( i_input == p_aout->i_nb_inputs )
     {
         msg_Err( p_aout, "cannot find an input to delete" );
-        vlc_mutex_unlock( &p_aout->mixer_lock );
+        aout_unlock_mixer( p_aout );
         return -1;
     }
 
@@ -252,7 +252,7 @@ int aout_DecDelete( aout_instance_t * p_aout, aout_input_t * p_input )
         }
     }
 
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
 
     return 0;
 }
@@ -271,11 +271,11 @@ aout_buffer_t * aout_DecNewBuffer( aout_input_t * p_input,
     aout_buffer_t * p_buffer;
     mtime_t duration;
 
-    vlc_mutex_lock( &p_input->lock );
+    aout_lock_input( NULL, p_input );
 
     if ( p_input->b_error )
     {
-        vlc_mutex_unlock( &p_input->lock );
+        aout_unlock_input( NULL, p_input );
         return NULL;
     }
 
@@ -290,7 +290,7 @@ aout_buffer_t * aout_DecNewBuffer( aout_input_t * p_input,
     /* Suppose the decoder doesn't have more than one buffered buffer */
     p_input->b_changed = 0;
 
-    vlc_mutex_unlock( &p_input->lock );
+    aout_unlock_input( NULL, p_input );
 
     if( p_buffer == NULL )
         return NULL;
@@ -360,11 +360,11 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                             + (mtime_t)p_buffer->i_nb_samples * 1000000
                                 / p_input->input.i_rate;
 
-    vlc_mutex_lock( &p_input->lock );
+    aout_lock_input( p_aout, p_input );
 
     if ( p_input->b_error )
     {
-        vlc_mutex_unlock( &p_input->lock );
+        aout_unlock_input( p_aout, p_input );
         aout_BufferFree( p_buffer );
         return -1;
     }
@@ -391,16 +391,14 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
     /* If the buffer is too early, wait a while. */
     mwait( p_buffer->start_date - AOUT_MAX_PREPARE_TIME );
 
-    if ( aout_InputPlay( p_aout, p_input, p_buffer, i_input_rate ) == -1 )
-    {
-        vlc_mutex_unlock( &p_input->lock );
-        return -1;
-    }
+    int ret = aout_InputPlay( p_aout, p_input, p_buffer, i_input_rate );
+
+    aout_unlock_input( p_aout, p_input );
 
-    vlc_mutex_unlock( &p_input->lock );
+    if ( ret == -1 ) return -1;
 
     /* Run the mixer if it is able to run. */
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
     aout_MixerRun( p_aout );
     if( p_input->p_input_thread )
     {
@@ -410,7 +408,7 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                              1, NULL );
         vlc_mutex_unlock( &p_input->p_input_thread->p->counters.counters_lock);
     }
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
 
     return 0;
 }
index 95681e8fd2439fee82b9b5021b6847db89d4e213..24de3d31c9a9eafaedbe74e4a50fde50ea6dfa04 100644 (file)
@@ -483,8 +483,8 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
         aout_fifo_t fifo, dummy_fifo;
         uint8_t     *p_first_byte_to_mix;
 
-        vlc_mutex_lock( &p_aout->mixer_lock );
-        vlc_mutex_lock( &p_aout->input_fifos_lock );
+        aout_lock_mixer( p_aout );
+        aout_lock_input_fifos( p_aout );
 
         /* A little trick to avoid loosing our input fifo */
         aout_FifoInit( p_aout, &dummy_fifo, p_aout->mixer.mixer.i_rate );
@@ -496,8 +496,8 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
         p_input->p_first_byte_to_mix = p_first_byte_to_mix;
         p_input->fifo = fifo;
 
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
-        vlc_mutex_unlock( &p_aout->mixer_lock );
+        aout_unlock_input_fifos( p_aout );
+        aout_unlock_mixer( p_aout );
     }
 
     if( i_input_rate != INPUT_RATE_DEFAULT && p_input->p_playback_rate_filter == NULL )
@@ -541,9 +541,9 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
     /* We don't care if someone changes the start date behind our back after
      * this. We'll deal with that when pushing the buffer, and compensate
      * with the next incoming buffer. */
-    vlc_mutex_lock( &p_aout->input_fifos_lock );
+    aout_lock_input_fifos( p_aout );
     start_date = aout_FifoNextStart( p_aout, &p_input->fifo );
-    vlc_mutex_unlock( &p_aout->input_fifos_lock );
+    aout_unlock_input_fifos( p_aout );
 
     if ( start_date != 0 && start_date < mdate() )
     {
@@ -552,10 +552,10 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
          * happen :). */
         msg_Warn( p_aout, "computed PTS is out of range (%"PRId64"), "
                   "clearing out", mdate() - start_date );
-        vlc_mutex_lock( &p_aout->input_fifos_lock );
+        aout_lock_input_fifos( p_aout );
         aout_FifoSet( p_aout, &p_input->fifo, 0 );
         p_input->p_first_byte_to_mix = NULL;
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
+        aout_unlock_input_fifos( p_aout );
         if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
             msg_Warn( p_aout, "timing screwed, stopping resampling" );
         inputResamplingStop( p_input );
@@ -582,10 +582,10 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
     {
         msg_Warn( p_aout, "audio drift is too big (%"PRId64"), clearing out",
                   start_date - p_buffer->start_date );
-        vlc_mutex_lock( &p_aout->input_fifos_lock );
+        aout_lock_input_fifos( p_aout );
         aout_FifoSet( p_aout, &p_input->fifo, 0 );
         p_input->p_first_byte_to_mix = NULL;
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
+        aout_unlock_input_fifos( p_aout );
         if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
             msg_Warn( p_aout, "timing screwed, stopping resampling" );
         inputResamplingStop( p_input );
@@ -710,9 +710,9 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
         (p_buffer->end_date - p_buffer->start_date);
     p_buffer->start_date = start_date;
 
-    vlc_mutex_lock( &p_aout->input_fifos_lock );
+    aout_lock_input_fifos( p_aout );
     aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
-    vlc_mutex_unlock( &p_aout->input_fifos_lock );
+    aout_unlock_input_fifos( p_aout );
     return 0;
 }
 
@@ -862,13 +862,13 @@ static int ReplayGainCallback( vlc_object_t *p_this, char const *psz_cmd,
     aout_instance_t *p_aout = (aout_instance_t *)p_this;
     int i;
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
     for( i = 0; i < p_aout->i_nb_inputs; i++ )
         ReplayGainSelect( p_aout, p_aout->pp_inputs[i] );
 
     /* Restart the mixer (a trivial mixer may be in use) */
     aout_MixerMultiplierSet( p_aout, p_aout->mixer.f_multiplier );
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
 
     return VLC_SUCCESS;
 }
index 5bec5b9894a57f2dc2ec0cc94e7007fcd086c60f..3e652f3caa19c4377123d827d043835766035d1a 100644 (file)
@@ -78,7 +78,7 @@ int __aout_VolumeGet( vlc_object_t * p_object, audio_volume_t * pi_volume )
         return 0;
     }
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
     if ( !p_aout->mixer.b_error )
     {
         i_result = p_aout->output.pf_volume_get( p_aout, pi_volume );
@@ -87,7 +87,7 @@ int __aout_VolumeGet( vlc_object_t * p_object, audio_volume_t * pi_volume )
     {
         *pi_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
     }
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
 
     vlc_object_release( p_aout );
     return i_result;
@@ -109,12 +109,12 @@ int __aout_VolumeSet( vlc_object_t * p_object, audio_volume_t i_volume )
 
     if ( p_aout == NULL ) return 0;
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
     if ( !p_aout->mixer.b_error )
     {
         i_result = p_aout->output.pf_volume_set( p_aout, i_volume );
     }
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
 
     var_Set( p_aout, "intf-change", val );
     vlc_object_release( p_aout );
@@ -132,7 +132,7 @@ int __aout_VolumeInfos( vlc_object_t * p_object, audio_volume_t * pi_soft )
 
     if ( p_aout == NULL ) return 0;
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
     if ( p_aout->mixer.b_error )
     {
         /* The output module is destroyed. */
@@ -142,7 +142,7 @@ int __aout_VolumeInfos( vlc_object_t * p_object, audio_volume_t * pi_soft )
     {
         i_result = p_aout->output.pf_volume_infos( p_aout, pi_soft );
     }
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
 
     vlc_object_release( p_aout );
     return i_result;
@@ -180,13 +180,13 @@ int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps,
 
     if ( p_aout == NULL ) return 0;
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
     if ( !p_aout->mixer.b_error )
     {
         i_result = p_aout->output.pf_volume_set( p_aout,
                                                 (audio_volume_t) i_volume );
     }
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
 
     vlc_object_release( p_aout );
     return i_result;
@@ -223,12 +223,12 @@ int __aout_VolumeDown( vlc_object_t * p_object, int i_nb_steps,
 
     if ( p_aout == NULL ) return 0;
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
     if ( !p_aout->mixer.b_error )
     {
         i_result = p_aout->output.pf_volume_set( p_aout, (audio_volume_t) i_volume );
     }
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_mixer( p_aout );
 
     vlc_object_release( p_aout );
     return i_result;
@@ -369,21 +369,21 @@ static int aout_Restart( aout_instance_t * p_aout )
     int i;
     bool b_error = 0;
 
-    vlc_mutex_lock( &p_aout->mixer_lock );
+    aout_lock_mixer( p_aout );
 
     if ( p_aout->i_nb_inputs == 0 )
     {
-        vlc_mutex_unlock( &p_aout->mixer_lock );
+        aout_unlock_mixer( p_aout );
         msg_Err( p_aout, "no decoder thread" );
         return -1;
     }
 
     /* Lock all inputs. */
-    vlc_mutex_lock( &p_aout->input_fifos_lock );
+    aout_lock_input_fifos( p_aout );
 
     for ( i = 0; i < p_aout->i_nb_inputs; i++ )
     {
-        vlc_mutex_lock( &p_aout->pp_inputs[i]->lock );
+        aout_lock_input( p_aout, p_aout->pp_inputs[i] );
         aout_InputDelete( p_aout, p_aout->pp_inputs[i] );
     }
 
@@ -399,8 +399,8 @@ static int aout_Restart( aout_instance_t * p_aout )
         {
             vlc_mutex_unlock( &p_aout->pp_inputs[i]->lock );
         }
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
-        vlc_mutex_unlock( &p_aout->mixer_lock );
+        aout_unlock_input_fifos( p_aout );
+        aout_unlock_mixer( p_aout );
         return -1;
     }
 
@@ -411,8 +411,8 @@ static int aout_Restart( aout_instance_t * p_aout )
         {
             vlc_mutex_unlock( &p_aout->pp_inputs[i]->lock );
         }
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
-        vlc_mutex_unlock( &p_aout->mixer_lock );
+        aout_unlock_input_fifos( p_aout );
+        aout_unlock_mixer( p_aout );
         return -1;
     }
 
@@ -420,14 +420,13 @@ static int aout_Restart( aout_instance_t * p_aout )
     for ( i = 0; i < p_aout->i_nb_inputs; i++ )
     {
         aout_input_t * p_input = p_aout->pp_inputs[i];
-
         b_error |= aout_InputNew( p_aout, p_input );
         p_input->b_changed = 1;
-        vlc_mutex_unlock( &p_input->lock );
+        aout_unlock_input( p_aout, p_input );
     }
 
-    vlc_mutex_unlock( &p_aout->input_fifos_lock );
-    vlc_mutex_unlock( &p_aout->mixer_lock );
+    aout_unlock_input_fifos( p_aout );
+    aout_unlock_mixer( p_aout );
 
     return b_error;
 }
index b29f2dda3ca4cdbfa2ab7d5bb4a0e8c99b4a14af..45255c7afdcf4a759f40091a6af8aaca18b16c6d 100644 (file)
@@ -80,7 +80,7 @@ static int MixBuffer( aout_instance_t * p_aout )
     if ( p_aout->mixer.b_error )
     {
         /* Free all incoming buffers. */
-        vlc_mutex_lock( &p_aout->input_fifos_lock );
+        aout_lock_input_fifos( p_aout );
         for ( i = 0; i < p_aout->i_nb_inputs; i++ )
         {
             aout_input_t * p_input = p_aout->pp_inputs[i];
@@ -93,13 +93,13 @@ static int MixBuffer( aout_instance_t * p_aout )
                 p_buffer = p_next;
             }
         }
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
+        aout_unlock_input_fifos( p_aout );
         return -1;
     }
 
 
-    vlc_mutex_lock( &p_aout->output_fifo_lock );
-    vlc_mutex_lock( &p_aout->input_fifos_lock );
+    aout_lock_output_fifo( p_aout );
+    aout_lock_input_fifos( p_aout );
 
     /* Retrieve the date of the next buffer. */
     memcpy( &exact_start_date, &p_aout->output.fifo.end_date,
@@ -118,7 +118,7 @@ static int MixBuffer( aout_instance_t * p_aout )
         start_date = 0;
     }
 
-    vlc_mutex_unlock( &p_aout->output_fifo_lock );
+    aout_unlock_output_fifo( p_aout );
 
     /* See if we have enough data to prepare a new buffer for the audio
      * output. First : start date. */
@@ -164,7 +164,7 @@ static int MixBuffer( aout_instance_t * p_aout )
         if ( i < p_aout->i_nb_inputs )
         {
             /* Interrupted before the end... We can't run. */
-            vlc_mutex_unlock( &p_aout->input_fifos_lock );
+            aout_unlock_input_fifos( p_aout );
             return -1;
         }
     }
@@ -287,10 +287,10 @@ static int MixBuffer( aout_instance_t * p_aout )
                 if( i_nb_bytes < 0 )
                 {
                     /* Is it really the best way to do it ? */
-                    vlc_mutex_lock( &p_aout->output_fifo_lock );
+                    aout_lock_output_fifo( p_aout );
                     aout_FifoSet( p_aout, &p_aout->output.fifo, 0 );
                     aout_DateSet( &exact_start_date, 0 );
-                    vlc_mutex_unlock( &p_aout->output_fifo_lock );
+                    aout_unlock_output_fifo( p_aout );
                     break;
                 }
 
@@ -302,7 +302,7 @@ static int MixBuffer( aout_instance_t * p_aout )
     if ( i < p_aout->i_nb_inputs || i_first_input == p_aout->i_nb_inputs )
     {
         /* Interrupted before the end... We can't run. */
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
+        aout_unlock_input_fifos( p_aout );
         return -1;
     }
 
@@ -316,7 +316,7 @@ static int MixBuffer( aout_instance_t * p_aout )
                       p_output_buffer );
     if ( p_output_buffer == NULL )
     {
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
+        aout_unlock_input_fifos( p_aout );
         return -1;
     }
     /* This is again a bit kludgy - for the S/PDIF mixer. */
@@ -332,7 +332,7 @@ static int MixBuffer( aout_instance_t * p_aout )
 
     p_aout->mixer.pf_do_work( p_aout, p_output_buffer );
 
-    vlc_mutex_unlock( &p_aout->input_fifos_lock );
+    aout_unlock_input_fifos( p_aout );
 
     aout_OutputPlay( p_aout, p_output_buffer );
 
index b799855b43db43ac012c2ce0837f088aac515b64..1181d1eb93ffdb17c23fd2d9955b5bc10ce99dee 100644 (file)
@@ -51,14 +51,14 @@ int aout_OutputNew( aout_instance_t * p_aout,
         p_aout->output.output.i_rate = i_rate;
     aout_FormatPrepare( &p_aout->output.output );
 
-    vlc_mutex_lock( &p_aout->output_fifo_lock );
+    aout_lock_output_fifo( p_aout );
 
     /* Find the best output plug-in. */
     p_aout->output.p_module = module_Need( p_aout, "audio output", "$aout", 0);
     if ( p_aout->output.p_module == NULL )
     {
         msg_Err( p_aout, "no suitable audio output module" );
-        vlc_mutex_unlock( &p_aout->output_fifo_lock );
+        aout_unlock_output_fifo( p_aout );
         return -1;
     }
 
@@ -165,7 +165,7 @@ int aout_OutputNew( aout_instance_t * p_aout,
     aout_FifoInit( p_aout, &p_aout->output.fifo,
                    p_aout->output.output.i_rate );
 
-    vlc_mutex_unlock( &p_aout->output_fifo_lock );
+    aout_unlock_output_fifo( p_aout );
 
     aout_FormatPrint( p_aout, "output", &p_aout->output.output );
 
@@ -232,9 +232,9 @@ void aout_OutputDelete( aout_instance_t * p_aout )
     aout_FiltersDestroyPipeline( p_aout, p_aout->output.pp_filters,
                                  p_aout->output.i_nb_filters );
 
-    vlc_mutex_lock( &p_aout->output_fifo_lock );
+    aout_lock_output_fifo( p_aout );
     aout_FifoDestroy( p_aout, &p_aout->output.fifo );
-    vlc_mutex_unlock( &p_aout->output_fifo_lock );
+    aout_unlock_output_fifo( p_aout );
 
     p_aout->output.b_error = true;
 }
@@ -256,10 +256,10 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
         return;
     }
 
-    vlc_mutex_lock( &p_aout->output_fifo_lock );
+    aout_lock_output_fifo( p_aout );
     aout_FifoPush( p_aout, &p_aout->output.fifo, p_buffer );
     p_aout->output.pf_play( p_aout );
-    vlc_mutex_unlock( &p_aout->output_fifo_lock );
+    aout_unlock_output_fifo( p_aout );
 }
 
 /*****************************************************************************
@@ -276,7 +276,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
 {
     aout_buffer_t * p_buffer;
 
-    vlc_mutex_lock( &p_aout->output_fifo_lock );
+    aout_lock_output_fifo( p_aout );
 
     p_buffer = p_aout->output.fifo.p_first;
 
@@ -310,7 +310,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
         p_aout->output.b_starving = 1;
 #endif
 
-        vlc_mutex_unlock( &p_aout->output_fifo_lock );
+        aout_unlock_output_fifo( p_aout );
         return NULL;
     }
 
@@ -327,7 +327,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
      */
     {
         const mtime_t i_delta = p_buffer->start_date - start_date;
-        vlc_mutex_unlock( &p_aout->output_fifo_lock );
+        aout_unlock_output_fifo( p_aout );
 
         if ( !p_aout->output.b_starving )
             msg_Dbg( p_aout, "audio output is starving (%"PRId64"), "
@@ -348,7 +348,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
         msg_Warn( p_aout, "output date isn't PTS date, requesting "
                   "resampling (%"PRId64")", difference );
 
-        vlc_mutex_lock( &p_aout->input_fifos_lock );
+        aout_lock_input_fifos( p_aout );
         for ( i = 0; i < p_aout->i_nb_inputs; i++ )
         {
             aout_fifo_t * p_fifo = &p_aout->pp_inputs[i]->fifo;
@@ -357,7 +357,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
         }
 
         aout_FifoMoveDates( p_aout, &p_aout->output.fifo, difference );
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
+        aout_unlock_input_fifos( p_aout );
     }
 
     p_aout->output.fifo.p_first = p_buffer->p_next;
@@ -366,6 +366,6 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
         p_aout->output.fifo.pp_last = &p_aout->output.fifo.p_first;
     }
 
-    vlc_mutex_unlock( &p_aout->output_fifo_lock );
+    aout_unlock_output_fifo( p_aout );
     return p_buffer;
 }