* input_clock.c: Clock/System date convertions, stream management
*****************************************************************************
* Copyright (C) 1999-2008 the VideoLAN team
+ * Copyright (C) 2008 Laurent Aimar
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
average_t drift;
/* Current modifiers */
- bool b_master;
int i_rate;
};
/*****************************************************************************
* input_clock_New: create a new clock
*****************************************************************************/
-input_clock_t *input_clock_New( bool b_master, int i_cr_average, int i_rate )
+input_clock_t *input_clock_New( int i_cr_average, int i_rate )
{
input_clock_t *cl = malloc( sizeof(*cl) );
if( !cl )
cl->i_next_drift_update = 0;
AvgInit( &cl->drift, i_cr_average );
- cl->b_master = b_master;
cl->i_rate = i_rate;
return cl;
vlc_object_t *p_log, bool b_can_pace_control,
mtime_t i_ck_stream, mtime_t i_ck_system )
{
- const bool b_synchronize = b_can_pace_control && cl->b_master;
bool b_reset_reference = false;
if( ( !cl->b_has_reference ) ||
__MAX( cl->i_ts_max + CR_MEAN_PTS_GAP, i_ck_system ) );
}
- if( !b_synchronize && cl->i_next_drift_update < i_ck_system )
+ if( !b_can_pace_control && cl->i_next_drift_update < i_ck_system )
{
const mtime_t i_converted = ClockSystemToStream( cl, i_ck_system );
cl->i_ts_max = 0;
}
-/*****************************************************************************
- * input_clock_GetTS: manages a PTS or DTS
- *****************************************************************************/
-mtime_t input_clock_GetTS( input_clock_t *cl,
- mtime_t i_pts_delay, mtime_t i_ts )
-{
- mtime_t i_converted_ts;
-
- if( !cl->b_has_reference )
- return 0;
-
- /* */
- i_converted_ts = ClockStreamToSystem( cl, i_ts + AvgGet( &cl->drift ) );
- if( i_converted_ts > cl->i_ts_max )
- cl->i_ts_max = i_converted_ts;
-
- return i_converted_ts + i_pts_delay;
-}
-
/*****************************************************************************
* input_clock_ChangeRate:
*****************************************************************************/
cl->i_rate = i_rate;
}
-/*****************************************************************************
- * input_clock_ChangeMaster:
- *****************************************************************************/
-void input_clock_ChangeMaster( input_clock_t *cl, bool b_master )
-{
- cl->b_master = b_master;
-}
-
/*****************************************************************************
* input_clock_GetWakeup
*****************************************************************************/
if( !cl->b_has_reference )
return 0;
- /* We must not wait if we are not the master clock */
- if( !cl->b_master )
+ /* */
+ return ClockStreamToSystem( cl, cl->last.i_stream );
+}
+
+/*****************************************************************************
+ * input_clock_GetTS: manages a PTS or DTS
+ *****************************************************************************/
+mtime_t input_clock_GetTS( input_clock_t *cl,
+ mtime_t i_pts_delay, mtime_t i_ts )
+{
+ mtime_t i_converted_ts;
+
+ if( !cl->b_has_reference )
return 0;
/* */
- return ClockStreamToSystem( cl, cl->last.i_stream );
+ i_converted_ts = ClockStreamToSystem( cl, i_ts + AvgGet( &cl->drift ) );
+ if( i_converted_ts > cl->i_ts_max )
+ cl->i_ts_max = i_converted_ts;
+
+ return i_converted_ts + i_pts_delay;
}
/*****************************************************************************
* This function creates a new input_clock_t.
* You must use input_clock_Delete to delete it once unused.
*/
-input_clock_t *input_clock_New( bool b_master, int i_cr_average, int i_rate );
+input_clock_t *input_clock_New( int i_cr_average, int i_rate );
/**
* This function destroys a input_clock_t created by input_clock_New.
*/
*/
void input_clock_Reset( input_clock_t * );
-/**
- * This function converts a timestamp from stream clock to system clock.
- */
-mtime_t input_clock_GetTS( input_clock_t *, mtime_t i_pts_delay, mtime_t );
/**
* This functions will return a deadline used to control the reading speed.
*/
mtime_t input_clock_GetWakeup( input_clock_t *cl );
+
/**
* This functions allows to change the actual reading speed.
*/
void input_clock_ChangeRate( input_clock_t *cl, int i_rate );
+
/**
- * This function allows to change the master status of a clock.
- * FIXME it should probably be moved out of input_clock_t.
+ * This function converts a timestamp from stream clock to system clock.
*/
-void input_clock_ChangeMaster( input_clock_t *cl, bool b_master );
+mtime_t input_clock_GetTS( input_clock_t *, mtime_t i_pts_delay, mtime_t );
#endif