X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finput%2Fclock.c;h=c4f81009b6ea50ebcf29629c1c558abf8a773ff5;hb=3b2502986923eb8ebf0bdcd7cc7ded6291af2587;hp=811ec7a6449f84879bf6694ecf45cda1ea89b6af;hpb=3c84b6ca4ced1aad7549e30261fbe3348c529c15;p=vlc diff --git a/src/input/clock.c b/src/input/clock.c index 811ec7a644..c4f81009b6 100644 --- a/src/input/clock.c +++ b/src/input/clock.c @@ -95,7 +95,9 @@ * It is 60s max, remember as it is limited by the size it takes by es_out.c * it can be really large. */ -#define CR_BUFFERING_TARGET (60000000) +//#define CR_BUFFERING_TARGET (60000000) +/* Due to some problems in es_out, we cannot use a large value yet */ +#define CR_BUFFERING_TARGET (100000) /***************************************************************************** * Structures @@ -142,10 +144,6 @@ struct input_clock_t /* */ vlc_mutex_t lock; - /* Reference point */ - bool b_has_reference; - clock_point_t ref; - /* Last point * It is used to detect unexpected stream discontinuities */ clock_point_t last; @@ -167,10 +165,18 @@ struct input_clock_t unsigned i_index; } late; + /* Reference point */ + 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; mtime_t i_pts_delay; - bool b_paused; mtime_t i_pause_date; }; @@ -191,6 +197,7 @@ input_clock_t *input_clock_New( 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 ); @@ -270,6 +277,7 @@ void input_clock_Update( input_clock_t *cl, vlc_object_t *p_log, 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 @@ -327,6 +335,7 @@ void input_clock_Reset( input_clock_t *cl ) 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 ); @@ -480,12 +489,25 @@ int input_clock_GetState( input_clock_t *cl, 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; @@ -493,6 +515,19 @@ void input_clock_ChangeSystemOrigin( input_clock_t *cl, mtime_t i_system ) vlc_mutex_unlock( &cl->lock ); } +void input_clock_GetSystemOrigin( input_clock_t *cl, mtime_t *pi_system, mtime_t *pi_delay ) +{ + vlc_mutex_lock( &cl->lock ); + + assert( cl->b_has_reference ); + + *pi_system = cl->ref.i_system; + if( pi_delay ) + *pi_delay = cl->i_pts_delay; + + vlc_mutex_unlock( &cl->lock ); +} + #warning "input_clock_SetJitter needs more work" void input_clock_SetJitter( input_clock_t *cl, mtime_t i_pts_delay, int i_cr_average )