[vlc-devel] [PATCH 11/11] demux: wav: fix wrong pts after a seek
Thomas Guillem
thomas at gllm.fr
Fri Mar 13 17:13:59 CET 2020
On Fri, Mar 13, 2020, at 11:11, Steve Lhomme wrote:
> 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
Thanks for catching this wise garden of the tick.
>
> > + 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
> >
> _______________________________________________
> 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