clock_point_t ref;
bool b_has_reference;
+ /* External clock drift */
+ mtime_t i_external_clock;
+ bool b_has_external_clock;
+
/* Current modifiers */
bool b_paused;
int i_rate;
vlc_mutex_init( &cl->lock );
cl->b_has_reference = false;
cl->ref = clock_point_Create( VLC_TS_INVALID, VLC_TS_INVALID );
+ cl->b_has_external_clock = false;
cl->last = clock_point_Create( VLC_TS_INVALID, VLC_TS_INVALID );
cl->b_has_reference = true;
cl->ref = clock_point_Create( i_ck_stream,
__MAX( cl->i_ts_max + CR_MEAN_PTS_GAP, i_ck_system ) );
+ cl->b_has_external_clock = false;
}
/* Compute the drift between the stream clock and the system clock
cl->b_has_reference = false;
cl->ref = clock_point_Create( VLC_TS_INVALID, VLC_TS_INVALID );
+ cl->b_has_external_clock = false;
cl->i_ts_max = VLC_TS_INVALID;
vlc_mutex_unlock( &cl->lock );
return VLC_SUCCESS;
}
-void input_clock_ChangeSystemOrigin( input_clock_t *cl, mtime_t i_system )
+void input_clock_ChangeSystemOrigin( input_clock_t *cl, bool b_absolute, mtime_t i_system )
{
vlc_mutex_lock( &cl->lock );
assert( cl->b_has_reference );
- const mtime_t i_offset = i_system - cl->ref.i_system - ClockGetTsOffset( cl );
+ mtime_t i_offset;
+ if( b_absolute )
+ {
+ i_offset = i_system - cl->ref.i_system - ClockGetTsOffset( cl );
+ }
+ else
+ {
+ if( !cl->b_has_external_clock )
+ {
+ cl->b_has_external_clock = true;
+ cl->i_external_clock = i_system;
+ }
+ i_offset = i_system - cl->i_external_clock;
+ }
cl->ref.i_system += i_offset;
cl->last.i_system += i_offset;