From e2d416b3fb740bdd505f2dc50b95c4a4aceb79e5 Mon Sep 17 00:00:00 2001 From: Bruno Date: Fri, 18 Jun 2021 00:21:09 +0200 Subject: [PATCH] Bugfix computation time with gaps --- Timeline.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Timeline.cpp b/Timeline.cpp index 3230482..af5ba22 100644 --- a/Timeline.cpp +++ b/Timeline.cpp @@ -258,11 +258,10 @@ bool Timeline::removeGaptAt(GstClockTime t) GstClockTime Timeline::sectionsDuration() const { - GstClockTime d = 0; - // compute the sum of durations of gaps - for (auto it = gaps_.begin(); it != gaps_.end(); ++it) - d += (*it).end - (*it).begin; + GstClockTime d = 0; + for (auto g = gaps_.begin(); g != gaps_.end(); ++g) + d+= g->duration(); // remove sum of gaps from actual duration return duration() - d; @@ -271,15 +270,13 @@ GstClockTime Timeline::sectionsDuration() const GstClockTime Timeline::sectionsTimeAt(GstClockTime t) const { - // target time - GstClockTime d = t; - // loop over gaps - for (auto it = gaps_.begin(); it != gaps_.end(); ++it) { + GstClockTime d = t; + for (auto g = gaps_.begin(); g != gaps_.end(); ++g) { // gap before target? - if ( (*it).end < d ) { + if ( g->begin < d ) { // increment target - d += (*it).end - (*it).begin; + d += g->duration(); } else // done