audiobuffersplit: Unset DISCONT flag if not discontinuous

And also set/unset the RESYNC flag accordingly.

It can happen that the flag is preserved by GstAdapter from the input
buffer. For example if a big input buffer is split into many small ones,
each of the small ones would have the flag set.

All other buffer flags seem safe to keep here if they were set,
including the GAP flag.

Also ensure that the buffer is actually writable before changing any
flags or metadata on it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1298>
This commit is contained in:
Sebastian Dröge 2020-05-25 15:36:38 +03:00 committed by GStreamer Merge Bot
parent 3efc8f5de9
commit bd67ef18e9

View file

@ -379,10 +379,15 @@ gst_audio_buffer_split_output (GstAudioBufferSplit * self, gboolean force,
size = MIN (size, avail);
buffer = gst_adapter_take_buffer (self->adapter, size);
buffer = gst_buffer_make_writable (buffer);
/* After a reset we have to set the discont flag */
if (self->current_offset == 0)
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
GST_BUFFER_FLAG_SET (buffer,
GST_BUFFER_FLAG_DISCONT | GST_BUFFER_FLAG_RESYNC);
else
GST_BUFFER_FLAG_UNSET (buffer,
GST_BUFFER_FLAG_DISCONT | GST_BUFFER_FLAG_RESYNC);
resync_time_diff =
gst_util_uint64_scale (self->current_offset, GST_SECOND, rate);