aggregator: add gst_aggregator_pad_drop_buffer()
authorTim-Philipp Müller <tim@centricular.com>
Fri, 13 Feb 2015 15:49:50 +0000 (15:49 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 2 Dec 2017 15:10:26 +0000 (15:10 +0000)
steal_buffer() + unref seems to be a wide-spread idiom
(which perhaps indicates that something is not quite
right with the way aggregator pad works currently).

libs/gst/base/gstaggregator.c
libs/gst/base/gstaggregator.h

index b69b7db..77ea80d 100644 (file)
@@ -2063,6 +2063,28 @@ gst_aggregator_pad_steal_buffer (GstAggregatorPad * pad)
 }
 
 /**
+ * gst_aggregator_pad_drop_buffer:
+ * @pad: the pad where to drop any pending buffer
+ *
+ * Drop the buffer currently queued in @pad.
+ *
+ * Returns: TRUE if there was a buffer queued in @pad, or FALSE if not.
+ */
+gboolean
+gst_aggregator_pad_drop_buffer (GstAggregatorPad * pad)
+{
+  GstBuffer *buf;
+
+  buf = gst_aggregator_pad_steal_buffer (pad);
+
+  if (buf == NULL)
+    return FALSE;
+
+  gst_buffer_unref (buf);
+  return TRUE;
+}
+
+/**
  * gst_aggregator_pad_get_buffer:
  * @pad: the pad to get buffer from
  *
index d0f1cdc..8c4e7cf 100644 (file)
@@ -104,6 +104,7 @@ GType gst_aggregator_pad_get_type           (void);
 
 GstBuffer * gst_aggregator_pad_steal_buffer (GstAggregatorPad *  pad);
 GstBuffer * gst_aggregator_pad_get_buffer   (GstAggregatorPad *  pad);
+gboolean    gst_aggregator_pad_drop_buffer  (GstAggregatorPad *  pad);
 gboolean    gst_aggregator_pad_is_eos       (GstAggregatorPad *  pad);
 
 /*********************