Skip to content

Commit

Permalink
input: add offset during seek by time operation
Browse files Browse the repository at this point in the history
Add an offset of `priv->i_start` during the seek by time operation to correctly account
for the start time of individual segmented tracks. Modify the initial value passed to
`input_SetTime()` to 0, as the start offset (`priv->i_start`) has already been considered.

These changes ensure accurate timing and seek behavior in media files containing segmented tracks,
such as those defined by CUE files, by aligning the seek position with the actual timing of individual
segments.
  • Loading branch information
its-ayush-07 authored and robUx4 committed Sep 16, 2024
1 parent d143110 commit cc63808
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ static int MainLoopTryRepeat( input_thread_t *p_input )

/* Seek to start position */
if( priv->i_start > 0 )
input_SetTime( p_input, priv->i_start, false );
input_SetTime( p_input, 0, false );
else
input_SetPosition( p_input, 0.0f, false );

Expand Down Expand Up @@ -926,7 +926,7 @@ static void SetStopStart( input_thread_t * p_input )
msg_Dbg( p_input, "starting at time: %"PRId64"s",
SEC_FROM_VLC_TICK(priv->i_start) );

input_SetTime( p_input, priv->i_start, false );
input_SetTime( p_input, 0, false );
}
if( priv->i_stop > 0 && priv->i_stop <= priv->i_start )
{
Expand Down Expand Up @@ -1985,15 +1985,15 @@ static bool Control( input_thread_t *p_input,
/* Reset the decoders states and clock sync (before calling the demuxer */
es_out_Control(&priv->p_es_out->out, ES_OUT_RESET_PCR);

i_ret = demux_SetTime( priv->master->p_demux, param.time.i_val,
i_ret = demux_SetTime( priv->master->p_demux, priv->i_start + param.time.i_val,
!param.time.b_fast_seek );
if( i_ret )
{
vlc_tick_t i_length = InputSourceGetLength( priv->master, priv->p_item );
/* Emulate it with a SET_POS */
if( i_length > 0 )
{
double f_pos = (double)param.time.i_val / (double)i_length;
double f_pos = (double)(priv->i_start + param.time.i_val) / (double)i_length;
i_ret = demux_SetPosition( priv->master->p_demux, f_pos,
!param.time.b_fast_seek );
}
Expand Down

0 comments on commit cc63808

Please sign in to comment.