[0.11] gstreamer: collectpads2: Fix handling of the event function and document it

Sebastian Dröge slomo at kemper.freedesktop.org
Thu Jan 26 01:45:50 PST 2012


Module: gstreamer
Branch: 0.11
Commit: 6b9280b18c092ccd917ce60cc01832e74f9897f0
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=6b9280b18c092ccd917ce60cc01832e74f9897f0

Author: Sebastian Dröge <sebastian.droege at collabora.co.uk>
Date:   Wed Jan 25 18:49:15 2012 +0100

collectpads2: Fix handling of the event function and document it

The event function is supposed to forward/drop the event in any case
now and takes ownership of the event.

---

 libs/gst/base/gstcollectpads2.c |    8 ++++----
 libs/gst/base/gstcollectpads2.h |    6 +++++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libs/gst/base/gstcollectpads2.c b/libs/gst/base/gstcollectpads2.c
index 3d14577..df3203c 100644
--- a/libs/gst/base/gstcollectpads2.c
+++ b/libs/gst/base/gstcollectpads2.c
@@ -1625,7 +1625,7 @@ gst_collect_pads2_event (GstPad * pad, GstObject * parent, GstEvent * event)
       /* forward event to unblock check_collected */
       if (event_func)
         res = event_func (pads, data, event, event_user_data);
-      if (!res)
+      else
         res = gst_pad_event_default (pad, parent, event);
 
       /* now unblock the chain function.
@@ -1754,7 +1754,7 @@ forward_or_default:
   }
   if (event_func)
     res = event_func (pads, data, event, event_user_data);
-  if (!res)
+  else
     res = gst_pad_event_default (pad, parent, event);
   if (need_unlock)
     GST_COLLECT_PADS2_STREAM_UNLOCK (pads);
@@ -1765,9 +1765,9 @@ forward_or_eat:
     GST_COLLECT_PADS2_STREAM_LOCK (pads);
     need_unlock = TRUE;
   }
-  if (event_func)
+  if (event_func) {
     res = event_func (pads, data, event, event_user_data);
-  if (!res) {
+  } else {
     gst_event_unref (event);
     res = TRUE;
   }
diff --git a/libs/gst/base/gstcollectpads2.h b/libs/gst/base/gstcollectpads2.h
index 165203a..64ae4ea 100644
--- a/libs/gst/base/gstcollectpads2.h
+++ b/libs/gst/base/gstcollectpads2.h
@@ -206,7 +206,11 @@ typedef gint (*GstCollectPads2CompareFunction) (GstCollectPads2 *pads,
  * @event: the #GstEvent received
  * @user_data: user data passed to gst_collect_pads2_set_event_function()
  *
- * A function that will be called after collectpads has processed the event.
+ * A function that will be called while processing an event. It takes
+ * ownership of the event and is responsible for forwarding
+ * events downstream (with gst_pad_event_default()) or dropping events.
+ *
+ * The SEGMENT and EOS events should usually be dropped by this function.
  *
  * Returns: %TRUE if the pad could handle the event
  *



More information about the gstreamer-commits mailing list