audiovisualizer: Don't wrap temporary memory in buffers

Avoids potentially ending up with the buffermemory pointing to already-freed or reused addresses.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6320>
This commit is contained in:
Piotr Brzeziński 2024-03-11 18:30:08 +01:00 committed by GStreamer Marge Bot
parent 9c084faa75
commit 3243c5fe94

View file

@ -1050,10 +1050,9 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
GstAudioVisualizer *scope; GstAudioVisualizer *scope;
GstAudioVisualizerClass *klass; GstAudioVisualizerClass *klass;
GstBuffer *inbuf; GstBuffer *inbuf, *databuf;
guint64 dist, ts; guint64 dist, ts;
guint avail, sbpf; guint avail, sbpf;
gpointer adata;
gint bpf, rate; gint bpf, rate;
scope = GST_AUDIO_VISUALIZER (parent); scope = GST_AUDIO_VISUALIZER (parent);
@ -1165,7 +1164,7 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
GST_BUFFER_DURATION (outbuf) = scope->priv->frame_duration; GST_BUFFER_DURATION (outbuf) = scope->priv->frame_duration;
/* this can fail as the data size we need could have changed */ /* this can fail as the data size we need could have changed */
if (!(adata = (gpointer) gst_adapter_map (scope->priv->adapter, sbpf))) if (!(databuf = gst_adapter_get_buffer (scope->priv->adapter, sbpf)))
break; break;
gst_video_frame_map (&outframe, &scope->vinfo, outbuf, gst_video_frame_map (&outframe, &scope->vinfo, outbuf,
@ -1182,9 +1181,8 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
} }
} }
gst_buffer_replace_all_memory (inbuf, gst_buffer_copy_into (inbuf, databuf, GST_BUFFER_COPY_MEMORY, 0, sbpf);
gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, adata, sbpf, 0, gst_buffer_unref (databuf);
sbpf, NULL, NULL));
/* call class->render() vmethod */ /* call class->render() vmethod */
if (klass->render) { if (klass->render) {