From: Laurent Aimar Date: Sat, 6 Mar 2004 16:36:37 +0000 (+0000) Subject: * all: implemented sout asynch support. (ie sout will try to work at X-Git-Tag: 0.7.2~768 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=1d7b91d6a91f864ac7fb1155db540d83beb9bfe1;p=vlc * all: implemented sout asynch support. (ie sout will try to work at the maximum speed if the output can control the pace) --- diff --git a/src/input/input.c b/src/input/input.c index 9fa1a742dc..42ebbb3127 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -88,9 +88,9 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, char **ppsz_options, int i_options ) { - input_thread_t * p_input; /* thread descriptor */ - vlc_value_t val; - int i; + input_thread_t *p_input; /* thread descriptor */ + vlc_value_t val; + int i; /* Allocate descriptor */ p_input = vlc_object_create( p_parent, VLC_OBJECT_INPUT ); @@ -178,6 +178,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, char *psz_uri, /* Initialize thread properties */ p_input->b_eof = 0; + p_input->b_out_pace_control = VLC_FALSE; p_input->p_sys = NULL; /* Set target */ @@ -1022,6 +1023,20 @@ static int InitThread( input_thread_t * p_input ) p_sub_toselect->p_es, VLC_TRUE ); } + if( p_input->stream.p_sout ) + { + if( p_input->stream.p_sout->i_out_pace_nocontrol > 0 ) + { + p_input->b_out_pace_control = VLC_FALSE; + } + else + { + p_input->b_out_pace_control = VLC_TRUE; + } + msg_Dbg( p_input, "starting in %s mode", + p_input->b_out_pace_control ? "asynch" : "synch" ); + } + return VLC_SUCCESS; } diff --git a/src/input/input_clock.c b/src/input/input_clock.c index 182a00c864..4c249ddafd 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-2004 VideoLAN - * $Id: input_clock.c,v 1.45 2004/01/06 12:02:06 zorglub Exp $ + * $Id$ * * Authors: Christophe Massiot * @@ -248,7 +248,10 @@ void input_ClockManageRef( input_thread_t * p_input, && p_input->stream.p_selected_program == p_pgrm ) { p_pgrm->last_cr = i_clock; - mwait( ClockToSysdate( p_input, p_pgrm, i_clock ) ); + if( !p_input->b_out_pace_control ) + { + mwait( ClockToSysdate( p_input, p_pgrm, i_clock ) ); + } } else { @@ -280,7 +283,10 @@ void input_ClockManageRef( input_thread_t * p_input, /* Wait a while before delivering the packets to the decoder. * In case of multiple programs, we arbitrarily follow the * clock of the selected program. */ - mwait( ClockToSysdate( p_input, p_pgrm, i_clock ) ); + if( !p_input->b_out_pace_control ) + { + mwait( ClockToSysdate( p_input, p_pgrm, i_clock ) ); + } /* Now take into account interface changes. */ input_ClockManageControl( p_input, p_pgrm, i_clock ); diff --git a/src/input/input_dec.c b/src/input/input_dec.c index 4c80c32ec3..ed46ec9999 100644 --- a/src/input/input_dec.c +++ b/src/input/input_dec.c @@ -2,7 +2,7 @@ * input_dec.c: Functions for the management of decoders ***************************************************************************** * Copyright (C) 1999-2004 VideoLAN - * $Id: input_dec.c,v 1.94 2004/03/03 20:39:53 gbazin Exp $ + * $Id$ * * Authors: Christophe Massiot * Gildas Bazin @@ -61,6 +61,8 @@ struct decoder_owner_sys_t { vlc_bool_t b_own_thread; + input_thread_t *p_input; + aout_instance_t *p_aout; aout_input_t *p_aout_input; @@ -279,6 +281,15 @@ void input_DecodeBlock( decoder_t * p_dec, block_t *p_block ) if( p_dec->p_owner->b_own_thread ) { block_FifoPut( p_dec->p_owner->p_fifo, p_block ); + + if( p_dec->p_owner->p_input->b_out_pace_control ) + { + /* FIXME !!!!! */ + while( p_dec->p_owner->p_fifo->i_depth > 10 ) + { + msleep( 1000 ); + } + } } else { @@ -462,12 +473,15 @@ static decoder_t * CreateDecoder( input_thread_t * p_input, return NULL; } p_dec->p_owner->b_own_thread = VLC_TRUE; + p_dec->p_owner->p_input = p_input; p_dec->p_owner->p_aout = NULL; p_dec->p_owner->p_aout_input = NULL; p_dec->p_owner->p_vout = NULL; p_dec->p_owner->p_sout = p_input->stream.p_sout; p_dec->p_owner->p_sout_input = NULL; p_dec->p_owner->p_es_descriptor = p_es; + + /* decoder fifo */ if( ( p_dec->p_owner->p_fifo = block_FifoNew( p_dec ) ) == NULL ) { @@ -619,6 +633,20 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block ) p_sout_block = p_next; } + + /* For now it's enough, as only sout inpact on this flag */ + if( p_dec->p_owner->p_sout->i_out_pace_nocontrol > 0 && + p_dec->p_owner->p_input->b_out_pace_control ) + { + msg_Dbg( p_dec, "switching to synch mode" ); + p_dec->p_owner->p_input->b_out_pace_control = VLC_FALSE; + } + else if( p_dec->p_owner->p_sout->i_out_pace_nocontrol <= 0 && + !p_dec->p_owner->p_input->b_out_pace_control ) + { + msg_Dbg( p_dec, "switching to asynch mode" ); + p_dec->p_owner->p_input->b_out_pace_control = VLC_TRUE; + } } } else if( p_dec->fmt_in.i_cat == AUDIO_ES ) diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c index dd6f3db6dd..ec6127f789 100644 --- a/src/stream_output/stream_output.c +++ b/src/stream_output/stream_output.c @@ -2,7 +2,7 @@ * stream_output.c : stream output module ***************************************************************************** * Copyright (C) 2002-2004 VideoLAN - * $Id: stream_output.c,v 1.41 2004/03/03 20:39:53 gbazin Exp $ + * $Id$ * * Authors: Christophe Massiot * Laurent Aimar @@ -119,6 +119,7 @@ sout_instance_t * __sout_NewInstance ( vlc_object_t *p_parent, p_sout->psz_sout = strdup( psz_dest ); p_sout->i_preheader = 0; p_sout->i_padding = 0; + p_sout->i_out_pace_nocontrol = 0; p_sout->p_sys = NULL; vlc_mutex_init( p_sout, &p_sout->lock );