[vlc-devel] commit: Auto detect when we need to buffer again. (Laurent Aimar )
git version control
git at videolan.org
Mon Jul 13 21:16:48 CEST 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Mon Jul 13 02:15:02 2009 +0200| [a48799e7a8702975e873e31a37be606267d7c674] | committer: Laurent Aimar
Auto detect when we need to buffer again.
As it is part of a critical section for playback, becareful about any
regressions.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a48799e7a8702975e873e31a37be606267d7c674
---
src/input/clock.c | 10 ++++++++--
src/input/clock.h | 2 ++
src/input/es_out.c | 25 ++++++++++++++++++++-----
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/src/input/clock.c b/src/input/clock.c
index 0b24c29..9cad368 100644
--- a/src/input/clock.c
+++ b/src/input/clock.c
@@ -197,8 +197,9 @@ void input_clock_Delete( input_clock_t *cl )
* i_ck_stream: date in stream clock
* i_ck_system: date in system clock
*****************************************************************************/
-void input_clock_Update( input_clock_t *cl,
- vlc_object_t *p_log, bool b_can_pace_control,
+void input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
+ bool *pb_late,
+ bool b_can_pace_control,
mtime_t i_ck_stream, mtime_t i_ck_system )
{
bool b_reset_reference = false;
@@ -247,6 +248,11 @@ void input_clock_Update( input_clock_t *cl,
}
cl->last = clock_point_Create( i_ck_stream, i_ck_system );
+ /* It does not take the decoder latency into account but it is not really
+ * the goal of the clock here */
+ const mtime_t i_system_expected = ClockStreamToSystem( cl, i_ck_stream + AvgGet( &cl->drift ) );
+ *pb_late = i_system_expected < i_ck_system - cl->i_pts_delay;
+
vlc_mutex_unlock( &cl->lock );
}
diff --git a/src/input/clock.h b/src/input/clock.h
index 1384793..b5f97b9 100644
--- a/src/input/clock.h
+++ b/src/input/clock.h
@@ -52,8 +52,10 @@ void input_clock_Delete( input_clock_t * );
/**
* This function will update a input_clock_t with a new clock reference point.
+ * It will also tell if the clock point is late regarding our buffering.
*/
void input_clock_Update( input_clock_t *, vlc_object_t *p_log,
+ bool *pb_late,
bool b_can_pace_control, mtime_t i_clock, mtime_t i_system );
/**
* This function will reset the drift of a input_clock_t.
diff --git a/src/input/es_out.c b/src/input/es_out.c
index d2d827d..1f1d50a 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -2212,6 +2212,7 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
int i_group = 0;
int64_t i_pcr;
+ /* Search program */
if( i_query == ES_OUT_SET_PCR )
{
p_pgrm = p_sys->p_pgrm;
@@ -2233,14 +2234,28 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
return VLC_EGENERIC;
}
- /* search program
- * TODO do not use mdate() but proper stream acquisition date */
+ /* TODO do not use mdate() but proper stream acquisition date */
+ bool b_late;
input_clock_Update( p_pgrm->p_clock, VLC_OBJECT(p_sys->p_input),
+ &b_late,
p_sys->p_input->p->b_can_pace_control || p_sys->b_buffering, i_pcr, mdate() );
- /* Check buffering state on master clock update */
- if( p_sys->b_buffering && p_pgrm == p_sys->p_pgrm )
- EsOutDecodersStopBuffering( out, false );
+ if( p_pgrm == p_sys->p_pgrm )
+ {
+ if( p_sys->b_buffering )
+ {
+ /* Check buffering state on master clock update */
+ EsOutDecodersStopBuffering( out, false );
+ }
+ else if( b_late )
+ {
+ /* Force a rebufferization when we are too late */
+ msg_Err( p_sys->p_input, "ES_OUT_SET_(GROUP_)PCR is called too late" );
+ /* It is not really good, as we throw away already buffered data
+ * TODO have a mean to correctly reenter bufferization */
+ EsOutChangePosition( out );
+ }
+ }
return VLC_SUCCESS;
}
More information about the vlc-devel
mailing list