? log
? tests/check/log
Index: gnl/gnlcomposition.c
===================================================================
RCS file: /cvs/gstreamer/gnonlin/gnl/gnlcomposition.c,v
retrieving revision 1.60
diff -u -p -u -p -r1.60 gnlcomposition.c
--- gnl/gnlcomposition.c	31 Aug 2006 11:48:47 -0000	1.60
+++ gnl/gnlcomposition.c	6 Oct 2006 07:49:51 -0000
@@ -734,6 +734,9 @@ next_stop_in_region_above_priority (GnlC
     if (object->stop <= start)
       continue;
 
+    if (object->start <= start)
+      continue;
+
     if (object->start > stop)
       break;
 
@@ -756,7 +759,7 @@ next_stop_in_region_above_priority (GnlC
  */
 
 static GNode *
-convert_list_to_tree (GList ** stack, GstClockTime * stop)
+convert_list_to_tree (GList ** stack, GstClockTime * stop, guint * highprio)
 {
   GNode *ret;
   guint nbsinks;
@@ -769,7 +772,8 @@ convert_list_to_tree (GList ** stack, Gs
 
   object = (GnlObject *) (*stack)->data;
 
-  GST_DEBUG ("object:%s", GST_ELEMENT_NAME (object));
+  GST_DEBUG ("object:%s , stop:%"GST_TIME_FORMAT"highprio:%d", GST_ELEMENT_NAME (object),
+	     GST_TIME_ARGS (*stop), *highprio);
 
   /* update earliest stop */
   if (GST_CLOCK_TIME_IS_VALID (*stop)) {
@@ -779,8 +783,12 @@ convert_list_to_tree (GList ** stack, Gs
     *stop = object->stop;
   }
 
-  GST_DEBUG_OBJECT (object, "*stop:%"GST_TIME_FORMAT,
-		    GST_TIME_ARGS (*stop));
+  /* update highest priority */
+  if ((object->priority != G_MAXUINT) && (object->priority > *highprio))
+    *highprio = object->priority;
+
+  GST_DEBUG_OBJECT (object, "*stop:%"GST_TIME_FORMAT" priority:%d",
+		    GST_TIME_ARGS (*stop), *highprio);
 
   if (GNL_IS_SOURCE (object)) {
     *stack = g_list_next (*stack);
@@ -797,7 +805,7 @@ convert_list_to_tree (GList ** stack, Gs
     /* FIXME : if num_sinks == -1 : request the proper number of pads */
 
     for (tmp = g_list_next (*stack); tmp && (!limit || nbsinks);) {
-      g_node_append (ret, convert_list_to_tree (&tmp, stop));
+      g_node_append (ret, convert_list_to_tree (&tmp, stop, highprio));
 
       if (limit)
         nbsinks--;
@@ -813,6 +821,8 @@ convert_list_to_tree (GList ** stack, Gs
  * @timestamp: The #GstClockTime to look at
  * @priority: The priority level to start looking from
  * @activeonly: Only look for active elements if TRUE
+ * @stop: The smallest stop time of the objects in the stack
+ * @highprio: The highest priority in the stack
  *
  * Not MT-safe, you should take the objects lock before calling it.
  * Returns: A tree of #GNode sorted in priority order, corresponding
@@ -821,12 +831,14 @@ convert_list_to_tree (GList ** stack, Gs
 
 static GNode *
 get_stack_list (GnlComposition * comp, GstClockTime timestamp,
-    guint priority, gboolean activeonly, GstClockTime * stop)
+		guint priority, gboolean activeonly, GstClockTime * stop,
+		guint *highprio)
 {
   GList *tmp = comp->private->objects_start;
   GList *stack = NULL;
   GNode *ret = NULL;
   GstClockTime nstop = GST_CLOCK_TIME_NONE;
+  guint highest = 0;
 
   GST_DEBUG_OBJECT (comp,
       "timestamp:%" GST_TIME_FORMAT ", priority:%d, activeonly:%d",
@@ -862,8 +874,11 @@ get_stack_list (GnlComposition * comp, G
 
   /* convert that list to a stack */
   tmp = stack;
-  ret = convert_list_to_tree (&tmp, &nstop);
-  *stop = nstop;
+  ret = convert_list_to_tree (&tmp, &nstop, &highest);
+  if (nstop)
+    *stop = nstop;
+  if (highprio)
+    *highprio = highest;
 
   g_list_free (stack);
 
@@ -886,11 +901,12 @@ get_clean_toplevel_stack (GnlComposition
   GNode *stack = NULL;
   GList *tmp;
   GstClockTime stop = G_MAXUINT64;
+  guint highprio;
 
   GST_DEBUG_OBJECT (comp, "timestamp:%" GST_TIME_FORMAT,
       GST_TIME_ARGS (*timestamp));
 
-  stack = get_stack_list (comp, *timestamp, 0, TRUE, &stop);
+  stack = get_stack_list (comp, *timestamp, 0, TRUE, &stop, &highprio);
 
   if (!stack) {
     GnlObject *object = NULL;
@@ -913,19 +929,19 @@ get_clean_toplevel_stack (GnlComposition
           GST_TIME_FORMAT "]", GST_TIME_ARGS (*timestamp),
           GST_ELEMENT_NAME (object), GST_TIME_ARGS (object->start));
       *timestamp = object->start;
-      stack = get_stack_list (comp, *timestamp, 0, TRUE, &stop);
+      stack = get_stack_list (comp, *timestamp, 0, TRUE, &stop, &highprio);
     }
   }
 
   if (stack) {
     guint32 top_priority;
-
+    
     top_priority = GNL_OBJECT (stack->data)->priority;
-
+    
     /* Figure out if there's anything blocking us with smaller priority */
     stop =
         next_stop_in_region_above_priority (comp, *timestamp, stop,
-        top_priority);
+					    (highprio == 0) ? top_priority : highprio);
   }
 
   if (stop_time) {
