baseparse: Add missing gst_buffer_make_writable

When the subclass attempts to finish without an explicit `out_buffer`,
we take a buffer from our adapter. We need to make this buffer writable
before copying the metadata.

This led to data races such as in the following pipeline, which randomly
messed up the buffer PTS:

    gst-launch-1.0 -e audiotestsrc timestamp-offset=5555 num-buffers=100 \
      ! opusenc ! tee name=t ! queue ! opusparse ! fakesink silent=0 \
      t. ! queue ! opusparse ! fakesink silent=0 -v | grep '0000, dur'

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5720>
This commit is contained in:
Jan Alexander Steffens (heftig) 2023-11-27 12:29:08 +01:00 committed by Tim-Philipp Müller
parent 36f653fdc5
commit a2533d2556

View file

@ -2728,6 +2728,7 @@ gst_base_parse_finish_frame (GstBaseParse * parse, GstBaseParseFrame * frame,
GstBuffer *src, *dest;
frame->out_buffer = gst_adapter_take_buffer (parse->priv->adapter, size);
frame->out_buffer = gst_buffer_make_writable (frame->out_buffer);
dest = frame->out_buffer;
src = frame->buffer;
GST_BUFFER_PTS (dest) = GST_BUFFER_PTS (src);