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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5324>
This commit is contained in:
Philippe Normand 2023-09-27 12:33:39 +02:00 committed by GStreamer Marge Bot
parent 46dbe2a372
commit 886bd7e4e0
3 changed files with 20 additions and 4 deletions

View file

@ -936,6 +936,7 @@ validate.test.h264.parse.trickmode_predicted.seek_trickmode_predicted
validate.test.h264.x264enc_youtube_bitrate.fullhd_lowframerate validate.test.h264.x264enc_youtube_bitrate.fullhd_lowframerate
validate.test.h265parse.alternate validate.test.h265parse.alternate
validate.test.h265parse.trickmode_predicted.seek_trickmode_predicted validate.test.h265parse.trickmode_predicted.seek_trickmode_predicted
validate.test.inter.audio-planar
validate.test.interlace.interlace_deinterlace validate.test.interlace.interlace_deinterlace
validate.test.interlace.interlace_deinterlace_alternate validate.test.interlace.interlace_deinterlace_alternate
validate.test.matroska.demux_flush_within_cluster.default validate.test.matroska.demux_flush_within_cluster.default

View file

@ -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",
}

View file

@ -293,6 +293,7 @@ gst_inter_audio_sink_render (GstBaseSink * sink, GstBuffer * buffer)
guint n, bpf; guint n, bpf;
guint64 period_time, buffer_time; guint64 period_time, buffer_time;
guint64 period_samples, buffer_samples; guint64 period_samples, buffer_samples;
GstBuffer *tmp;
GST_DEBUG_OBJECT (interaudiosink, "render %" G_GSIZE_FORMAT, GST_DEBUG_OBJECT (interaudiosink, "render %" G_GSIZE_FORMAT,
gst_buffer_get_size (buffer)); 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); n = gst_adapter_available (interaudiosink->input_adapter);
if (period_samples * bpf > gst_buffer_get_size (buffer) + n) { 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 { } else {
GstBuffer *tmp; GstAudioMeta *audio_meta = NULL;
if (n > 0) { if (n > 0) {
tmp = gst_adapter_take_buffer (interaudiosink->input_adapter, n); tmp = gst_adapter_take_buffer (interaudiosink->input_adapter, n);
gst_adapter_push (interaudiosink->surface->audio_adapter, tmp); gst_adapter_push (interaudiosink->surface->audio_adapter, tmp);
} }
gst_adapter_push (interaudiosink->surface->audio_adapter, tmp = gst_buffer_copy_deep (buffer);
gst_buffer_ref (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); g_mutex_unlock (&interaudiosink->surface->mutex);