audioresample: Drain the resampler and reset timestamp tracking on caps changes
authorSebastian Dröge <sebastian@centricular.com>
Tue, 26 May 2020 19:45:41 +0000 (22:45 +0300)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 27 May 2020 17:06:08 +0000 (17:06 +0000)
commit6d423cbba26d22476675b481afa11c588792ebf7
tree6675f0e63a29f420902debd36ef7f3048972b3a5
parentc7a956aede13771848acc8cd097d40976dbfb9b8
audioresample: Drain the resampler and reset timestamp tracking on caps changes

Especially when changing the sample rate our timestamp tracking will be
completely off, but even otherwise we would usually lose the last few
samples if we don't drain here as the resampler gets reset if anything
but the sample rate changes.

This is usually not a problem as the first buffer after a caps event
usually has the discont flag set, but can cause problems if
 - the caps event is followed by a segment event, which then causes
   draining according to the new sample rate
 - the caps were changed because of rengotiation due to a reconfigure
   event and there is not discontinuity from upstream

In both cases we would output buffers with completely wrong timestamps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/670>
gst/audioresample/gstaudioresample.c