track: Update gaps only when commiting

We were still updating them at useless moments, do it only when absolutely needed.
This commit is contained in:
Thibault Saunier 2013-06-25 18:36:24 -04:00 committed by Mathieu Duponchelle
parent 4020ca54ff
commit dd7085d2ed
3 changed files with 13 additions and 25 deletions

View file

@ -237,23 +237,12 @@ resort_and_fill_gaps (GESTrack * track)
}
/* callbacks */
static void
timeline_duration_changed_cb (GESTimeline * timeline,
GParamSpec * arg, GESTrack * track)
{
GESTrackPrivate *priv = track->priv;
/* Remove the last gap on the timeline if not needed anymore */
if (priv->updating == TRUE) {
resort_and_fill_gaps (track);
}
}
static void
sort_track_elements_cb (GESTrackElement * child,
GParamSpec * arg G_GNUC_UNUSED, GESTrack * track)
{
resort_and_fill_gaps (track);
g_sequence_sort (track->priv->trackelements_by_start,
(GCompareDataFunc) element_start_compare, NULL);
}
static void
@ -643,14 +632,6 @@ ges_track_set_timeline (GESTrack * track, GESTimeline * timeline)
{
GST_DEBUG ("track:%p, timeline:%p", track, timeline);
if (track->priv->timeline)
g_signal_handlers_disconnect_by_func (track->priv->timeline,
timeline_duration_changed_cb, track);
if (timeline)
g_signal_connect (timeline, "notify::duration",
G_CALLBACK (timeline_duration_changed_cb), track);
track->priv->timeline = timeline;
resort_and_fill_gaps (track);
}
@ -742,8 +723,6 @@ ges_track_add_element (GESTrack * track, GESTrackElement * object)
g_signal_connect (GES_TRACK_ELEMENT (object), "notify::priority",
G_CALLBACK (sort_track_elements_cb), track);
resort_and_fill_gaps (track);
return TRUE;
}
@ -863,6 +842,7 @@ ges_track_commit (GESTrack * track)
g_return_val_if_fail (GES_IS_TRACK (track), FALSE);
resort_and_fill_gaps (track);
g_signal_emit_by_name (track->priv->composition, "commit", TRUE, &ret);
return ret;

View file

@ -305,6 +305,7 @@ GST_START_TEST (test_gap_filling_basic)
assert_equals_uint64 (_DURATION (clip1), 5);
ges_layer_add_clip (layer, GES_CLIP (clip1));
ges_timeline_commit (timeline);
assert_equals_int (g_list_length (GES_CONTAINER_CHILDREN (clip1)), 1);
trackelement1 = GES_CONTAINER_CHILDREN (clip1)->data;
fail_unless (trackelement1 != NULL);
@ -329,13 +330,13 @@ GST_START_TEST (test_gap_filling_basic)
}
}
fail_unless (gap != NULL);
fail_unless (ges_timeline_commit (timeline));
gap_object_check (gap, 5, 10, 1);
clip2 = GES_CLIP (ges_test_clip_new ());
fail_unless (clip2 != NULL);
g_object_set (clip2, "start", (guint64) 35, "duration", (guint64) 5, NULL);
ges_layer_add_clip (layer, GES_CLIP (clip2));
fail_unless (ges_timeline_commit (timeline));
assert_equals_int (g_list_length (GES_CONTAINER_CHILDREN (clip2)), 1);
trackelement2 = GES_CONTAINER_CHILDREN (clip2)->data;
fail_unless (trackelement2 != NULL);
@ -374,6 +375,7 @@ GST_START_TEST (test_gap_filling_empty_track)
/* Set some properties */
asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
clip = ges_layer_add_asset (layer, asset, 0, 0, 10, GES_TRACK_TYPE_VIDEO);
ges_timeline_commit (timeline);
assert_equals_int (g_list_length (GES_CONTAINER_CHILDREN (clip)), 1);
/* We should not have created any TrackElement in the audio track */
@ -386,8 +388,8 @@ GST_START_TEST (test_gap_filling_empty_track)
gap = GST_BIN_CHILDREN (composition)->data;
fail_unless (gap != NULL);
fail_unless (ges_timeline_commit (timeline));
gap_object_check (gap, 0, 10, 1);
fail_unless (ges_timeline_commit (timeline));
gst_object_unref (timeline);
}

View file

@ -396,6 +396,7 @@ GST_START_TEST (test_single_layer_automatic_transition)
assert_equals_uint64 (_DURATION (src), 1000);
assert_equals_uint64 (_START (src1), 500);
assert_equals_uint64 (_DURATION (src1), 1500 - 500);
ges_timeline_commit (timeline);
GST_DEBUG ("Checking that a transition has been added");
objects = ges_layer_get_clips (layer);
@ -574,6 +575,7 @@ GST_START_TEST (test_single_layer_automatic_transition)
GST_DEBUG
("Changig first source duration to 800 2 transitions should be created");
ges_timeline_element_set_duration (src, 800);
ges_timeline_commit (timeline);
/* 600__________________src_____________1400
* 500___________src1________1250
* 1250___________src2________2250
@ -649,6 +651,7 @@ GST_START_TEST (test_single_layer_automatic_transition)
GST_DEBUG
("Set third clip start to 1100, 1 new transition should be created");
ges_timeline_element_set_start (src2, 1100);
ges_timeline_commit (timeline);
/* 600____src___1100
* 500___________src1________1250
* 1100___________src2________2100
@ -688,6 +691,7 @@ GST_START_TEST (test_single_layer_automatic_transition)
GST_DEBUG ("Set third clip start to 1000, Transition should be updated");
ges_clip_edit (GES_CLIP (src2), NULL, -1,
GES_EDIT_MODE_NORMAL, GES_EDGE_START, 1000);
ges_timeline_commit (timeline);
/* 600____src___1100
* !_tr__^
* 500___________src1________1250
@ -788,6 +792,7 @@ GST_START_TEST (test_multi_layer_automatic_transition)
GST_DEBUG ("Adding clip from 500 -- 1000 to first layer");
src1 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 500,
0, 1000, GES_TRACK_TYPE_UNKNOWN));
ges_timeline_commit (timeline);
fail_unless (GES_IS_CLIP (src1));
/*
@ -1384,6 +1389,7 @@ GST_START_TEST (test_layer_activate_automatic_transition)
GST_DEBUG ("Moving src2 to 1200, check everything updates properly");
ges_timeline_element_set_start (src2, 1200);
ges_timeline_commit (timeline);
/*
* 0___________src_________1000
* 500______tr______1000