Commit 355ec9f1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

decoder: do not wait for buffering when there is no data

This removes small hacks surrounding this corner case.
parent ea86f279
...@@ -105,7 +105,6 @@ struct decoder_owner_sys_t ...@@ -105,7 +105,6 @@ struct decoder_owner_sys_t
} pause; } pause;
/* Waiting */ /* Waiting */
bool b_woken;
bool b_waiting; bool b_waiting;
bool b_first; bool b_first;
bool b_has_data; bool b_has_data;
...@@ -113,6 +112,7 @@ struct decoder_owner_sys_t ...@@ -113,6 +112,7 @@ struct decoder_owner_sys_t
/* Flushing */ /* Flushing */
bool b_flushing; bool b_flushing;
bool b_draining; bool b_draining;
bool b_idle;
/* CC */ /* CC */
struct struct
...@@ -1427,45 +1427,34 @@ static void *DecoderThread( void *p_data ) ...@@ -1427,45 +1427,34 @@ static void *DecoderThread( void *p_data )
for( ;; ) for( ;; )
{ {
block_t *p_block; block_t *p_block;
bool draining = false;
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 );
while( vlc_fifo_IsEmpty( p_owner->p_fifo ) ) while( vlc_fifo_IsEmpty( p_owner->p_fifo ) )
{ {
if( p_owner->b_draining ) if( p_owner->b_draining )
{ /* We have emptied the FIFO and there is a pending request to { /* We have emptied the FIFO and there is a pending request to
* drain. Pass p_block = NULL to decoder just once. */ * drain. Pass p_block = NULL to decoder just once. */
p_owner->b_draining = false; p_owner->b_draining = false;
draining = true;
break; break;
} }
if( p_owner->b_woken )
break;
p_owner->b_idle = true;
vlc_fifo_Wait( p_owner->p_fifo ); vlc_fifo_Wait( p_owner->p_fifo );
/* Make sure there is no cancellation point other than this one^^. /* Make sure there is no cancellation point other than this one^^.
* If you need one, be sure to push cleanup of p_block. */ * If you need one, be sure to push cleanup of p_block. */
p_owner->b_idle = false;
} }
p_block = vlc_fifo_DequeueUnlocked( p_owner->p_fifo ); p_block = vlc_fifo_DequeueUnlocked( p_owner->p_fifo );
if( p_block != NULL )
vlc_cond_signal( &p_owner->wait_acknowledge );
p_owner->b_woken = false;
vlc_cleanup_run(); vlc_cleanup_run();
if( p_block == NULL )
DecoderSignalWait( p_dec );
if( p_block != NULL || draining )
{
int canc = vlc_savecancel(); int canc = vlc_savecancel();
DecoderProcess( p_dec, p_block ); DecoderProcess( p_dec, p_block );
vlc_restorecancel( canc ); vlc_restorecancel( canc );
} }
}
return NULL; return NULL;
} }
...@@ -1529,7 +1518,6 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent, ...@@ -1529,7 +1518,6 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
es_format_Init( &p_owner->fmt, UNKNOWN_ES, 0 ); es_format_Init( &p_owner->fmt, UNKNOWN_ES, 0 );
/* decoder fifo */ /* decoder fifo */
p_owner->b_woken = false;
p_owner->p_fifo = block_FifoNew(); p_owner->p_fifo = block_FifoNew();
if( unlikely(p_owner->p_fifo == NULL) ) if( unlikely(p_owner->p_fifo == NULL) )
{ {
...@@ -1617,6 +1605,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent, ...@@ -1617,6 +1605,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_idle = false;
/* */ /* */
p_owner->cc.b_supported = false; p_owner->cc.b_supported = false;
...@@ -2125,14 +2114,21 @@ void input_DecoderWait( decoder_t *p_dec ) ...@@ -2125,14 +2114,21 @@ void input_DecoderWait( decoder_t *p_dec )
assert( p_owner->b_waiting ); assert( p_owner->b_waiting );
vlc_mutex_lock( &p_owner->lock ); vlc_mutex_lock( &p_owner->lock );
vlc_fifo_Lock( p_owner->p_fifo );
while( !p_owner->b_has_data ) while( !p_owner->b_has_data )
{ {
vlc_fifo_Lock( p_owner->p_fifo ); if( p_owner->b_idle )
p_owner->b_woken = true; {
assert( vlc_fifo_IsEmpty( p_owner->p_fifo ) );
msg_Warn( p_dec, "can't wait without data to decode" );
break;
}
vlc_fifo_Signal( p_owner->p_fifo ); vlc_fifo_Signal( p_owner->p_fifo );
vlc_fifo_Unlock( p_owner->p_fifo ); vlc_fifo_Unlock( p_owner->p_fifo );
vlc_cond_wait( &p_owner->wait_acknowledge, &p_owner->lock ); vlc_cond_wait( &p_owner->wait_acknowledge, &p_owner->lock );
vlc_fifo_Lock( p_owner->p_fifo );
} }
vlc_fifo_Unlock( p_owner->p_fifo );
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