mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
libs: audio: Fix gst_audio_buffer_truncate meta handling
In the non-interleaved case, it made `buffer` writable but then changed the meta of the non-writable buffer. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1035>
This commit is contained in:
parent
319da90d4c
commit
297a5f09b1
1 changed files with 5 additions and 1 deletions
|
@ -290,6 +290,10 @@ gst_audio_buffer_truncate (GstBuffer * buffer, gint bpf, gsize trim,
|
|||
if (samples == orig_samples)
|
||||
return buffer;
|
||||
|
||||
GST_DEBUG ("Truncating %" G_GSIZE_FORMAT " to %" G_GSIZE_FORMAT
|
||||
" (trim start %" G_GSIZE_FORMAT ", end %" G_GSIZE_FORMAT ")",
|
||||
orig_samples, samples, trim, orig_samples - trim - samples);
|
||||
|
||||
if (!meta || meta->info.layout == GST_AUDIO_LAYOUT_INTERLEAVED) {
|
||||
/* interleaved */
|
||||
ret = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, trim * bpf,
|
||||
|
@ -301,7 +305,7 @@ gst_audio_buffer_truncate (GstBuffer * buffer, gint bpf, gsize trim,
|
|||
} else {
|
||||
/* non-interleaved */
|
||||
ret = gst_buffer_make_writable (buffer);
|
||||
meta = gst_buffer_get_audio_meta (buffer);
|
||||
meta = gst_buffer_get_audio_meta (ret);
|
||||
meta->samples = samples;
|
||||
for (i = 0; i < meta->info.channels; i++) {
|
||||
meta->offsets[i] += trim * bpf / meta->info.channels;
|
||||
|
|
Loading…
Reference in a new issue