Skip to content

Commit 80f137f

Browse files
authored
[DLStreamer] latency_tracer fixes (open-edge-platform#957)
1 parent 2705d56 commit 80f137f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libraries/dl-streamer/src/gst/tracers/latency_tracer/latency_tracer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ static void do_push_buffer_pre(LatencyTracer *lt, guint64 ts, GstPad *pad, GstBu
324324
}
325325
if (lt->flags & LATENCY_TRACER_FLAG_ELEMENT) {
326326
ElementStats *stats = ElementStats::from_element(elem);
327-
if (stats != nullptr) {
327+
// log latency only if ts is greater than last logged ts to avoid duplicate logging for the same buffer
328+
if (stats != nullptr && ts > meta->last_pad_push_ts) {
328329
stats->cal_log_element_latency(ts, meta->last_pad_push_ts, lt->interval);
329330
meta->last_pad_push_ts = ts;
330331
}
@@ -372,7 +373,10 @@ static void on_element_change_state_post(LatencyTracer *lt, guint64 ts, GstEleme
372373
if (GST_OBJECT_FLAG_IS_SET(element, GST_ELEMENT_FLAG_SINK))
373374
lt->sink_element = element;
374375
else if (!GST_OBJECT_FLAG_IS_SET(element, GST_ELEMENT_FLAG_SOURCE)) {
375-
ElementStats::create(element, ts);
376+
// create ElementStats only once per each element
377+
if (!ElementStats::from_element(element)) {
378+
ElementStats::create(element, ts);
379+
}
376380
}
377381
}
378382
GstTracer *tracer = GST_TRACER(lt);

0 commit comments

Comments
 (0)