[vlc-devel] [V4 PATCH 2/2] dec: update pause/rate when the output is restarted

Steve Lhomme robux4 at ycbcr.xyz
Fri Jul 6 08:18:05 CEST 2018


On 2018-07-05 12:02, Thomas Guillem wrote:
> The aout/vout paused/rate state was not set if the output was restarted within
> the lifetime of the decoder.
> ---
>   src/input/decoder.c | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
>
> diff --git a/src/input/decoder.c b/src/input/decoder.c
> index dfcbf2ce66..040ccd64e5 100644
> --- a/src/input/decoder.c
> +++ b/src/input/decoder.c
> @@ -112,6 +112,7 @@ struct decoder_owner
>       /* Preroll */
>       vlc_tick_t i_preroll_end;
>       /* Pause & Rate */
> +    bool reset_out_state;

Maybe an atomic would be better ? to avoid locking when writing it. Plus 
you get to get/reset the value in one call.

>       vlc_tick_t pause_date;
>       float rate;
>       unsigned frames_countdown;
> @@ -404,6 +405,10 @@ static int aout_update_format( decoder_t *p_dec )
>               p_owner->fmt.audio.i_bytes_per_frame;
>           p_dec->fmt_out.audio.i_frame_length =
>               p_owner->fmt.audio.i_frame_length;
> +
> +        vlc_fifo_Lock( p_owner->p_fifo );
> +        p_owner->reset_out_state = true;
> +        vlc_fifo_Unlock( p_owner->p_fifo );
>       }
>       return 0;
>   }
> @@ -536,6 +541,10 @@ static int vout_update_format( decoder_t *p_dec )
>               msg_Err( p_dec, "failed to create video output" );
>               return -1;
>           }
> +
> +        vlc_fifo_Lock( p_owner->p_fifo );
> +        p_owner->reset_out_state = true;
> +        vlc_fifo_Unlock( p_owner->p_fifo );
>       }
>   
>       if ( memcmp( &p_dec->fmt_out.video.mastering,
> @@ -1565,6 +1574,16 @@ static void *DecoderThread( void *p_data )
>               continue;
>           }
>   
> +        /* Reset the original pause/rate state when a new aout/vout is created:
> +         * this will trigger the OutputChangePause/OutputChangeRate code path
> +         * if needed. */
> +        if( p_owner->reset_out_state )
> +        {
> +            rate = 1.f;
> +            paused = false;
> +            p_owner->reset_out_state = false;
> +        }
> +
>           if( paused != p_owner->paused )
>           {   /* Update playing/paused status of the output */
>               int canc = vlc_savecancel();
> @@ -1718,6 +1737,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
>       p_owner->b_fmt_description = false;
>       p_owner->p_description = NULL;
>   
> +    p_owner->reset_out_state = false;
>       p_owner->rate = 1.f;
>       p_owner->paused = false;
>       p_owner->pause_date = VLC_TICK_INVALID;
> -- 
> 2.18.0
>
> _______________________________________________
> 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