From 4311de2be0d66132555388570c15d5de6c2a47f3 Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Wed, 27 Sep 2023 12:33:39 +0200 Subject: [PATCH] interaudiosink: Ensure adapters don't store buffers with audio meta The interaudiosrc might take buffers of different sizes from the audio adapter, so keeping metas consistency would be an issue. So the sink now strips the audio metas away and the src adds them back (for non-interleaved layouts only) when taking buffers from the adapter. Part-of: --- .../testsuites/validate.testslist | 1 + .../validate/inter/audio-planar.validatetest | 4 ++++ .../gst-plugins-bad/gst/inter/gstinteraudiosink.c | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 subprojects/gst-integration-testsuites/testsuites/validate/inter/audio-planar.validatetest diff --git a/subprojects/gst-integration-testsuites/testsuites/validate.testslist b/subprojects/gst-integration-testsuites/testsuites/validate.testslist index c5e5438..02f22cc 100644 --- a/subprojects/gst-integration-testsuites/testsuites/validate.testslist +++ b/subprojects/gst-integration-testsuites/testsuites/validate.testslist @@ -936,6 +936,7 @@ validate.test.h264.parse.trickmode_predicted.seek_trickmode_predicted validate.test.h264.x264enc_youtube_bitrate.fullhd_lowframerate validate.test.h265parse.alternate validate.test.h265parse.trickmode_predicted.seek_trickmode_predicted +validate.test.inter.audio-planar validate.test.interlace.interlace_deinterlace validate.test.interlace.interlace_deinterlace_alternate validate.test.matroska.demux_flush_within_cluster.default diff --git a/subprojects/gst-integration-testsuites/testsuites/validate/inter/audio-planar.validatetest b/subprojects/gst-integration-testsuites/testsuites/validate/inter/audio-planar.validatetest new file mode 100644 index 0000000..42e2c48 --- /dev/null +++ b/subprojects/gst-integration-testsuites/testsuites/validate/inter/audio-planar.validatetest @@ -0,0 +1,4 @@ +meta, + args = { + "audiotestsrc num-buffers=10 ! audio/x-raw,format=S16LE,channels=2,layout=non-interleaved ! interaudiosink interaudiosrc num-buffers=10 ! audioconvert ! audio/x-raw,layout=interleaved,format=S16LE,channels=2 ! queue ! fakeaudiosink", + } diff --git a/subprojects/gst-plugins-bad/gst/inter/gstinteraudiosink.c b/subprojects/gst-plugins-bad/gst/inter/gstinteraudiosink.c index a33fe81..6c654e8 100644 --- a/subprojects/gst-plugins-bad/gst/inter/gstinteraudiosink.c +++ b/subprojects/gst-plugins-bad/gst/inter/gstinteraudiosink.c @@ -293,6 +293,7 @@ gst_inter_audio_sink_render (GstBaseSink * sink, GstBuffer * buffer) guint n, bpf; guint64 period_time, buffer_time; guint64 period_samples, buffer_samples; + GstBuffer *tmp; GST_DEBUG_OBJECT (interaudiosink, "render %" G_GSIZE_FORMAT, gst_buffer_get_size (buffer)); @@ -330,16 +331,26 @@ gst_inter_audio_sink_render (GstBaseSink * sink, GstBuffer * buffer) n = gst_adapter_available (interaudiosink->input_adapter); if (period_samples * bpf > gst_buffer_get_size (buffer) + n) { - gst_adapter_push (interaudiosink->input_adapter, gst_buffer_ref (buffer)); + GstAudioMeta *audio_meta = NULL; + + tmp = gst_buffer_copy_deep (buffer); + audio_meta = gst_buffer_get_audio_meta (tmp); + if (audio_meta != NULL) + gst_buffer_remove_meta (tmp, GST_META_CAST (audio_meta)); + + gst_adapter_push (interaudiosink->input_adapter, tmp); } else { - GstBuffer *tmp; + GstAudioMeta *audio_meta = NULL; if (n > 0) { tmp = gst_adapter_take_buffer (interaudiosink->input_adapter, n); gst_adapter_push (interaudiosink->surface->audio_adapter, tmp); } - gst_adapter_push (interaudiosink->surface->audio_adapter, - gst_buffer_ref (buffer)); + tmp = gst_buffer_copy_deep (buffer); + audio_meta = gst_buffer_get_audio_meta (tmp); + if (audio_meta != NULL) + gst_buffer_remove_meta (tmp, GST_META_CAST (audio_meta)); + gst_adapter_push (interaudiosink->surface->audio_adapter, tmp); } g_mutex_unlock (&interaudiosink->surface->mutex); -- 2.7.4