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 730586 - alsasrc: Clock does not take overruns into account
alsasrc: Clock does not take overruns into account
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
unspecified
Other Windows
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-05-22 15:30 UTC by Tom Deseyn
Modified: 2018-11-03 11:30 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tom Deseyn 2014-05-22 15:30:29 UTC
In a pipeline where gstalsasrc provides the pipeline clock, time spent in buffer overruns is missing.

In such a pipline, the pipeline clock is provided by gst_audio_base_src_get_time which does not increase during overruns. The buffer timestamps are set in gst_audio_base_src_create and do not take into account buffer overruns.

This causes problems in pipelines which have live sinks where this is detected as clock skew (https://bugzilla.gnome.org/show_bug.cgi?id=692953).

When working around this by setting provide-clock=false on alsasink this triggers alsasrc to add buffer timestamps. (http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=a049b102da7c1b68a31c49717a4b37b351ea4b34). In this case, overruns are visible in the buffer timestamps but the difference in clock (alsa vs pipeline) is not compensated.

So either buffer overruns are not visible (alsasrc provides clock) or buffer timestamps are not matched against the pipeline clock (alsasrc doesn't provide the clock).

Do do it properly the alsasrc should provide a clock which takes into account buffer overrun and use that clock to timestamp the buffers.
If the pipeline uses another (monotonic) clock, the alsa timestamps should be reconverted to that clock.

Some simple changes can be made:
Perhaps alsasrc should not provide a clock by default?
For most if not all audio cards, the current code works fine when the pipeline clock is the monotonic OS clock. This is because snd_pcm_status_get_htstamp equals the clock time. If the call to the first in gstalsasrc was replaced by a call to the latter, it will even work fine for all monotonic system clocks.
Comment 1 Sebastian Dröge (slomo) 2014-12-22 10:02:38 UTC
Or maybe once we detect an overrun in alsa, the clock should be adjusted accordingly? That seems to be the most direct fix for this.

Tom, can you provide a patch for that?
Comment 2 Tom Deseyn 2014-12-22 20:17:48 UTC
Sebastian, do you have some thoughts on where the overrun time should be tracked and where it should be added to the existing components (segments done + delay)? Probably we still want the clock to be implemented as thread-safe without locks?
Should the overrun time be stored in alsasrc as a 32-bit sample counter and be made accessible through the ringbuffer via a function, similar to how the delay is retrieved in gst_audio_base_src_get_time?
Comment 3 Sebastian Dröge (slomo) 2014-12-22 20:26:28 UTC
I think you should just make the clock advance properly, maybe this needs a new function for GstAudioClock. or maybe just reset the clock to the real current time if an overrun happens.
Comment 4 GStreamer system administrator 2018-11-03 11:30:03 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/120.