- msg_Dbg( out->p_sys->p_input, "input_EsOutFrameNext consummed %d ms", (int)(i_duration/1000) );
-
- if( i_duration <= 0 )
- i_duration = 40*1000;
-
- /* FIXME it is not a clean way ? */
- if( p_sys->i_buffering_extra_initial <= 0 )
- {
- mtime_t i_stream_start;
- mtime_t i_system_start;
- mtime_t i_stream_duration;
- mtime_t i_system_duration;
- int i_ret;
-
- i_ret = input_clock_GetState( p_sys->p_pgrm->p_clock,
- &i_stream_start, &i_system_start,
- &i_stream_duration, &i_system_duration );
- if( i_ret )
- return;
-
- p_sys->i_buffering_extra_initial = 1 + i_stream_duration - p_sys->p_input->i_pts_delay; /* FIXME < 0 ? */
- p_sys->i_buffering_extra_system =
- p_sys->i_buffering_extra_stream = p_sys->i_buffering_extra_initial;
- }
-
- const int i_rate = input_clock_GetRate( p_sys->p_pgrm->p_clock );
-
- p_sys->b_buffering = true;
- p_sys->i_buffering_extra_system += i_duration;
- p_sys->i_buffering_extra_stream = p_sys->i_buffering_extra_initial +
- ( p_sys->i_buffering_extra_system - p_sys->i_buffering_extra_initial ) *
- INPUT_RATE_DEFAULT / i_rate;
-
- p_sys->i_preroll_end = -1;
-}
-
-void input_EsOutLock( es_out_t *out )
-{
- vlc_mutex_lock( &out->p_sys->lock );
-}
-void input_EsOutUnlock( es_out_t *out )
-{
- vlc_mutex_unlock( &out->p_sys->lock );
-}
-
-/*****************************************************************************
- *
- *****************************************************************************/
-static void EsOutDelete( es_out_t *out )
-{
- es_out_sys_t *p_sys = out->p_sys;
- int i;
-
- if( p_sys->p_sout_record )
- input_EsOutSetRecord( out, false );
-
- for( i = 0; i < p_sys->i_es; i++ )
- {
- if( p_sys->es[i]->p_dec )
- input_DecoderDelete( p_sys->es[i]->p_dec );
-
- free( p_sys->es[i]->psz_language );
- free( p_sys->es[i]->psz_language_code );
- es_format_Clean( &p_sys->es[i]->fmt );
-
- free( p_sys->es[i] );
- }
- if( p_sys->ppsz_audio_language )
- {
- for( i = 0; p_sys->ppsz_audio_language[i]; i++ )
- free( p_sys->ppsz_audio_language[i] );
- free( p_sys->ppsz_audio_language );
- }
- if( p_sys->ppsz_sub_language )
- {
- for( i = 0; p_sys->ppsz_sub_language[i]; i++ )
- free( p_sys->ppsz_sub_language[i] );
- free( p_sys->ppsz_sub_language );
- }
- free( p_sys->es );
-
- /* FIXME duplicate work EsOutProgramDel (but we cannot use it) add a EsOutProgramClean ? */
- for( i = 0; i < p_sys->i_pgrm; i++ )
- {
- es_out_pgrm_t *p_pgrm = p_sys->pgrm[i];
- input_clock_Delete( p_pgrm->p_clock );
- free( p_pgrm->psz_now_playing );
- free( p_pgrm->psz_publisher );
- free( p_pgrm->psz_name );
- if( p_pgrm->p_epg )
- vlc_epg_Delete( p_pgrm->p_epg );
-
- free( p_pgrm );
- }
- TAB_CLEAN( p_sys->i_pgrm, p_sys->pgrm );
- vlc_mutex_destroy( &p_sys->lock );
-
- free( p_sys );
- free( out );
-}
-
-static mtime_t EsOutGetWakeup( es_out_t *out )
-{
- es_out_sys_t *p_sys = out->p_sys;
- input_thread_t *p_input = p_sys->p_input;
-
- if( !p_sys->p_pgrm )
- return 0;
-
- /* We do not have a wake up date if the input cannot have its speed
- * controlled or sout is imposing its own or while buffering
- *
- * FIXME for !p_input->b_can_pace_control a wkeup time is still needed to avoid too strong buffering */
- if( !p_input->b_can_pace_control ||
- p_input->p->b_out_pace_control ||
- p_sys->b_buffering )
- return 0;
-
- return input_clock_GetWakeup( p_sys->p_pgrm->p_clock );
-}
-
-static es_out_id_t *EsOutGetFromID( es_out_t *out, int i_id )
-{
- int i;
- if( i_id < 0 )
- {
- /* Special HACK, -i_id is the cat of the stream */
- return (es_out_id_t*)((uint8_t*)NULL-i_id);
- }
-
- for( i = 0; i < out->p_sys->i_es; i++ )
- {
- if( out->p_sys->es[i]->i_id == i_id )
- return out->p_sys->es[i];
- }
- return NULL;
-}