After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 788006 - audiobasesink: Improve clock skew adjustments
audiobasesink: Improve clock skew adjustments
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: 1.15.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-09-21 17:42 UTC by GstBlub
Modified: 2018-06-06 20:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
audiobasesink: Fix clock skew corrections (2.08 KB, patch)
2017-09-21 17:42 UTC, GstBlub
none Details | Review
audiobasesink: Fix clock skew corrections (3.22 KB, patch)
2017-09-21 18:29 UTC, GstBlub
none Details | Review
audiobasesink: Fix clock skew corrections (3.22 KB, patch)
2017-09-21 18:34 UTC, GstBlub
none Details | Review
audiobasesink: Improve clock skew corrections. (3.90 KB, patch)
2017-11-01 16:26 UTC, GstBlub
committed Details | Review

Description GstBlub 2017-09-21 17:42:24 UTC
Created attachment 360208 [details] [review]
audiobasesink: Fix clock skew corrections

The external time should be moved only as much as needed
to get back to the ideal center point, so that the clock
is still allowed to drift both directions after the correction.
This fixes excessive back and forth corrections due to the
assumption of a linear drift.

This also allowed me to reduce the clock skew tolerance dramatically without introducing more corrections.

Bug #722259 may be to some extent also be caused by this bug.  The enhancement bug #769804 still makes sense in combination with this fix.
Comment 1 GstBlub 2017-09-21 18:29:54 UTC
Created attachment 360211 [details] [review]
audiobasesink: Fix clock skew corrections

Fix calculation of driftsamples as well.
Comment 2 GstBlub 2017-09-21 18:34:49 UTC
Created attachment 360213 [details] [review]
audiobasesink: Fix clock skew corrections

Fix calculation of driftsamples as well (second attempt).
Comment 3 Nicolas Dufresne (ndufresne) 2017-09-21 19:36:35 UTC
Review of attachment 360208 [details] [review]:

That looks promizing, as this is pretty tricky to test, any chance of implementing some unit test ?
Comment 4 GstBlub 2017-09-21 19:58:42 UTC
Unless there happen to be unit tests around this logic already, I don't think I have the time to do this.

All I can say is that I believe the current logic is flawed in that it assumes a linear drift, and because of that, once it exceeded the allowed drift in one direction, it corrected by the whole drift tolerance value "back", placing the new ideal center on the edge of the window on the other side.  If the clock then skewed some more, odds are it skewed outside of the window, triggering yet another correction.  This behavior required a skew tolerance to be set much higher than needed.

Depending on the alignment threshold property value, this may also avoid an alignment resync due to smaller corrections, which means most skew corrections may now be much more subtle.
Comment 5 Sebastian Dröge (slomo) 2017-10-31 17:00:39 UTC
Review of attachment 360213 [details] [review]:

Please fix the commit message :) You don't "fix" the skew correction, but you improve it so that it doesn't over-compensate.

Also please add some comments to the code to explain why you do those calculations there and what the result is (how do we correct, where do we end up?).


The idea makes sense in any case.
Comment 6 GstBlub 2017-11-01 16:26:50 UTC
Created attachment 362765 [details] [review]
audiobasesink: Improve clock skew corrections.
Comment 7 GstBlub 2017-11-01 16:38:13 UTC
We've been running with this for quite a while now and it's amazing how much fewer clock skews we see, actually they're almost entirely gone.
Comment 8 Nicolas Dufresne (ndufresne) 2018-06-06 20:15:32 UTC
Let's get this in while the development branch is young. I've went through
the code and haven't fond anything, and Sebastian comments has been addressed.

Attachment 362765 [details] pushed as 7d3c098 - audiobasesink: Improve clock skew corrections.