diff --git a/ges/ges-internal.h b/ges/ges-internal.h index e8a9c980e3..54dd87705c 100644 --- a/ges/ges-internal.h +++ b/ges/ges-internal.h @@ -100,6 +100,14 @@ gboolean timeline_remove_element (GESTimeline *timeline, GESTimelineElement *element); +G_GNUC_INTERNAL +void +timeline_fill_gaps (GESTimeline *timeline); + +G_GNUC_INTERNAL +void +track_resort_and_fill_gaps (GESTrack *track); + G_GNUC_INTERNAL void ges_asset_cache_init (void); diff --git a/ges/ges-project.c b/ges/ges-project.c index 9dcd770558..7556396eda 100644 --- a/ges/ges-project.c +++ b/ges/ges-project.c @@ -540,7 +540,12 @@ gboolean ges_project_set_loaded (GESProject * project, GESFormatter * formatter) { GST_INFO_OBJECT (project, "Emit project loaded"); - ges_timeline_commit (formatter->timeline); + if (GST_STATE (formatter->timeline) < GST_STATE_PAUSED) { + timeline_fill_gaps (formatter->timeline); + } else { + ges_timeline_commit (formatter->timeline); + } + g_signal_emit (project, _signals[LOADED_SIGNAL], 0, formatter->timeline); /* We are now done with that formatter */ diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c index 5c221a3872..c59d6d8c76 100644 --- a/ges/ges-timeline.c +++ b/ges/ges-timeline.c @@ -2474,6 +2474,16 @@ timeline_remove_element (GESTimeline * timeline, GESTimelineElement * element) return g_hash_table_remove (timeline->priv->all_elements, element->name); } +void +timeline_fill_gaps (GESTimeline * timeline) +{ + GList *tmp; + + for (tmp = timeline->tracks; tmp; tmp = tmp->next) { + track_resort_and_fill_gaps (tmp->data); + } +} + /**** API *****/ /** * ges_timeline_new: diff --git a/ges/ges-track.c b/ges/ges-track.c index eb24417f38..5897284dd0 100644 --- a/ges/ges-track.c +++ b/ges/ges-track.c @@ -237,8 +237,8 @@ update_gaps (GESTrack * track) g_list_free_full (gaps, (GDestroyNotify) free_gap); } -static inline void -resort_and_fill_gaps (GESTrack * track) +void +track_resort_and_fill_gaps (GESTrack * track) { g_sequence_sort (track->priv->trackelements_by_start, (GCompareDataFunc) element_start_compare, NULL); @@ -691,7 +691,7 @@ ges_track_set_timeline (GESTrack * track, GESTimeline * timeline) GST_DEBUG ("track:%p, timeline:%p", track, timeline); track->priv->timeline = timeline; - resort_and_fill_gaps (track); + track_resort_and_fill_gaps (track); } /** @@ -907,7 +907,7 @@ ges_track_remove_element (GESTrack * track, GESTrackElement * object) it = g_hash_table_lookup (priv->trackelements_iter, object); g_sequence_remove (it); - resort_and_fill_gaps (track); + track_resort_and_fill_gaps (track); if (remove_object_internal (track, object) == TRUE) { ges_timeline_element_set_timeline (GES_TIMELINE_ELEMENT (object), NULL); @@ -990,7 +990,7 @@ ges_track_commit (GESTrack * track) { g_return_val_if_fail (GES_IS_TRACK (track), FALSE); - resort_and_fill_gaps (track); + track_resort_and_fill_gaps (track); return nle_object_commit (NLE_OBJECT (track->priv->composition), TRUE); }