audioaggregator: Resync on the next buffer when dropping a buffer on discont resyncing
authorSebastian Dröge <sebastian@centricular.com>
Fri, 9 Jul 2021 06:49:15 +0000 (09:49 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Mon, 12 Jul 2021 06:42:39 +0000 (09:42 +0300)
commit71e46bcf385656bc50ebb358656947aaa1ed1d7b
treea59a47182135247bc1c2c545bfe179fee4a1558e
parente8b4164a1f181e113fc2ead73c2cdce2b98886e5
audioaggregator: Resync on the next buffer when dropping a buffer on discont resyncing

If a buffer is dropped during resyncing on a discont because either its
end offset is already before the current output offset of the
aggregator or because it fully overlaps with the part of the current
output buffer that was already filled, then don't just assume that the
next buffer is going to start at exactly the expected offset. It might
still require some more dropping of samples.

This caused the input to be mixed with an offset to its actual position
in the output stream, causing additional latency and wrong
synchronization between the different input streams.

Instead consider each buffer after a discont as a discont until the
aggregator actually resynced and starts mixing samples from the input
again.

Also update the start output offset of a new input buffer if samples
have to be dropped at the beginning. Otherwise it might be mixed too
early into the output and overwrite part of the output buffer that
already took samples from this input into account.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/912
which is a regression introduced by https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1180/

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1224>
gst-libs/gst/audio/gstaudioaggregator.c
tests/check/elements/audiomixer.c