From: Guillaume Desmottes Date: Tue, 6 Aug 2019 04:39:22 +0000 (+0530) Subject: latency: fix custom event leaks X-Git-Tag: 1.16.2~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a9bc30b51c697065fe509b3b7dbad4a46061ea07;p=platform%2Fupstream%2Fgstreamer.git latency: fix custom event leaks If the element before the sink needs $n buffers to produce one output buffer, we were reffing $n events and unreffing only one. Prevent this by using g_object_set_qdata_full() to handle the event unreffing so we're sure no ref will be lost. --- diff --git a/plugins/tracers/gstlatency.c b/plugins/tracers/gstlatency.c index c3e8f746f3..0f6d5176de 100644 --- a/plugins/tracers/gstlatency.c +++ b/plugins/tracers/gstlatency.c @@ -297,10 +297,9 @@ calculate_latency (GstElement * parent, GstPad * pad, guint64 ts) GST_DEBUG ("%s_%s: Should log full lantency now (event %p)", GST_DEBUG_PAD_NAME (pad), ev); if (ev) { - g_object_set_qdata ((GObject *) pad, latency_probe_id, NULL); log_latency (gst_event_get_structure (ev), peer_parent, GST_PAD_PEER (pad), ts); - gst_event_unref (ev); + g_object_set_qdata ((GObject *) pad, latency_probe_id, NULL); } } @@ -308,9 +307,8 @@ calculate_latency (GstElement * parent, GstPad * pad, guint64 ts) GST_DEBUG ("%s_%s: Should log sub lantency now (event %p)", GST_DEBUG_PAD_NAME (pad), ev); if (ev) { - g_object_set_qdata ((GObject *) pad, sub_latency_probe_id, NULL); log_element_latency (gst_event_get_structure (ev), parent, pad, ts); - gst_event_unref (ev); + g_object_set_qdata ((GObject *) pad, sub_latency_probe_id, NULL); } } } @@ -412,8 +410,8 @@ do_push_event_pre (GstTracer * self, guint64 ts, GstPad * pad, GstEvent * ev) if (GST_OBJECT_FLAG_IS_SET (peer_parent, GST_ELEMENT_FLAG_SINK)) { /* store event so that we can calculate latency when the buffer that * follows has been processed */ - g_object_set_qdata ((GObject *) pad, latency_probe_id, - gst_event_ref (ev)); + g_object_set_qdata_full ((GObject *) pad, latency_probe_id, + gst_event_ref (ev), (GDestroyNotify) gst_event_unref); } } @@ -433,8 +431,8 @@ do_push_event_pre (GstTracer * self, guint64 ts, GstPad * pad, GstEvent * ev) !g_str_equal (value_pad_name, pad_name)) { GST_DEBUG ("%s_%s: Storing sub-latency event", GST_DEBUG_PAD_NAME (pad)); - g_object_set_qdata ((GObject *) pad, sub_latency_probe_id, - gst_event_ref (ev)); + g_object_set_qdata_full ((GObject *) pad, sub_latency_probe_id, + gst_event_ref (ev), (GDestroyNotify) gst_event_unref); } g_free (pad_name);