From c47c115dd11e1b91b7ccb54edc55affca7d3983e Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sat, 7 Sep 2013 12:59:17 -0400 Subject: [PATCH] timeline: Avoid setting duration > max_duration when rippling We should use the trimming method to set duration to make sure to avoid going over the max duration. Also avoid computing when setting duration to the same old value. --- ges/ges-timeline.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c index 9f649c9..b559765 100644 --- a/ges/ges-timeline.c +++ b/ges/ges-timeline.c @@ -1434,6 +1434,12 @@ ges_timeline_trim_object_simple (GESTimeline * timeline, duration = MAX (0, real_dur); duration = MIN (duration, max_duration - _INPOINT (track_element)); + /* Not moving, avoid overhead */ + if (duration == _DURATION (track_element)) { + GST_DEBUG_OBJECT (track_element, "No change in duration"); + return FALSE; + } + _set_duration0 (GES_TIMELINE_ELEMENT (track_element), duration); break; } @@ -1502,7 +1508,11 @@ timeline_ripple_object (GESTimeline * timeline, GESTrackElement * obj, duration = _DURATION (obj); - _set_duration0 (GES_TIMELINE_ELEMENT (obj), position - _START (obj)); + if (!ges_timeline_trim_object_simple (timeline, + GES_TIMELINE_ELEMENT (obj), NULL, GES_EDGE_END, position, + FALSE)) { + return FALSE; + } offset = _DURATION (obj) - duration; for (tmp = mv_ctx->moving_trackelements; tmp; tmp = tmp->next) { @@ -1655,6 +1665,11 @@ timeline_roll_object (GESTimeline * timeline, GESTrackElement * obj, ret &= ges_timeline_trim_object_simple (timeline, GES_TIMELINE_ELEMENT (obj), NULL, GES_EDGE_END, position, FALSE); + if (ret == FALSE) { + GST_DEBUG_OBJECT (timeline, "No triming, bailing out"); + goto done; + } + /* In the case we reached max_duration we just make sure to roll * everything to the real new position */ position = _START (obj) + _DURATION (obj); -- 2.7.4