clip: Use container priority offset when setting children prios
authorThibault Saunier <tsaunier@gnome.org>
Wed, 1 Jul 2015 09:35:42 +0000 (11:35 +0200)
committerThibault Saunier <tsaunier@gnome.org>
Wed, 1 Jul 2015 09:38:53 +0000 (11:38 +0200)
Instead of trying to compute it ourself which might lead to wrong
behaviour when moving between layer.

+ Make sure that when we reset clip children priority (to make space
  for effects,) we update the container knowledge of priority offsets

ges/ges-clip.c
ges/nle/nlecomposition.c

index 380a32d..9dd935a 100644 (file)
@@ -223,16 +223,17 @@ _set_priority (GESTimelineElement * element, guint32 priority)
   for (tmp = container->children; tmp; tmp = g_list_next (tmp)) {
     guint32 real_tck_prio;
     GESTimelineElement *child = (GESTimelineElement *) tmp->data;
-    gint off = _PRIORITY (child) - _PRIORITY (element) - min_prio;
+    gint off = _ges_container_get_priority_offset (container, child);
+
 
     if (off >= LAYER_HEIGHT) {
       GST_ERROR ("%s child %s as a priority offset %d >= LAYER_HEIGHT %d"
-          "clamping it to 0", GES_TIMELINE_ELEMENT_NAME (element),
+          " ==> clamping it to 0", GES_TIMELINE_ELEMENT_NAME (element),
           GES_TIMELINE_ELEMENT_NAME (child), off, LAYER_HEIGHT);
       off = 0;
     }
 
-    real_tck_prio = min_prio + priority + off;
+    real_tck_prio = min_prio + priority - off;
 
     if (real_tck_prio > max_prio) {
       GST_WARNING ("%p priority of %i, is outside of the its containing "
@@ -300,6 +301,7 @@ _add_child (GESContainer * container, GESTimelineElement * element)
    */
   _get_priority_range (container, &min_prio, &max_prio);
   if (GES_IS_BASE_EFFECT (element)) {
+    GESChildrenControlMode mode = container->children_control_mode;
 
     GST_DEBUG_OBJECT (container, "Adding %ith effect: %" GST_PTR_FORMAT
         " Priority %i", priv->nb_effects + 1, element,
@@ -307,12 +309,15 @@ _add_child (GESContainer * container, GESTimelineElement * element)
         priv->nb_effects);
 
     tmp = g_list_nth (GES_CONTAINER_CHILDREN (container), priv->nb_effects);
-    for (; tmp; tmp = tmp->next)
+    container->children_control_mode = GES_CHILDREN_UPDATE_OFFSETS;
+    for (; tmp; tmp = tmp->next) {
       ges_timeline_element_set_priority (GES_TIMELINE_ELEMENT (tmp->data),
           GES_TIMELINE_ELEMENT_PRIORITY (tmp->data) + 1);
+    }
 
     _set_priority0 (element, min_prio +
         GES_TIMELINE_ELEMENT_PRIORITY (container) + priv->nb_effects);
+    container->children_control_mode = mode;
     priv->nb_effects++;
   } else {
     /* We add the track element on top of the effect list */
index 13efe83..77416d3 100644 (file)
@@ -2134,8 +2134,9 @@ _is_ready_to_restart_task (NleComposition * comp, GstEvent * event)
 
 
   if (comp->priv->seqnum_to_restart_task == seqnum) {
-    gchar *name = g_strdup_printf ("new-stack__%" GST_TIME_FORMAT "--%"
-        GST_TIME_FORMAT "", GST_TIME_ARGS (comp->priv->segment_start),
+    gchar *name = g_strdup_printf ("%s-new-stack__%" GST_TIME_FORMAT "--%"
+        GST_TIME_FORMAT "", GST_OBJECT_NAME (comp),
+        GST_TIME_ARGS (comp->priv->segment_start),
         GST_TIME_ARGS (comp->priv->segment_stop));
 
     GST_INFO_OBJECT (comp, "Got %s with proper seqnum"