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 791269 - audiorate: reset offset and next_ts if caps is changed
audiorate: reset offset and next_ts if caps is changed
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other All
: Normal normal
: 1.15.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-12-05 14:24 UTC by Justin Kim
Modified: 2018-07-19 22:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
audiorate: reset offset and next_ts if caps is changed (1.12 KB, patch)
2017-12-05 14:24 UTC, Justin Kim
none Details | Review
audiorate: accumulate offset by time diff (9.41 KB, patch)
2018-01-09 09:34 UTC, Justin Kim
none Details | Review
audiorate: accumulate offset by time diff (8.88 KB, patch)
2018-01-09 09:38 UTC, Justin Kim
committed Details | Review

Description Justin Kim 2017-12-05 14:24:28 UTC
Created attachment 365028 [details] [review]
audiorate: reset offset and next_ts if caps is changed

When sink caps is changed, next_offset and next_ts should be
re-calculated based on audio information from the caps.
Otherwise, samples might be dropped if the rate is down.
Comment 1 Justin Kim 2017-12-28 04:32:34 UTC
any advice for the patch?
Comment 2 Mathieu Duponchelle 2017-12-28 10:02:36 UTC
As far as I can tell from looking at the chain method, setting these to -1 will cause audiorate to mark itself as discont, and potentially go through the if (skip_to_first) condition, that doesn't seem optimal, couldn't you rather recalculate next_offset and next_ts directly ?
Comment 3 Tim-Philipp Müller 2017-12-28 10:20:31 UTC
A small unit test would be great as well if you're up for it :)
Comment 4 Justin Kim 2018-01-09 09:34:47 UTC
Created attachment 366533 [details] [review]
audiorate: accumulate offset by time diff

    audiorate: accumulate offset by time diff

    The fomula, 'offset = time / rate', is correct only if
    the rate is never changed. When the rate is changed,
    the offset should be re-calculated based on the previous
    offset.
Comment 5 Justin Kim 2018-01-09 09:38:07 UTC
Created attachment 366534 [details] [review]
audiorate: accumulate offset by time diff
Comment 6 Olivier Crête 2018-07-16 22:04:21 UTC
Review of attachment 366534 [details] [review]:

I've noticed that this probably won't work with segment->rate < 0, but I think this use-case is already broken with the current code and I think I should write some unit tests for this.
Comment 7 Olivier Crête 2018-07-19 22:33:47 UTC
audiorate is already broken for reverse playback, I tried to fix it, but got bored, so I merged hit more or less as-is.

commit 4fa850e3e6c039000fc7f648de238af6c2278469 (HEAD -> master, upstream/master)
Author: Justin Kim <justin.kim@collabora.com>
Date:   Fri Jan 5 16:07:54 2018 +0900

    audiorate: accumulate offset by time diff
    
    The fomula, 'offset = time / rate', is correct only if
    the rate is never changed. When the rate is changed,
    the offset should be re-calculated based on the previous
    offset.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=791269