latency: Dot not override already stored events
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Tue, 19 Mar 2019 01:55:50 +0000 (21:55 -0400)
committerJulian Bouzas <julian.bouzas@collabora.com>
Mon, 8 Apr 2019 16:28:07 +0000 (12:28 -0400)
First, the event would be leaved, but also when an element takes
several buffers before producing one, we want the reported latency to be
the aggregation, so the distance from the oldest buffer.

plugins/tracers/gstlatency.c

index bb6aedf..3b774e9 100644 (file)
@@ -300,8 +300,9 @@ do_push_event_pre (GstTracer * self, guint64 ts, GstPad * pad, GstEvent * ev)
 
         /* 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));
+        if (!g_object_get_qdata ((GObject *) pad, latency_probe_id))
+          g_object_set_qdata ((GObject *) pad, latency_probe_id,
+              gst_event_ref (ev));
       }
     }
 
@@ -314,8 +315,9 @@ do_push_event_pre (GstTracer * self, guint64 ts, GstPad * pad, GstEvent * ev)
 
       if (!g_str_equal (g_value_get_string (value), pad_name)) {
         GST_DEBUG ("%s: Storing sub-latency event", pad_name);
-        g_object_set_qdata ((GObject *) pad, sub_latency_probe_id,
-            gst_event_ref (ev));
+        if (!g_object_get_qdata ((GObject *) pad, sub_latency_probe_id))
+          g_object_set_qdata ((GObject *) pad, sub_latency_probe_id,
+              gst_event_ref (ev));
       }
 
       g_free (pad_name);