Commit a18cf1de authored by Laurent Aimar's avatar Laurent Aimar

Moved clock master flag to es_out.

parent 5775fda6
......@@ -2,6 +2,7 @@
* 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>
......@@ -132,7 +133,6 @@ struct input_clock_t
average_t drift;
/* Current modifiers */
bool b_master;
int i_rate;
};
......@@ -142,7 +142,7 @@ static mtime_t ClockSystemToStream( input_clock_t *, mtime_t i_system );
/*****************************************************************************
* 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 )
......@@ -158,7 +158,6 @@ input_clock_t *input_clock_New( bool b_master, int i_cr_average, int i_rate )
cl->i_next_drift_update = 0;
AvgInit( &cl->drift, i_cr_average );
cl->b_master = b_master;
cl->i_rate = i_rate;
return cl;
......@@ -183,7 +182,6 @@ void input_clock_Update( input_clock_t *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 ) ||
......@@ -217,7 +215,7 @@ void input_clock_Update( input_clock_t *cl,
__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 );
......@@ -238,25 +236,6 @@ void input_clock_Reset( input_clock_t *cl )
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:
*****************************************************************************/
......@@ -269,14 +248,6 @@ void input_clock_ChangeRate( input_clock_t *cl, int i_rate )
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
*****************************************************************************/
......@@ -286,12 +257,27 @@ mtime_t input_clock_GetWakeup( input_clock_t *cl )
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;
}
/*****************************************************************************
......
......@@ -646,9 +646,6 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
p_pgrm->b_selected = true;
/* Switch master stream */
if( p_sys->p_pgrm )
input_clock_ChangeMaster( p_sys->p_pgrm->p_clock, false );
input_clock_ChangeMaster( p_pgrm->p_clock, true );
p_sys->p_pgrm = p_pgrm;
/* Update "program" */
......@@ -697,7 +694,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
p_pgrm->psz_now_playing = NULL;
p_pgrm->psz_publisher = NULL;
p_pgrm->p_epg = NULL;
p_pgrm->p_clock = input_clock_New( false, p_input->p->input.i_cr_average, p_sys->i_rate );
p_pgrm->p_clock = input_clock_New( p_input->p->input.i_cr_average, p_sys->i_rate );
if( !p_pgrm->p_clock )
{
free( p_pgrm );
......
......@@ -774,10 +774,7 @@ static void MainLoop( input_thread_t *p_input )
{
mtime_t i_new_wakeup = input_EsOutGetWakeup( p_input->p->p_es_out );
if( !i_new_wakeup )
{
msg_Err( p_input, "RESET" );
i_wakeup = 0;
}
}
} while( i_current < i_wakeup );
}
......
......@@ -40,7 +40,7 @@ typedef struct input_clock_t input_clock_t;
* 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.
*/
......@@ -58,23 +58,20 @@ void input_clock_Update( input_clock_t *, vlc_object_t *p_log,
*/
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment