]> git.sesse.net Git - vlc/commitdiff
ALSA: fix signaling race condition
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 30 Aug 2009 20:21:15 +0000 (23:21 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 30 Aug 2009 20:21:15 +0000 (23:21 +0300)
start_date must be set with the lock held. Otherwise, the condition
statement inside the ALSAThread while() startup loop may fail.
Once signaled, start_date belongs to the ALSA thread, so locking is not
needed anymore.

modules/audio_output/alsa.c

index a1d770dd3ffb681c02522b0c2d4ce7d04c086f6a..1adb6d40253f54080f622f780695442f527cfc34 100644 (file)
@@ -690,11 +690,11 @@ static void Play( aout_instance_t *p_aout )
         p_aout->output.p_sys->b_playing = true;
 
         /* get the playing date of the first aout buffer */
+        vlc_mutex_lock( &p_aout->output.p_sys->lock );
         p_aout->output.p_sys->start_date =
             aout_FifoFirstDate( p_aout, &p_aout->output.fifo );
 
         /* wake up the audio output thread */
-        vlc_mutex_lock( &p_aout->output.p_sys->lock );
         vlc_cond_signal( &p_aout->output.p_sys->wait );
         vlc_mutex_unlock( &p_aout->output.p_sys->lock );
     }