aggregator: Add a timeout parameter to ::aggregate()

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.
This commit is contained in:
Sebastian Dröge 2014-12-17 17:54:09 +01:00 committed by Tim-Philipp Müller
parent 344c85da76
commit 435a477f63
3 changed files with 10 additions and 5 deletions

View file

@ -486,12 +486,14 @@ gst_aggregator_get_next_time (GstAggregator * self)
/* called with the src STREAM lock */ /* called with the src STREAM lock */
static gboolean static gboolean
_wait_and_check (GstAggregator * self) _wait_and_check (GstAggregator * self, gboolean * timeout)
{ {
GstClockTime latency_max, latency_min; GstClockTime latency_max, latency_min;
GstClockTime start; GstClockTime start;
gboolean live; gboolean live;
*timeout = FALSE;
gst_aggregator_get_latency (self, &live, &latency_min, &latency_max); gst_aggregator_get_latency (self, &live, &latency_min, &latency_max);
if (gst_aggregator_iterate_sinkpads (self, if (gst_aggregator_iterate_sinkpads (self,
@ -561,6 +563,7 @@ _wait_and_check (GstAggregator * self)
/* we timed out */ /* we timed out */
if (status == GST_CLOCK_OK || status == GST_CLOCK_EARLY) { if (status == GST_CLOCK_OK || status == GST_CLOCK_EARLY) {
SRC_STREAM_UNLOCK (self); SRC_STREAM_UNLOCK (self);
*timeout = TRUE;
return TRUE; return TRUE;
} }
} }
@ -575,6 +578,7 @@ aggregate_func (GstAggregator * self)
{ {
GstAggregatorPrivate *priv = self->priv; GstAggregatorPrivate *priv = self->priv;
GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (self); GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (self);
gboolean timeout = FALSE;
if (self->priv->running == FALSE) { if (self->priv->running == FALSE) {
GST_DEBUG_OBJECT (self, "Not running anymore"); GST_DEBUG_OBJECT (self, "Not running anymore");
@ -583,12 +587,12 @@ aggregate_func (GstAggregator * self)
GST_LOG_OBJECT (self, "Checking aggregate"); GST_LOG_OBJECT (self, "Checking aggregate");
while (priv->send_eos && priv->running) { while (priv->send_eos && priv->running) {
if (!_wait_and_check (self)) if (!_wait_and_check (self, &timeout))
continue; continue;
GST_TRACE_OBJECT (self, "Actually aggregating!"); 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) { if (priv->flow_return == GST_FLOW_EOS) {
_push_eos (self); _push_eos (self);

View file

@ -237,7 +237,8 @@ struct _GstAggregatorClass {
GstPadMode mode, GstPadMode mode,
gboolean active); gboolean active);
GstFlowReturn (*aggregate) (GstAggregator * aggregator); GstFlowReturn (*aggregate) (GstAggregator * aggregator,
gboolean timeout);
gboolean (*stop) (GstAggregator * aggregator); gboolean (*stop) (GstAggregator * aggregator);

View file

@ -63,7 +63,7 @@ struct _GstTestAggregatorClass
}; };
static GstFlowReturn static GstFlowReturn
gst_test_aggregator_aggregate (GstAggregator * aggregator) gst_test_aggregator_aggregate (GstAggregator * aggregator, gboolean timeout)
{ {
GstIterator *iter; GstIterator *iter;
gboolean all_eos = TRUE; gboolean all_eos = TRUE;