]> git.sesse.net Git - vlc/commitdiff
decoder: fix race in spu_new_buffer
authorThomas Guillem <thomas@gllm.fr>
Wed, 18 Mar 2015 09:16:44 +0000 (09:16 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 20 Mar 2015 15:10:12 +0000 (16:10 +0100)
There is a race when starting video with subtitles at a given position (via
--start-time).

If all decoders are flushed early, the video decoder may not have created the
Vout via the decoder_NewPicture call. In that case, spu_new_buffer will be
blocking for 6 seconds. Indeed, spu_new_buffer can block for maximum 6 seconds
when it's waiting for a Vout.

To solve this race, abort spu_new_buffer if decoder is flushing.

How to reproduce the race condition:
./vlc --start-time 3600 <video_with_subtitles>

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
src/input/decoder.c

index 8e1a658b6355c4b5a1d107a56143097c18d0dfc1..b5ac4646de10381bc6927fccecc58f30336c4783 100644 (file)
@@ -2192,7 +2192,8 @@ static subpicture_t *spu_new_buffer( decoder_t *p_dec,
 
     while( i_attempts-- )
     {
-        if( DecoderIsExitRequested( p_dec ) || p_dec->b_error )
+        if( DecoderIsExitRequested( p_dec ) || DecoderIsFlushing( p_dec )
+         || p_dec->b_error )
             break;
 
         p_vout = input_resource_HoldVout( p_owner->p_resource );