[vlc-devel] [PATCH 11/11] demux: wav: fix wrong pts after a seek

Steve Lhomme robux4 at ycbcr.xyz
Fri Mar 13 11:11:01 CET 2020


On 2020-03-12 14:56, Thomas Guillem wrote:
> ---
>   modules/demux/wav.c | 30 ++++++++++++++++++++++++++----
>   1 file changed, 26 insertions(+), 4 deletions(-)
> 
> diff --git a/modules/demux/wav.c b/modules/demux/wav.c
> index 3d71711791f..0fcf644eccf 100644
> --- a/modules/demux/wav.c
> +++ b/modules/demux/wav.c
> @@ -141,10 +141,32 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
>       if( p_sys->i_data_size > 0 )
>           i_end = p_sys->i_data_pos + p_sys->i_data_size;
>   
> -    return demux_vaControlHelper( p_demux->s, p_sys->i_data_pos, i_end,
> -                                   p_sys->fmt.i_bitrate,
> -                                   p_sys->fmt.audio.i_blockalign,
> -                                   i_query, args );
> +    int ret = demux_vaControlHelper( p_demux->s, p_sys->i_data_pos, i_end,
> +                                     p_sys->fmt.i_bitrate,
> +                                     p_sys->fmt.audio.i_blockalign,
> +                                     i_query, args );
> +    if( ret != VLC_SUCCESS )
> +        return ret;
> +
> +    /* Update the date to the new seek point */
> +    switch( i_query )
> +    {
> +        case DEMUX_SET_POSITION:
> +        case DEMUX_SET_TIME:
> +        {
> +            uint64_t ofs = vlc_stream_Tell( p_demux->s );
> +            if( unlikely( ofs < p_sys->i_data_pos ) )
> +                return VLC_SUCCESS;
> +
> +            ofs -= p_sys->i_data_pos;
> +            vlc_tick_t pts = ofs * INT64_C(8000000) / p_sys->fmt.i_bitrate;

There's a helper for that: vlc_tick_from_samples()
It doesn't assume CLOCK_FREQ is 1000000

> +            date_Set( &p_sys->pts, pts );
> +            break;
> +        }
> +        default:
> +            break;
> +    }
> +    return VLC_SUCCESS;
>   }
>   
>   static int ChunkSkip( demux_t *p_demux, size_t i_size )
> -- 
> 2.20.1
> 
> _______________________________________________
> 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