ges: Avoid to always commit when a project is loaded

In case we are not in a PLAYING state and the project is loaded, the
only thing that should be done is to fill the gaps and this way when the
composition get to PLAYING, their initialization will be enough to get
everything on track.
This commit is contained in:
Thibault Saunier 2014-09-19 17:12:18 +02:00
parent 57eef236b5
commit 0d54d796de
4 changed files with 29 additions and 6 deletions

View file

@ -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);

View file

@ -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 */

View file

@ -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:

View file

@ -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);
}