Commit d30180d8 authored by Laurent Aimar's avatar Laurent Aimar

Hide es out timeshift delay from time display.

parent 7f2f2b4d
......@@ -2246,9 +2246,14 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
}
case ES_OUT_GET_BUFFERING:
pb = (bool *)va_arg( args, bool* );
{
#warning "TODO ES_OUT_GET_BUFFERING"
bool *pb = (bool *)va_arg( args, bool* );
mtime_t *pi_delay = (mtime_t*)va_arg( args, mtime_t* );
*pb = p_sys->b_buffering;
*pi_delay = 0;
return VLC_SUCCESS;
}
case ES_OUT_GET_EMPTY:
pb = (bool *)va_arg( args, bool* );
......
......@@ -49,7 +49,7 @@ enum es_out_query_private_e
ES_OUT_SET_ES_DEFAULT_BY_ID,
/* Get buffering state */
ES_OUT_GET_BUFFERING, /* arg1=bool* res=cannot fail */
ES_OUT_GET_BUFFERING, /* arg1=bool*, arg2=mtime_t* res=cannot fail */
/* Check if es_out has still data to play */
ES_OUT_GET_EMPTY, /* arg1=bool* res=cannot fail */
......@@ -81,12 +81,15 @@ static inline mtime_t es_out_GetWakeup( es_out_t *p_out )
assert( !i_ret );
return i_wu;
}
static inline bool es_out_GetBuffering( es_out_t *p_out )
static inline bool es_out_GetBuffering( es_out_t *p_out, mtime_t *pi_delay )
{
bool b;
int i_ret = es_out_Control( p_out, ES_OUT_GET_BUFFERING, &b );
mtime_t i_delay;
int i_ret = es_out_Control( p_out, ES_OUT_GET_BUFFERING, &b, &i_delay );
assert( !i_ret );
if( pi_delay )
*pi_delay = i_delay;
return b;
}
static inline bool es_out_GetEmpty( es_out_t *p_out )
......
......@@ -239,6 +239,7 @@ static bool TsHasCmd( ts_thread_t * );
static bool TsIsUnused( ts_thread_t * );
static int TsChangePause( ts_thread_t *, bool b_source_paused, bool b_paused, mtime_t i_date );
static int TsChangeRate( ts_thread_t *, int i_src_rate, int i_rate );
static mtime_t TsGetDelay( ts_thread_t * );
static void *TsRun( vlc_object_t * );
......@@ -460,14 +461,22 @@ static int ControlLockedGetWakeup( es_out_t *p_out, mtime_t *pi_wakeup )
return VLC_SUCCESS;
}
static int ControlLockedGetBuffering( es_out_t *p_out, bool *pb_buffering )
static int ControlLockedGetBuffering( es_out_t *p_out, bool *pb_buffering, mtime_t *pi_delay )
{
es_out_sys_t *p_sys = p_out->p_sys;
if( p_sys->b_delayed )
{
mtime_t i_delay;
es_out_GetBuffering( p_sys->p_out, &i_delay );
*pb_buffering = true;
*pi_delay = i_delay + TsGetDelay( p_sys->p_thread );
}
else
*pb_buffering = es_out_GetBuffering( p_sys->p_out );
{
*pb_buffering = es_out_GetBuffering( p_sys->p_out, pi_delay );
}
return VLC_SUCCESS;
}
......@@ -635,7 +644,8 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
case ES_OUT_GET_BUFFERING:
{
bool *pb_buffering = (bool *)va_arg( args, bool* );
return ControlLockedGetBuffering( p_out, pb_buffering );
mtime_t *pi_delay = (mtime_t*)va_arg( args, mtime_t* );
return ControlLockedGetBuffering( p_out, pb_buffering, pi_delay );
}
case ES_OUT_SET_PAUSE_STATE:
{
......@@ -901,6 +911,19 @@ static int TsChangeRate( ts_thread_t *p_ts, int i_src_rate, int i_rate )
return i_ret;
}
static mtime_t TsGetDelay( ts_thread_t *p_ts )
{
mtime_t i_delay;
vlc_mutex_lock( &p_ts->lock );
i_delay = p_ts->i_cmd_delay + p_ts->i_rate_delay + p_ts->i_buffering_delay;
if( p_ts->b_paused )
i_delay += mdate() - p_ts->i_pause_date;
vlc_mutex_unlock( &p_ts->lock );
return i_delay;
}
static void *TsRun( vlc_object_t *p_thread )
{
......@@ -920,7 +943,7 @@ static void *TsRun( vlc_object_t *p_thread )
for( ;; )
{
const int canc = vlc_savecancel();
b_buffering = es_out_GetBuffering( p_ts->p_out );
b_buffering = es_out_GetBuffering( p_ts->p_out, NULL );
if( ( !p_ts->b_paused || b_buffering ) && !TsPopCmdLocked( p_ts, &cmd, false ) )
{
......
......@@ -198,6 +198,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
p_input->p->input.b_rescale_ts = true;
p_input->p->input.b_eof = false;
p_input->p->input.i_cr_average = 0;
memset( &p_input->p->input_last_times, 0, sizeof(p_input->p->input_last_times) );
vlc_mutex_lock( &p_item->lock );
......@@ -645,6 +646,9 @@ static void MainLoopDemux( input_thread_t *p_input, bool *pb_changed, mtime_t *p
static void MainLoopInterface( input_thread_t *p_input )
{
input_event_times_t ev;
mtime_t i_es_out_delay;
es_out_GetBuffering( p_input->p->p_es_out, &i_es_out_delay );
ev.f_position = 0.0;
ev.i_time = 0;
......@@ -663,6 +667,29 @@ static void MainLoopInterface( input_thread_t *p_input )
DEMUX_GET_LENGTH, &ev.i_length ) )
ev.i_length = 0;
if( ev.i_time > 0 )
{
ev.i_time -= i_es_out_delay;
if( ev.i_time < 0 )
ev.i_time = 0;
}
if( ev.i_length > 0 )
{
ev.f_position -= (double)i_es_out_delay / ev.i_length;
}
if( p_input->i_state == PAUSE_S )
{
input_event_times_t old = p_input->p->input_last_times;
/* XXX We have a jitter because of PCR frequency/get time precision.
* Hides it */
if( llabs(ev.i_time - old.i_time) < CLOCK_FREQ )
ev.i_time = old.i_time;
}
p_input->p->input_last_times = ev;
input_SendEventTimes( p_input, &ev );
}
......@@ -712,7 +739,7 @@ static void MainLoop( input_thread_t *p_input )
* is paused -> this may cause problem with some of them
* The same problem can be seen when seeking while paused */
b_paused = p_input->i_state == PAUSE_S &&
!es_out_GetBuffering( p_input->p->p_es_out );
!es_out_GetBuffering( p_input->p->p_es_out, NULL );
if( !b_paused )
{
......
......@@ -33,6 +33,7 @@
#include <vlc_input.h>
#include <libvlc.h>
#include "input_interface.h"
#include "event.h"
/*****************************************************************************
* Private input fields
......@@ -118,7 +119,9 @@ struct input_thread_private_t
bool b_out_pace_control; /* idem ? */
/* Main input properties */
input_source_t input;
input_source_t input;
input_event_times_t input_last_times;
/* Slave demuxers (subs, and others) */
int i_slave;
input_source_t **slave;
......
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