X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finput%2Finput_clock.c;h=7df1aa4d34314a037cdb05407b378788aa76146f;hb=e01eb15e2a09e0dcb42b2145770b7ae2d2e42436;hp=37b418ee683d980fead79456ead9f7df0be712fd;hpb=1b8d106c723cfe9a75449dbfe5cd5a4e677159a0;p=vlc diff --git a/src/input/input_clock.c b/src/input/input_clock.c index 37b418ee68..7df1aa4d34 100644 --- a/src/input/input_clock.c +++ b/src/input/input_clock.c @@ -2,7 +2,7 @@ * input_clock.c: Clock/System date convertions, stream management ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: input_clock.c,v 1.27 2001/12/07 18:33:08 sam Exp $ + * $Id: input_clock.c,v 1.37 2003/05/22 16:01:02 gbazin Exp $ * * Authors: Christophe Massiot * @@ -24,15 +24,9 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include "defs.h" - #include /* memcpy(), memset() */ -#include /* off_t */ -#include "common.h" -#include "intf_msg.h" -#include "threads.h" -#include "mtime.h" +#include #include "stream_control.h" #include "input_ext-intf.h" @@ -83,8 +77,6 @@ /***************************************************************************** * ClockToSysdate: converts a movie clock to system date *****************************************************************************/ -static void ClockNewRef( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm, - mtime_t i_clock, mtime_t i_sysdate ); static mtime_t ClockToSysdate( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm, mtime_t i_clock ) { @@ -119,7 +111,7 @@ static mtime_t ClockCurrent( input_thread_t * p_input, /***************************************************************************** * ClockNewRef: writes a new clock reference *****************************************************************************/ -static void ClockNewRef( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm, +static void ClockNewRef( pgrm_descriptor_t * p_pgrm, mtime_t i_clock, mtime_t i_sysdate ) { p_pgrm->cr_ref = i_clock; @@ -160,25 +152,29 @@ int input_ClockManageControl( input_thread_t * p_input, if( p_input->stream.i_new_status == PAUSE_S ) { int i_old_status; + vlc_mutex_lock( &p_input->stream.control.control_lock ); i_old_status = p_input->stream.control.i_status; - p_input->stream.control.i_status = PAUSE_S; + vlc_mutex_unlock( &p_input->stream.control.control_lock ); + vlc_cond_wait( &p_input->stream.stream_wait, &p_input->stream.stream_lock ); p_pgrm->last_syscr = 0; - ClockNewRef( p_input, p_pgrm, i_clock, mdate() ); + ClockNewRef( p_pgrm, i_clock, mdate() ); if( p_input->stream.i_new_status == PAUSE_S ) - { + { /* PAUSE_S undoes the pause state: Return to old state. */ + vlc_mutex_lock( &p_input->stream.control.control_lock ); p_input->stream.control.i_status = i_old_status; + vlc_mutex_unlock( &p_input->stream.control.control_lock ); + p_input->stream.i_new_status = UNDEF_S; p_input->stream.i_new_rate = UNDEF_S; } /* We handle i_new_status != PAUSE_S below... */ - vlc_mutex_unlock( &p_input->stream.control.control_lock ); i_return_value = PAUSE_S; } @@ -189,7 +185,7 @@ int input_ClockManageControl( input_thread_t * p_input, p_input->stream.control.i_status = p_input->stream.i_new_status; - ClockNewRef( p_input, p_pgrm, i_clock, + ClockNewRef( p_pgrm, i_clock, ClockToSysdate( p_input, p_pgrm, i_clock ) ); if( p_input->stream.control.i_status == PLAYING_S ) @@ -224,10 +220,16 @@ int input_ClockManageControl( input_thread_t * p_input, void input_ClockManageRef( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm, mtime_t i_clock ) { + /* take selected program if none specified */ + if( !p_pgrm ) + { + p_pgrm = p_input->stream.p_selected_program; + } + if( ( p_pgrm->i_synchro_state != SYNCHRO_OK ) || ( i_clock == 0 ) ) { /* Feed synchro with a new reference point. */ - ClockNewRef( p_input, p_pgrm, i_clock, mdate() ); + ClockNewRef( p_pgrm, i_clock, mdate() ); p_pgrm->i_synchro_state = SYNCHRO_OK; if( p_input->stream.b_pace_control @@ -253,10 +255,10 @@ void input_ClockManageRef( input_thread_t * p_input, /* Stream discontinuity, for which we haven't received a * warning from the stream control facilities (dd-edited * stream ?). */ - intf_WarnMsg( 1, "Clock gap, unexpected stream discontinuity" ); + msg_Warn( p_input, "clock gap, unexpected stream discontinuity" ); input_ClockInit( p_pgrm ); p_pgrm->i_synchro_state = SYNCHRO_START; - input_EscapeDiscontinuity( p_input, p_pgrm ); + input_EscapeDiscontinuity( p_input ); } p_pgrm->last_cr = i_clock; @@ -308,11 +310,16 @@ void input_ClockManageRef( input_thread_t * p_input, mtime_t input_ClockGetTS( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm, mtime_t i_ts ) { + /* take selected program if none specified */ + if( !p_pgrm ) + { + p_pgrm = p_input->stream.p_selected_program; + } + if( p_pgrm->i_synchro_state == SYNCHRO_OK ) { return( ClockToSysdate( p_input, p_pgrm, i_ts + p_pgrm->delta_cr ) - + DEFAULT_PTS_DELAY - + (p_main->i_desync > 0 ? p_main->i_desync : 0) ); + + p_input->i_pts_delay ); } else {