mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
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:
parent
9c084faa75
commit
3243c5fe94
1 changed files with 4 additions and 6 deletions
|
@ -1050,10 +1050,9 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
|
|||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
GstAudioVisualizer *scope;
|
||||
GstAudioVisualizerClass *klass;
|
||||
GstBuffer *inbuf;
|
||||
GstBuffer *inbuf, *databuf;
|
||||
guint64 dist, ts;
|
||||
guint avail, sbpf;
|
||||
gpointer adata;
|
||||
gint bpf, rate;
|
||||
|
||||
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;
|
||||
|
||||
/* 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;
|
||||
|
||||
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_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, adata, sbpf, 0,
|
||||
sbpf, NULL, NULL));
|
||||
gst_buffer_copy_into (inbuf, databuf, GST_BUFFER_COPY_MEMORY, 0, sbpf);
|
||||
gst_buffer_unref (databuf);
|
||||
|
||||
/* call class->render() vmethod */
|
||||
if (klass->render) {
|
||||
|
|
Loading…
Reference in a new issue