aggregator: Add a timeout parameter to ::aggregate()
authorSebastian Dröge <sebastian@centricular.com>
Wed, 17 Dec 2014 16:54:09 +0000 (17:54 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 2 Dec 2017 15:10:26 +0000 (15:10 +0000)
When this is TRUE, we really have to produce output. This happens
in live mixing mode when we have to output something for the current
time, no matter if we have enough input or not.

libs/gst/base/gstaggregator.c
libs/gst/base/gstaggregator.h
tests/check/libs/aggregator.c

index bb80527..16690f4 100644 (file)
@@ -486,12 +486,14 @@ gst_aggregator_get_next_time (GstAggregator * self)
 
 /* called with the src STREAM lock */
 static gboolean
-_wait_and_check (GstAggregator * self)
+_wait_and_check (GstAggregator * self, gboolean * timeout)
 {
   GstClockTime latency_max, latency_min;
   GstClockTime start;
   gboolean live;
 
+  *timeout = FALSE;
+
   gst_aggregator_get_latency (self, &live, &latency_min, &latency_max);
 
   if (gst_aggregator_iterate_sinkpads (self,
@@ -561,6 +563,7 @@ _wait_and_check (GstAggregator * self)
     /* we timed out */
     if (status == GST_CLOCK_OK || status == GST_CLOCK_EARLY) {
       SRC_STREAM_UNLOCK (self);
+      *timeout = TRUE;
       return TRUE;
     }
   }
@@ -575,6 +578,7 @@ aggregate_func (GstAggregator * self)
 {
   GstAggregatorPrivate *priv = self->priv;
   GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (self);
+  gboolean timeout = FALSE;
 
   if (self->priv->running == FALSE) {
     GST_DEBUG_OBJECT (self, "Not running anymore");
@@ -583,12 +587,12 @@ aggregate_func (GstAggregator * self)
 
   GST_LOG_OBJECT (self, "Checking aggregate");
   while (priv->send_eos && priv->running) {
-    if (!_wait_and_check (self))
+    if (!_wait_and_check (self, &timeout))
       continue;
 
     GST_TRACE_OBJECT (self, "Actually aggregating!");
 
-    priv->flow_return = klass->aggregate (self);
+    priv->flow_return = klass->aggregate (self, timeout);
 
     if (priv->flow_return == GST_FLOW_EOS) {
       _push_eos (self);
index 19b04e9..d11545c 100644 (file)
@@ -237,7 +237,8 @@ struct _GstAggregatorClass {
                                        GstPadMode          mode,
                                        gboolean            active);
 
-  GstFlowReturn     (*aggregate)      (GstAggregator    *  aggregator);
+  GstFlowReturn     (*aggregate)      (GstAggregator    *  aggregator,
+                                       gboolean            timeout);
 
   gboolean          (*stop)           (GstAggregator    *  aggregator);
 
index 46a657f..5e0c388 100644 (file)
@@ -63,7 +63,7 @@ struct _GstTestAggregatorClass
 };
 
 static GstFlowReturn
-gst_test_aggregator_aggregate (GstAggregator * aggregator)
+gst_test_aggregator_aggregate (GstAggregator * aggregator, gboolean timeout)
 {
   GstIterator *iter;
   gboolean all_eos = TRUE;