No need to use an iterator for this which creates a temporary
structure every time and also involves taking and releasing the
object lock many times in the course of iterating. Not to mention
all that GList handling in gst_aggregator_iterate_sinkpads().
-static inline gboolean
-gst_aggregator_check_all_pads_with_data_or_eos (GstAggregator * self,
- GstAggregatorPad * aggpad, gpointer user_data)
+static gboolean
+gst_aggregator_check_pads_ready (GstAggregator * self)
- if (aggpad->buffer || aggpad->eos) {
- return TRUE;
+ GstAggregatorPad *pad;
+ GList *l, *sinkpads;
+
+ GST_LOG_OBJECT (self, "checking pads");
+
+ GST_OBJECT_LOCK (self);
+
+ sinkpads = GST_ELEMENT_CAST (self)->sinkpads;
+ if (sinkpads == NULL)
+ goto no_sinkpads;
+
+ for (l = sinkpads; l != NULL; l = l->next) {
+ pad = l->data;
+
+ if (pad->buffer == NULL && !pad->eos)
+ goto pad_not_ready;
- GST_LOG_OBJECT (aggpad, "Not ready to be aggregated");
+ GST_OBJECT_UNLOCK (self);
+ GST_LOG_OBJECT (self, "pads are ready");
+ return TRUE;
+no_sinkpads:
+ {
+ GST_LOG_OBJECT (self, "pads not ready: no sink pads");
+ GST_OBJECT_UNLOCK (self);
+ return FALSE;
+ }
+pad_not_ready:
+ {
+ GST_LOG_OBJECT (pad, "pad not ready to be aggregated yet");
+ GST_OBJECT_UNLOCK (self);
+ return 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,
- gst_aggregator_check_all_pads_with_data_or_eos, NULL)) {
+ if (gst_aggregator_check_pads_ready (self)) {
GST_DEBUG_OBJECT (self, "all pads have data");
SRC_STREAM_UNLOCK (self);
GST_DEBUG_OBJECT (self, "all pads have data");
SRC_STREAM_UNLOCK (self);
- res = gst_aggregator_iterate_sinkpads (self,
- gst_aggregator_check_all_pads_with_data_or_eos, NULL);
+ res = gst_aggregator_check_pads_ready (self);
SRC_STREAM_UNLOCK (self);
return res;
SRC_STREAM_UNLOCK (self);
return res;
(G_MAXLONG == G_MAXINT64) ? G_MAXINT64 : (G_MAXLONG * GST_SECOND - 1),
DEFAULT_LATENCY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
(G_MAXLONG == G_MAXINT64) ? G_MAXINT64 : (G_MAXLONG * GST_SECOND - 1),
DEFAULT_LATENCY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- GST_DEBUG_REGISTER_FUNCPTR (gst_aggregator_check_all_pads_with_data_or_eos);
GST_DEBUG_REGISTER_FUNCPTR (gst_aggregator_stop_pad);
GST_DEBUG_REGISTER_FUNCPTR (gst_aggregator_query_sink_latency_foreach);
GST_DEBUG_REGISTER_FUNCPTR (gst_aggregator_set_flush_pending);
GST_DEBUG_REGISTER_FUNCPTR (gst_aggregator_stop_pad);
GST_DEBUG_REGISTER_FUNCPTR (gst_aggregator_query_sink_latency_foreach);
GST_DEBUG_REGISTER_FUNCPTR (gst_aggregator_set_flush_pending);
PAD_STREAM_UNLOCK (aggpad);
SRC_STREAM_LOCK (self);
PAD_STREAM_UNLOCK (aggpad);
SRC_STREAM_LOCK (self);
- if (gst_aggregator_iterate_sinkpads (self,
- gst_aggregator_check_all_pads_with_data_or_eos, NULL))
+ if (gst_aggregator_check_pads_ready (self))
SRC_STREAM_BROADCAST_UNLOCKED (self);
SRC_STREAM_UNLOCK (self);
SRC_STREAM_BROADCAST_UNLOCKED (self);
SRC_STREAM_UNLOCK (self);