Commit 557eaa06 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

decoder: drain the audio output properly

parent 90a41800
...@@ -113,6 +113,7 @@ struct decoder_owner_sys_t ...@@ -113,6 +113,7 @@ struct decoder_owner_sys_t
/* Flushing */ /* Flushing */
bool b_flushing; bool b_flushing;
bool b_draining; bool b_draining;
bool b_drained;
bool b_idle; bool b_idle;
/* CC */ /* CC */
...@@ -1423,7 +1424,6 @@ static void *DecoderThread( void *p_data ) ...@@ -1423,7 +1424,6 @@ static void *DecoderThread( void *p_data )
vlc_fifo_Lock( p_owner->p_fifo ); vlc_fifo_Lock( p_owner->p_fifo );
vlc_fifo_CleanupPush( p_owner->p_fifo ); vlc_fifo_CleanupPush( p_owner->p_fifo );
vlc_cond_signal( &p_owner->wait_acknowledge );
vlc_cond_signal( &p_owner->wait_fifo ); vlc_cond_signal( &p_owner->wait_fifo );
while( vlc_fifo_IsEmpty( p_owner->p_fifo ) ) while( vlc_fifo_IsEmpty( p_owner->p_fifo ) )
...@@ -1447,6 +1447,18 @@ static void *DecoderThread( void *p_data ) ...@@ -1447,6 +1447,18 @@ static void *DecoderThread( void *p_data )
int canc = vlc_savecancel(); int canc = vlc_savecancel();
DecoderProcess( p_dec, p_block ); DecoderProcess( p_dec, p_block );
vlc_mutex_lock( &p_owner->lock );
if( p_block == NULL )
{ /* Draining: the decoder is drained and all decoded buffers are
* queued to the output at this point. Now drain the output. */
if( p_owner->p_aout != NULL )
aout_DecFlush( p_owner->p_aout, true );
}
p_owner->b_drained = (p_block == NULL);
vlc_cond_signal( &p_owner->wait_acknowledge );
vlc_mutex_unlock( &p_owner->lock );
vlc_restorecancel( canc ); vlc_restorecancel( canc );
} }
return NULL; return NULL;
...@@ -1600,6 +1612,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent, ...@@ -1600,6 +1612,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
p_owner->b_flushing = false; p_owner->b_flushing = false;
p_owner->b_draining = false; p_owner->b_draining = false;
p_owner->b_drained = false;
p_owner->b_idle = false; p_owner->b_idle = false;
/* */ /* */
...@@ -1890,8 +1903,8 @@ bool input_DecoderIsEmpty( decoder_t * p_dec ) ...@@ -1890,8 +1903,8 @@ bool input_DecoderIsEmpty( decoder_t * p_dec )
vlc_mutex_lock( &p_owner->lock ); vlc_mutex_lock( &p_owner->lock );
if( p_owner->fmt.i_cat == VIDEO_ES && p_owner->p_vout != NULL ) if( p_owner->fmt.i_cat == VIDEO_ES && p_owner->p_vout != NULL )
b_empty = vout_IsEmpty( p_owner->p_vout ); b_empty = vout_IsEmpty( p_owner->p_vout );
else if( p_owner->fmt.i_cat == AUDIO_ES && p_owner->p_aout != NULL ) else if( p_owner->fmt.i_cat == AUDIO_ES )
b_empty = aout_DecIsEmpty( p_owner->p_aout ); b_empty = p_owner->b_drained;
else else
b_empty = true; /* TODO subtitles support */ b_empty = true; /* TODO subtitles support */
vlc_mutex_unlock( &p_owner->lock ); vlc_mutex_unlock( &p_owner->lock );
......
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