[vlc-devel] Re: Clock synchro problems - proposed solution
Marian Durkovic
md at bts.sk
Wed Nov 9 20:57:34 CET 2005
Hi Sigmund,
> The clock drift calculation smoothing algorithm is basically a running
> average with cr-average being by default 40. This means that even though
> the calculation is performed at every pcr at least 40 pcr periods are
> taken into account. Increasing cr-average will increase the period. The
> computation is indeed subject to rounding error, and I have a still
> uncommited patch that fixes this.
thanks for commiting the rounding-error fix. Indeed, with this fix, it's
enough to change the computation interval to 1 second, and my test streams
play all fine.
Please find the new - now much simpler version of my synchro patch in the
attachment.
With kind regards,
M.
-------------- next part --------------
Index: src/input/input_internal.h
===================================================================
--- src/input/input_internal.h (revision 13166)
+++ src/input/input_internal.h (working copy)
@@ -133,6 +133,7 @@
/* Synchronization information */
mtime_t delta_cr;
mtime_t cr_ref, sysdate_ref;
+ mtime_t last_sysdate;
mtime_t last_cr; /* reference to detect unexpected stream
* discontinuities */
mtime_t last_pts;
Index: src/input/clock.c
===================================================================
--- src/input/clock.c (revision 13166)
+++ src/input/clock.c (working copy)
@@ -133,6 +133,7 @@
cl->last_cr = 0;
cl->last_pts = 0;
+ cl->last_sysdate = 0;
cl->cr_ref = 0;
cl->sysdate_ref = 0;
cl->delta_cr = 0;
@@ -264,6 +265,7 @@
else
{
cl->last_cr = 0;
+ cl->last_sysdate = 0;
cl->delta_cr = 0;
cl->i_delta_cr_residue = 0;
}
@@ -308,7 +310,7 @@
input_ClockManageControl( p_input, cl, i_clock );
#endif
}
- else
+ else if ( mdate() - cl->last_sysdate > 1000000 )
{
/* Smooth clock reference variations. */
mtime_t i_extrapoled_clock = ClockCurrent( p_input, cl );
@@ -324,6 +326,7 @@
+ cl->i_delta_cr_residue )
% cl->i_cr_average;
cl->delta_cr = delta_cr;
+ cl->last_sysdate = mdate();
}
}
}
More information about the vlc-devel
mailing list