From a18cf1de2e0e1cecfb44894e5043b6806361d15d Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sat, 27 Sep 2008 16:19:51 +0200 Subject: [PATCH] Moved clock master flag to es_out. --- src/input/clock.c | 56 ++++++++++++++++------------------------- src/input/es_out.c | 5 +--- src/input/input.c | 3 --- src/input/input_clock.h | 13 ++++------ 4 files changed, 27 insertions(+), 50 deletions(-) diff --git a/src/input/clock.c b/src/input/clock.c index d7b53a6559..7d1d5b0f12 100644 --- a/src/input/clock.c +++ b/src/input/clock.c @@ -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 @@ -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; } /***************************************************************************** diff --git a/src/input/es_out.c b/src/input/es_out.c index 887bf0844a..c32bf64a10 100644 --- a/src/input/es_out.c +++ b/src/input/es_out.c @@ -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 ); diff --git a/src/input/input.c b/src/input/input.c index 62536496c4..14fa876800 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -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 ); } diff --git a/src/input/input_clock.h b/src/input/input_clock.h index 5f78c6781a..db5340a42d 100644 --- a/src/input/input_clock.h +++ b/src/input/input_clock.h @@ -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 -- GitLab