ges: Keep the track object list sorted in track
authorMathieu Duponchelle <seeed@laposte.net>
Wed, 27 Jul 2011 00:04:48 +0000 (02:04 +0200)
committerThibault Saunier <thibault.saunier@collabora.com>
Wed, 11 Jan 2012 14:56:14 +0000 (11:56 -0300)
ges/ges-track.c

index c61451acdb4e05c564ce2372f2757607eabd6bd2..71cc6cb0be982196d78adc323c9a922bb439a2ff 100644 (file)
@@ -69,6 +69,9 @@ static void
 pad_removed_cb (GstElement * element, GstPad * pad, GESTrack * track);
 static void composition_duration_cb (GstElement * composition, GParamSpec * arg
     G_GNUC_UNUSED, GESTrack * obj);
+static void
+sort_track_objects_cb (GESTrackObject * child,
+    GParamSpec * arg G_GNUC_UNUSED, GESTrack * track);
 
 static void
 ges_track_get_property (GObject * object, guint property_id,
@@ -409,6 +412,12 @@ ges_track_add_object (GESTrack * track, GESTrackObject * object)
   g_signal_emit (track, ges_track_signals[TRACK_OBJECT_ADDED], 0,
       GES_TRACK_OBJECT (object));
 
+  g_signal_connect (GES_TRACK_OBJECT (object), "notify::start",
+      G_CALLBACK (sort_track_objects_cb), track);
+
+  g_signal_connect (GES_TRACK_OBJECT (object), "notify::priority",
+      G_CALLBACK (sort_track_objects_cb), track);
+
   return TRUE;
 }
 
@@ -534,6 +543,15 @@ composition_duration_cb (GstElement * composition,
   }
 }
 
+static void
+sort_track_objects_cb (GESTrackObject * child,
+    GParamSpec * arg G_GNUC_UNUSED, GESTrack * track)
+{
+  track->priv->trackobjects =
+      g_list_sort (track->priv->trackobjects,
+      (GCompareFunc) objects_start_compare);
+}
+
 /**
  * ges_track_get_caps:
  * @track: a #GESTrack