Commit 9e6e2eeb authored by Laurent Aimar's avatar Laurent Aimar

Correctly flush video/audio decoder in all cases.

parent 0e420aff
...@@ -888,10 +888,23 @@ static void *DecoderThread( vlc_object_t *p_this ) ...@@ -888,10 +888,23 @@ static void *DecoderThread( vlc_object_t *p_this )
return NULL; return NULL;
} }
static block_t *DecoderBlockFlushNew()
{
block_t *p_null = block_Alloc( 128 );
if( !p_null )
return NULL;
p_null->i_flags |= BLOCK_FLAG_DISCONTINUITY |
BLOCK_FLAG_CORRUPTED |
BLOCK_FLAG_CORE_FLUSH;
memset( p_null->p_buffer, 0, p_null->i_buffer );
return p_null;
}
static void DecoderFlush( decoder_t *p_dec ) static void DecoderFlush( decoder_t *p_dec )
{ {
decoder_owner_sys_t *p_owner = p_dec->p_owner; decoder_owner_sys_t *p_owner = p_dec->p_owner;
block_t *p_null;
vlc_assert_locked( &p_owner->lock ); vlc_assert_locked( &p_owner->lock );
...@@ -903,15 +916,9 @@ static void DecoderFlush( decoder_t *p_dec ) ...@@ -903,15 +916,9 @@ static void DecoderFlush( decoder_t *p_dec )
vlc_cond_signal( &p_owner->wait ); vlc_cond_signal( &p_owner->wait );
/* Send a special block */ /* Send a special block */
p_null = block_New( p_dec, 128 ); block_t *p_null = DecoderBlockFlushNew();
if( !p_null ) if( !p_null )
return; return;
p_null->i_flags |= BLOCK_FLAG_DISCONTINUITY;
p_null->i_flags |= BLOCK_FLAG_CORE_FLUSH;
if( !p_dec->fmt_in.b_packetized )
p_null->i_flags |= BLOCK_FLAG_CORRUPTED;
memset( p_null->p_buffer, 0, p_null->i_buffer );
input_DecoderDecode( p_dec, p_null ); input_DecoderDecode( p_dec, p_null );
/* */ /* */
...@@ -1796,6 +1803,14 @@ static void DecoderProcessVideo( decoder_t *p_dec, block_t *p_block, bool b_flus ...@@ -1796,6 +1803,14 @@ static void DecoderProcessVideo( decoder_t *p_dec, block_t *p_block, bool b_flus
p_packetized_block = p_next; p_packetized_block = p_next;
} }
} }
/* The packetizer does not output a block that tell the decoder to flush
* do it ourself */
if( b_flush )
{
block_t *p_null = DecoderBlockFlushNew();
if( p_null )
DecoderDecodeVideo( p_dec, p_null );
}
} }
else if( p_block ) else if( p_block )
{ {
...@@ -1836,6 +1851,14 @@ static void DecoderProcessAudio( decoder_t *p_dec, block_t *p_block, bool b_flus ...@@ -1836,6 +1851,14 @@ static void DecoderProcessAudio( decoder_t *p_dec, block_t *p_block, bool b_flus
p_packetized_block = p_next; p_packetized_block = p_next;
} }
} }
/* The packetizer does not output a block that tell the decoder to flush
* do it ourself */
if( b_flush )
{
block_t *p_null = DecoderBlockFlushNew();
if( p_null )
DecoderDecodeAudio( p_dec, p_null );
}
} }
else if( p_block ) else if( p_block )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment