? libs/gst/base/gstcollectpads.c.blocking
? libs/gst/base/gstcollectpads.c.waiting
? libs/gst/base/gstcollectpads.h.waiting
? libs/gst/base/libgstbase_0.10_la-gstadapter.loT
Index: libs/gst/base/gstcollectpads.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/libs/gst/base/gstcollectpads.c,v
retrieving revision 1.49
diff -a -u -r1.49 gstcollectpads.c
--- libs/gst/base/gstcollectpads.c	1 Feb 2007 19:00:48 -0000	1.49
+++ libs/gst/base/gstcollectpads.c	19 Feb 2007 15:13:40 -0000
@@ -42,7 +42,7 @@
  *     performing a pull_range.
  *   </para></listitem>
  *   <listitem><para>
- *     When data is queued on all pads, the callback function is called.
+ *     When data is queued on all pads in waiting mode, the callback function is called.
  *   </para></listitem>
  *   <listitem><para>
  *     Data can be dequeued from the pad with the gst_collect_pads_pop() method.
@@ -67,6 +67,12 @@
  *     elements that start a #GstTask to drive the collect_pads. This feature is however
  *     not yet implemented.
  *   </para></listitem>
+ *   <listitem><para>
+ *     gst_collect_pads_set_waiting() sets a pad to waiting or non-waiting mode.
+ *     CollectPads element is not waiting for data to be collected on non-waiting pads.
+ *     Thus these pads may but need not have data when the callback is called.
+ *     All pads are in waiting mode by default.
+ *   </para></listitem>
  * </itemizedlist>
  *
  * Last reviewed on 2006-05-10 (0.10.6)
@@ -324,6 +330,7 @@
   data->abidata.ABI.new_segment = FALSE;
   data->abidata.ABI.eos = FALSE;
   data->abidata.ABI.refcount = 1;
+  data->abidata.ABI.waiting = TRUE;
 
   /* FIXME: Ugly hack as we can't add more fields to GstCollectData */
   g_object_set_data (G_OBJECT (pad), "gst-collect-data-destroy-notify",
@@ -718,7 +725,8 @@
     data->buffer = NULL;
     data->pos = 0;
     /* one less pad with queued data now */
-    pads->queuedpads--;
+    if (data->abidata.ABI.waiting)
+      pads->queuedpads--;
   }
 
   GST_COLLECT_PADS_BROADCAST (pads);
@@ -890,6 +898,46 @@
   return flushsize;
 }
 
+/**
+ * gst_collect_pads_set_waiting:
+ * @pads: the collectspads
+ * @data: the data to use
+ * @waiting: boolean indicating whether this pad should operate
+ *           in waiting or non-waiting mode
+ *
+ * Sets a pad to waiting or non-waiting mode.
+ *
+ * This function should be called with @pads LOCK held, such as
+ * in the callback.
+ *
+ * MT safe.
+ */
+void
+gst_collect_pads_set_waiting (GstCollectPads *pads, GstCollectData *data,
+    gboolean waiting)
+{
+  g_return_if_fail (pads != NULL);
+  g_return_if_fail (GST_IS_COLLECT_PADS (pads));
+  g_return_if_fail (data != NULL);
+
+  /* Do something only on changes */
+  if (data->abidata.ABI.waiting != waiting) {
+    /* Set waiting state for this pad */
+    data->abidata.ABI.waiting = waiting;
+
+    /* Update number of queued pads if needed */
+    if (!data->buffer && !data->abidata.ABI.eos) {
+      if (data->abidata.ABI.waiting)
+        pads->queuedpads--;
+      else
+        pads->queuedpads++;
+    }
+
+    /* signal waiters because something changed */
+    GST_COLLECT_PADS_BROADCAST (pads);
+  }
+}
+
 /* see if pads were added or removed and update our stats. Any pad
  * added after releasing the PAD_LOCK will get collected in the next
  * round.
@@ -922,10 +970,10 @@
       /* update the stats */
       pads->numpads++;
       data = collected->data;
-      if (data->buffer)
-        pads->queuedpads++;
       if (data->abidata.ABI.eos)
         pads->eospads++;
+      else if (data->buffer || !data->abidata.ABI.waiting)
+        pads->queuedpads++;
 
       /* add to the list of pads to collect */
       pads->data = g_slist_prepend (pads->data, data);
@@ -1039,6 +1087,8 @@
       /* if the pad was EOS, remove the EOS flag and
        * decrement the number of eospads */
       if (G_UNLIKELY (data->abidata.ABI.eos == TRUE)) {
+        if (!data->abidata.ABI.waiting)
+          pads->queuedpads++;
         pads->eospads--;
         data->abidata.ABI.eos = FALSE;
       }
@@ -1054,6 +1104,8 @@
        * have one more eospad */
       if (G_LIKELY (data->abidata.ABI.eos == FALSE)) {
         data->abidata.ABI.eos = TRUE;
+        if (!data->abidata.ABI.waiting)
+          pads->queuedpads--;
         pads->eospads++;
       }
       /* check if we need collecting anything, we ignore the
@@ -1164,7 +1216,8 @@
       GST_DEBUG_PAD_NAME (pad));
 
   /* One more pad has data queued */
-  pads->queuedpads++;
+  if (data->abidata.ABI.waiting)
+      pads->queuedpads++;
   buffer_p = &data->buffer;
   gst_buffer_replace (buffer_p, buffer);
 
Index: libs/gst/base/gstcollectpads.h
===================================================================
RCS file: /cvs/gstreamer/gstreamer/libs/gst/base/gstcollectpads.h,v
retrieving revision 1.21
diff -a -u -r1.21 gstcollectpads.h
--- libs/gst/base/gstcollectpads.h	1 Feb 2007 19:00:48 -0000	1.21
+++ libs/gst/base/gstcollectpads.h	19 Feb 2007 15:13:40 -0000
@@ -75,6 +75,7 @@
       gboolean           new_segment;
       gboolean           eos;
       gint               refcount;
+      gboolean           waiting;
     } ABI;
     /* adding + 0 to mark ABI change to be undone later */
     gpointer _gst_reserved[GST_PADDING + 0];
@@ -184,6 +185,11 @@
 guint 		gst_collect_pads_flush 		(GstCollectPads *pads, GstCollectData *data,
 						 guint size);
 
+/* setting and unsetting waiting mode */
+void		gst_collect_pads_set_waiting	(GstCollectPads *pads, GstCollectData *data,
+						 gboolean waiting);
+
+
 G_END_DECLS
 
 #endif /* __GST_COLLECT_PADS_H__ */
