ges: preserve discovery order

The previous code was storing container children in reverse
addition order, this was mitigated by the fact that track elements
were also stored in reverse order, thus restoring the original
order, but it seems more consistent to preserve order throughout,
the extra cost of append operations is negligible.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1549>
This commit is contained in:
Mathieu Duponchelle 2022-01-22 02:24:23 +01:00 committed by GStreamer Marge Bot
parent b2c4052531
commit 52f7150de4
4 changed files with 16 additions and 16 deletions

View file

@ -2008,7 +2008,7 @@ _child_removed (GESContainer * container, GESTimelineElement * element)
static void
add_clip_to_list (gpointer key, gpointer clip, GList ** list)
{
*list = g_list_prepend (*list, gst_object_ref (clip));
*list = g_list_append (*list, gst_object_ref (clip));
}
/* NOTE: Since this does not change the track of @child, this should

View file

@ -761,7 +761,7 @@ ges_container_add (GESContainer * container, GESTimelineElement * child)
mapping = g_slice_new0 (ChildMapping);
mapping->child = gst_object_ref (child);
g_hash_table_insert (priv->mappings, child, mapping);
container->children = g_list_prepend (container->children, child);
container->children = g_list_append (container->children, child);
/* Listen to all property changes */
mapping->start_notifyid =

View file

@ -583,7 +583,7 @@ ges_uri_clip_create_track_elements (GESClip * clip, GESTrackType type)
NULL));
ges_timeline_element_set_max_duration (GES_TIMELINE_ELEMENT (element),
max_duration);
res = g_list_prepend (res, element);
res = g_list_append (res, element);
}
}

View file

@ -614,12 +614,15 @@ GST_START_TEST (test_split_object)
/* core elements have swapped order in the clip, this is ok since they
* share the same priority */
assert_equal_children_properties (splittrackelement, trackelement2);
fail_unless (ges_track_element_get_track (splittrackelement) == track2);
fail_unless (ges_track_element_get_track (trackelement2) == track2);
assert_equal_children_properties (splittrackelement, trackelement1);
fail_unless (ges_track_element_get_track (splittrackelement) == track1);
fail_unless (ges_track_element_get_track (trackelement1) == track1);
assert_equals_int (GES_TIMELINE_ELEMENT_PRIORITY (splittrackelement),
priority2 + 3);
fail_unless (GES_TIMELINE_ELEMENT_PRIORITY (trackelement2) == priority2);
priority1 + 3);
fail_unless (GES_TIMELINE_ELEMENT_PRIORITY (trackelement1) == priority1);
meta = ges_meta_container_get_string (GES_META_CONTAINER (splittrackelement),
"test_key");
fail_unless_equals_string (meta, "test_value");
fail_unless (splittrackelement != trackelement1);
fail_unless (splittrackelement != trackelement2);
@ -631,15 +634,12 @@ GST_START_TEST (test_split_object)
fail_unless (GES_IS_TRACK_ELEMENT (splittrackelement));
CHECK_OBJECT_PROPS (splittrackelement, 67, 37, 25);
assert_equal_children_properties (splittrackelement, trackelement1);
fail_unless (ges_track_element_get_track (splittrackelement) == track1);
fail_unless (ges_track_element_get_track (trackelement1) == track1);
assert_equal_children_properties (splittrackelement, trackelement2);
fail_unless (ges_track_element_get_track (splittrackelement) == track2);
fail_unless (ges_track_element_get_track (trackelement2) == track2);
assert_equals_int (GES_TIMELINE_ELEMENT_PRIORITY (splittrackelement),
priority1 + 3);
fail_unless (GES_TIMELINE_ELEMENT_PRIORITY (trackelement1) == priority2);
meta = ges_meta_container_get_string (GES_META_CONTAINER (splittrackelement),
"test_key");
fail_unless_equals_string (meta, "test_value");
priority2 + 3);
fail_unless (GES_TIMELINE_ELEMENT_PRIORITY (trackelement2) == priority2);
fail_unless (splittrackelement != trackelement1);
fail_unless (splittrackelement != trackelement2);