multiqueue: Allow growing a queue if all other queues are not linked
authorPer x Johansson <perxjoh@axis.com>
Thu, 23 Jan 2014 14:47:23 +0000 (15:47 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 24 Jan 2014 08:27:28 +0000 (09:27 +0100)
In the case where one singlequeue is full and all other are not linked, the
growing of the full queue does not work correctly. The result depends on if
the full queue is last in the queue list or not.

https://bugzilla.gnome.org/show_bug.cgi?id=722891

plugins/elements/gstmultiqueue.c

index 434902f..2f1a1bf 100644 (file)
@@ -1904,6 +1904,7 @@ single_queue_overrun_cb (GstDataQueue * dq, GstSingleQueue * sq)
   GstDataQueueSize size;
   gboolean filled = TRUE;
   gboolean all_not_linked = TRUE;
+  gboolean empty_found = FALSE;
 
   gst_data_queue_get_level (sq->queue, &size);
 
@@ -1921,8 +1922,7 @@ single_queue_overrun_cb (GstDataQueue * dq, GstSingleQueue * sq)
     goto done;
   }
 
-  /* if hard limits are not reached then we allow one more buffer in the full
-   * queue, but only if any of the other singelqueues are empty */
+  /* Search for empty or unlinked queues */
   for (tmp = mq->queues; tmp; tmp = g_list_next (tmp)) {
     GstSingleQueue *oq = (GstSingleQueue *) tmp->data;
 
@@ -1931,28 +1931,31 @@ single_queue_overrun_cb (GstDataQueue * dq, GstSingleQueue * sq)
 
     if (oq->srcresult == GST_FLOW_NOT_LINKED) {
       GST_LOG_OBJECT (mq, "Queue %d is not-linked", oq->id);
-      if (!all_not_linked || tmp->next)
         continue;
-    } else {
-      all_not_linked = FALSE;
-      GST_LOG_OBJECT (mq, "Checking Queue %d", oq->id);
     }
 
-    if (gst_data_queue_is_empty (oq->queue)
-        || oq->srcresult == GST_FLOW_NOT_LINKED) {
-      if (oq->srcresult == GST_FLOW_NOT_LINKED)
-        GST_LOG_OBJECT (mq, "All other queues are not linked");
-      else
-        GST_LOG_OBJECT (mq, "Queue %d is empty", oq->id);
+    all_not_linked = FALSE;
+    GST_LOG_OBJECT (mq, "Checking Queue %d", oq->id);
 
-      if (IS_FILLED (sq, visible, size.visible)) {
-        sq->max_size.visible = size.visible + 1;
-        GST_DEBUG_OBJECT (mq,
-            "Bumping single queue %d max visible to %d",
-            sq->id, sq->max_size.visible);
-        filled = FALSE;
-        break;
-      }
+    if (gst_data_queue_is_empty (oq->queue)) {
+      GST_LOG_OBJECT (mq, "Queue %d is empty", oq->id);
+      empty_found = TRUE;
+    }
+  }
+
+  /* if hard limits are not reached then we allow one more buffer in the full
+   * queue, but only if any of the other singelqueues are empty or all are
+   * not linked */
+  if (all_not_linked || empty_found) {
+    if (all_not_linked) {
+      GST_LOG_OBJECT (mq, "All other queues are not linked");
+    }
+    if (IS_FILLED (sq, visible, size.visible)) {
+      sq->max_size.visible = size.visible + 1;
+      GST_DEBUG_OBJECT (mq,
+          "Bumping single queue %d max visible to %d",
+          sq->id, sq->max_size.visible);
+      filled = FALSE;
     }
   }