bool b_buffering;
struct
{
+ bool b_first;
bool b_full;
int i_count;
DecoderFlush( p_dec );
+ p_owner->buffer.b_first = true;
p_owner->buffer.b_full = false;
p_owner->buffer.i_count = 0;
p_owner->pause.i_date = 0;
p_owner->b_buffering = false;
+ p_owner->buffer.b_first = true;
p_owner->buffer.b_full = false;
p_owner->buffer.i_count = 0;
p_owner->buffer.p_picture = NULL;
while( !p_owner->b_flushing )
{
+ if( p_owner->b_paused && p_owner->b_buffering && !p_owner->buffer.b_full )
+ break;
+
if( !p_owner->b_paused && ( !p_owner->b_buffering || !p_owner->buffer.b_full ) )
break;
+
vlc_cond_wait( &p_owner->wait, &p_owner->lock );
}
if( !b_has_more )
break;
+
vlc_mutex_lock( &p_owner->lock );
+ if( !p_owner->buffer.p_audio )
+ {
+ vlc_mutex_unlock( &p_owner->lock );
+ break;
+ }
}
}
/* */
vlc_mutex_lock( &p_owner->lock );
- if( p_owner->b_buffering || p_owner->buffer.p_picture )
+ if( ( p_owner->b_buffering && !p_owner->buffer.b_first ) || p_owner->buffer.p_picture )
{
p_picture->p_next = NULL;
bool b_reject;
DecoderWaitUnblock( p_dec, &b_reject );
- if( p_owner->b_buffering )
+ if( p_owner->b_buffering && !p_owner->buffer.b_first )
{
vlc_mutex_unlock( &p_owner->lock );
return;
}
+ bool b_buffering_first = p_owner->b_buffering;
/* */
if( p_owner->buffer.p_picture )
int i_rate = INPUT_RATE_DEFAULT;
mtime_t i_delay;
- DecoderFixTs( p_dec, &p_picture->date, NULL, NULL,
- &i_rate, &i_delay, false );
+ if( b_buffering_first )
+ {
+ assert( p_owner->buffer.b_first );
+ assert( !p_owner->buffer.i_count );
+ msg_Dbg( p_dec, "Received first picture" );
+ p_owner->buffer.b_first = false;
+ p_picture->date = mdate();
+ p_picture->b_force = true;
+ i_delay = 0;
+ if( p_owner->p_clock )
+ i_rate = input_clock_GetRate( p_owner->p_clock );
+ }
+ else
+ {
+ DecoderFixTs( p_dec, &p_picture->date, NULL, NULL,
+ &i_rate, &i_delay, false );
+ }
vlc_mutex_unlock( &p_owner->lock );
*pi_played_sum += i_tmp_display;
*pi_lost_sum += i_tmp_lost;
- if( !b_has_more )
+ if( !b_has_more || b_buffering_first )
break;
+
vlc_mutex_lock( &p_owner->lock );
+ if( !p_owner->buffer.p_picture )
+ {
+ vlc_mutex_unlock( &p_owner->lock );
+ break;
+ }
}
}
if( !b_has_more )
break;
vlc_mutex_lock( &p_owner->lock );
+ if( !p_owner->buffer.p_subpic )
+ {
+ vlc_mutex_unlock( &p_owner->lock );
+ break;
+ }
}
}
p_sys->b_buffering = true;
}
-bool input_EsOutDecodersEmpty( es_out_t *out )
+bool input_EsOutDecodersIsEmpty( es_out_t *out )
{
es_out_sys_t *p_sys = out->p_sys;
int i;
return true;
}
+bool input_EsOutIsBuffering( es_out_t *out )
+{
+ return out->p_sys->b_buffering;
+}
+
/*****************************************************************************
*
*****************************************************************************/
if( i_ret )
return;
- if( i_stream_duration <= p_sys->p_input->i_pts_delay && !b_forced )
+ mtime_t i_preroll_duration = 0;
+ mtime_t i_preroll_end = 0;
+ for( int i = 0; i < p_sys->i_es; i++ )
+ {
+ es_out_id_t *p_es = p_sys->es[i];
+
+ if( p_es->p_dec && p_es->i_preroll_end > 0 )
+ i_preroll_end = __MAX( i_preroll_end, p_es->i_preroll_end );
+ }
+ if( i_preroll_end > 0 )
+ i_preroll_duration = __MAX( i_preroll_end - i_stream_start, 0 );
+
+ if( i_stream_duration <= p_sys->p_input->i_pts_delay + i_preroll_duration && !b_forced )
{
- msg_Dbg( p_sys->p_input, "Buffering %d%%", (int)(100 * i_stream_duration / p_sys->p_input->i_pts_delay) );
+ msg_Dbg( p_sys->p_input, "Buffering %d%%", (int)(100 * i_stream_duration / ( p_sys->p_input->i_pts_delay + i_preroll_duration )) );
return;
}
mtime_t i_current;
mtime_t i_deadline;
mtime_t i_wakeup;
+ bool b_paused;
/* Demux data */
b_force_update = false;
i_wakeup = 0;
- if( p_input->i_state != PAUSE_S )
+ b_paused = p_input->i_state == PAUSE_S &&
+ !input_EsOutIsBuffering( p_input->p->p_es_out );
+
+ if( !b_paused )
{
MainLoopDemux( p_input, &b_force_update, &i_start_mdate );
i_wakeup = input_EsOutGetWakeup( p_input->p->p_es_out );
/* */
do {
i_deadline = i_wakeup;
- if( p_input->i_state == PAUSE_S )
+ if( b_paused )
i_deadline = __MIN( i_intf_update, i_statistic_update );
/* Handle control */
/* We have finish to demux data but not to play them */
while( vlc_object_alive( p_input ) )
{
- if( input_EsOutDecodersEmpty( p_input->p->p_es_out ) )
+ if( input_EsOutDecodersIsEmpty( p_input->p->p_es_out ) )
break;
msg_Dbg( p_input, "waiting decoder fifos to empty" );