Commit b0bcb74c authored by Laurent Aimar's avatar Laurent Aimar

Moved input_EsOutDecodersIsEmpty to es_out_Control and cleaned its usage.

parent 26a1e9d2
......@@ -471,30 +471,6 @@ void input_EsOutChangePosition( es_out_t *out )
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;
......@@ -666,6 +642,31 @@ static es_out_id_t *EsOutGetFromID( es_out_t *out, int i_id )
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;
......@@ -2310,6 +2311,11 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
*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;
......
......@@ -43,6 +43,9 @@ enum es_out_query_private_e
/* 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 )
......@@ -61,7 +64,14 @@ static inline bool es_out_GetBuffering( 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 );
......@@ -70,7 +80,6 @@ int input_EsOutSetRecord( es_out_t *, bool b_record );
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 * );
......
......@@ -729,7 +729,7 @@ static void MainLoop( input_thread_t *p_input )
/* 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;
......@@ -750,9 +750,21 @@ static void MainLoop( input_thread_t *p_input )
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;
}
}
/* */
......@@ -797,26 +809,8 @@ static void MainLoop( input_thread_t *p_input )
} 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 )
......@@ -1601,6 +1595,7 @@ static bool Control( input_thread_t *p_input, int i_type,
{
if( p_input->p->i_slave > 0 )
SlaveSeek( p_input );
p_input->p->input.b_eof = false;
b_force_update = true;
}
......@@ -1660,6 +1655,7 @@ static bool Control( input_thread_t *p_input, int i_type,
{
if( p_input->p->i_slave > 0 )
SlaveSeek( p_input );
p_input->p->input.b_eof = false;
b_force_update = true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment