p_sys->i_preroll_end = -1;
}
-bool input_EsOutDecodersIsEmpty( es_out_t *out )
-{
- es_out_sys_t *p_sys = out->p_sys;
- int i;
-
- if( p_sys->b_buffering && p_sys->p_pgrm )
- {
- EsOutDecodersStopBuffering( out, true );
- if( p_sys->b_buffering )
- return true;
- }
-
- for( i = 0; i < p_sys->i_es; i++ )
- {
- es_out_id_t *es = p_sys->es[i];
-
- if( es->p_dec && !input_DecoderIsEmpty( es->p_dec ) )
- return false;
- if( es->p_dec_record && !input_DecoderIsEmpty( es->p_dec_record ) )
- return false;
- }
- return true;
-}
-
void input_EsOutFrameNext( es_out_t *out )
{
es_out_sys_t *p_sys = out->p_sys;
return NULL;
}
+static bool EsOutDecodersIsEmpty( es_out_t *out )
+{
+ es_out_sys_t *p_sys = out->p_sys;
+ int i;
+
+ if( p_sys->b_buffering && p_sys->p_pgrm )
+ {
+ EsOutDecodersStopBuffering( out, true );
+ if( p_sys->b_buffering )
+ return true;
+ }
+
+ for( i = 0; i < p_sys->i_es; i++ )
+ {
+ es_out_id_t *es = p_sys->es[i];
+
+ if( es->p_dec && !input_DecoderIsEmpty( es->p_dec ) )
+ return false;
+ if( es->p_dec_record && !input_DecoderIsEmpty( es->p_dec_record ) )
+ return false;
+ }
+ return true;
+}
+
+
static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced )
{
es_out_sys_t *p_sys = out->p_sys;
*pb = p_sys->b_buffering;
return VLC_SUCCESS;
+ case ES_OUT_GET_EMPTY:
+ pb = (bool *)va_arg( args, bool* );
+ *pb = EsOutDecodersIsEmpty( out );
+ return VLC_SUCCESS;
+
default:
msg_Err( p_sys->p_input, "unknown query in es_out_Control" );
return VLC_EGENERIC;
/* Get buffering state */
ES_OUT_GET_BUFFERING, /* arg1=bool* res=cannot fail */
+
+ /* Check if es_out has still data to play */
+ ES_OUT_GET_EMPTY, /* arg1=bool* res=cannot fail */
};
static inline mtime_t es_out_GetWakeup( es_out_t *p_out )
assert( !i_ret );
return b;
}
+static inline bool es_out_GetEmpty( es_out_t *p_out )
+{
+ bool b;
+ int i_ret = es_out_Control( p_out, ES_OUT_GET_EMPTY, &b );
+ assert( !i_ret );
+ return b;
+}
es_out_t *input_EsOutNew( input_thread_t *, int i_rate );
void input_EsOutChangeRate( es_out_t *, int );
void input_EsOutChangePause( es_out_t *, bool b_paused, mtime_t i_date );
void input_EsOutChangePosition( es_out_t * );
-bool input_EsOutDecodersIsEmpty( es_out_t * );
void input_EsOutFrameNext( es_out_t * );
void input_EsOutLock( es_out_t * );
/* Start the timer */
stats_TimerStop( p_input, STATS_TIMER_INPUT_LAUNCHING );
- while( !p_input->b_die && !p_input->b_error && !p_input->p->input.b_eof )
+ while( vlc_object_alive( p_input ) && !p_input->b_error )
{
bool b_force_update;
int i_type;
if( !b_paused )
{
- MainLoopDemux( p_input, &b_force_update, &i_start_mdate );
+ if( !p_input->p->input.b_eof )
+ {
+ MainLoopDemux( p_input, &b_force_update, &i_start_mdate );
- i_wakeup = es_out_GetWakeup( p_input->p->p_es_out );
+ i_wakeup = es_out_GetWakeup( p_input->p->p_es_out );
+ }
+ else if( !p_input->b_eof && !es_out_GetEmpty( p_input->p->p_es_out ) )
+ {
+ msg_Dbg( p_input, "waiting decoder fifos to empty" );
+ i_wakeup = mdate() + INPUT_IDLE_SLEEP;
+ }
+ else
+ {
+ break;
+ }
}
/* */
} while( i_current < i_wakeup );
}
- if( !p_input->b_eof && !p_input->b_error && p_input->p->input.b_eof )
- {
- /* We have finish to demux data but not to play them */
- while( vlc_object_alive( p_input ) )
- {
- input_EsOutLock( p_input->p->p_es_out );
- bool b_empty = input_EsOutDecodersIsEmpty( p_input->p->p_es_out );
- input_EsOutUnlock( p_input->p->p_es_out );
-
- if( b_empty )
- break;
-
- msg_Dbg( p_input, "waiting decoder fifos to empty" );
-
- msleep( INPUT_IDLE_SLEEP );
- }
-
- /* We have finished */
+ if( !p_input->b_error )
input_ChangeState( p_input, END_S );
- }
}
static void InitStatistics( input_thread_t * p_input )
{
if( p_input->p->i_slave > 0 )
SlaveSeek( p_input );
+ p_input->p->input.b_eof = false;
b_force_update = true;
}
{
if( p_input->p->i_slave > 0 )
SlaveSeek( p_input );
+ p_input->p->input.b_eof = false;
b_force_update = true;
}