[vlc-devel] [RFC PATCH 1/4] decoder: don't wait for flush to complete
Thomas Guillem
thomas at gllm.fr
Tue Nov 17 16:54:16 CET 2015
On Tue, Nov 17, 2015, at 16:46, Rémi Denis-Courmont wrote:
> Le 2015-11-17 18:16, Thomas Guillem a écrit :
> > ---
> > src/input/decoder.c | 31 +++++--------------------------
> > 1 file changed, 5 insertions(+), 26 deletions(-)
> >
> > diff --git a/src/input/decoder.c b/src/input/decoder.c
> > index cacf7f2..16c985a 100644
> > --- a/src/input/decoder.c
> > +++ b/src/input/decoder.c
> > @@ -109,8 +109,7 @@ struct decoder_owner_sys_t
> > bool b_has_data;
> >
> > /* Flushing */
> > - bool flushing;
> > - bool flushed;
> > + atomic_bool flushing;
>
> Why atomic?
I needed atomic for the first version of my patch. I didn't realized
that it wasn't needed anymore.
>
> > bool b_draining;
> > atomic_bool drained;
> > bool b_idle;
> > @@ -1330,7 +1329,7 @@ static void *DecoderThread( void *p_data )
> >
> > for( ;; )
> > {
> > - if( p_owner->flushing )
> > + if( atomic_load( &p_owner->flushing ) )
> > { /* Flush before/regardless of pause. We do not want to
> > resume just
> > * for the sake of flushing (glitches could otherwise
> > happen). */
> > int canc = vlc_savecancel();
> > @@ -1341,9 +1340,6 @@ static void *DecoderThread( void *p_data )
> > if( unlikely(dummy == NULL) )
> > msg_Err( p_dec, "cannot flush" );
> >
> > - /* Owner is buggy if it queues data while flushing */
> > - assert( vlc_fifo_IsEmpty( p_owner->p_fifo ) );
> > - p_owner->flushing = false;
> > vlc_fifo_Unlock( p_owner->p_fifo );
> >
> > /* Flush the decoder (and the output) */
> > @@ -1351,12 +1347,8 @@ static void *DecoderThread( void *p_data )
> >
> > vlc_fifo_Lock( p_owner->p_fifo );
> > vlc_restorecancel( canc );
> > + atomic_store( &p_owner->flushing, false );
> >
> > - /* Owner is supposed to wait for flush to complete.
> > - * TODO: It might be possible to remove this
> > restriction. */
> > - assert( vlc_fifo_IsEmpty( p_owner->p_fifo ) );
> > - p_owner->flushed = true;
> > - vlc_cond_signal( &p_owner->wait_fifo );
> > continue;
> > }
> >
> > @@ -1485,9 +1477,8 @@ static decoder_t * CreateDecoder( vlc_object_t
> > *p_parent,
> > p_owner->b_first = true;
> > p_owner->b_has_data = false;
> >
> > - p_owner->flushing = false;
> > - p_owner->flushed = true;
> > p_owner->b_draining = false;
> > + atomic_init( &p_owner->flushing, false );
> > atomic_init( &p_owner->drained, false );
> > p_owner->b_idle = false;
> >
> > @@ -1818,7 +1809,6 @@ void input_DecoderDecode( decoder_t *p_dec,
> > block_t *p_block, bool b_do_pace )
> > vlc_fifo_WaitCond( p_owner->p_fifo, &p_owner->wait_fifo
> > );
> > }
> >
> > - p_owner->flushed = false;
> > vlc_fifo_QueueUnlocked( p_owner->p_fifo, p_block );
> > vlc_fifo_Unlock( p_owner->p_fifo );
> > }
> > @@ -1874,16 +1864,9 @@ void input_DecoderFlush( decoder_t *p_dec )
> >
> > vlc_fifo_Lock( p_owner->p_fifo );
> >
> > - /* Don't flush if already flushed */
> > - if( p_owner->flushed )
> > - {
> > - vlc_fifo_Unlock( p_owner->p_fifo );
> > - return;
> > - }
> > -
> > /* Empty the fifo */
> > block_ChainRelease( vlc_fifo_DequeueAllUnlocked( p_owner->p_fifo
> > ) );
> > - p_owner->flushing = true;
> > + atomic_store( &p_owner->flushing, true );
> >
> > /* Flushing video decoder when paused: increment
> > frames_countdown in order
> > * to display one frame */
> > @@ -1893,10 +1876,6 @@ void input_DecoderFlush( decoder_t *p_dec )
> >
> > vlc_fifo_Signal( p_owner->p_fifo );
> >
> > - /* Monitor for flush end */
> > - while( !p_owner->flushed )
> > - vlc_fifo_WaitCond( p_owner->p_fifo, &p_owner->wait_fifo );
> > -
> > vlc_fifo_Unlock( p_owner->p_fifo );
> > }
>
> --
> Rémi Denis-Courmont
> http://www.remlab.net/
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list