From 950b772a0df849600d8a618808eca10fe3f73f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 13 Feb 2015 15:49:50 +0000 Subject: [PATCH] aggregator: add gst_aggregator_pad_drop_buffer() 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 | 22 ++++++++++++++++++++++ libs/gst/base/gstaggregator.h | 1 + 2 files changed, 23 insertions(+) diff --git a/libs/gst/base/gstaggregator.c b/libs/gst/base/gstaggregator.c index b69b7dbe2f..77ea80dbf0 100644 --- a/libs/gst/base/gstaggregator.c +++ b/libs/gst/base/gstaggregator.c @@ -2062,6 +2062,28 @@ gst_aggregator_pad_steal_buffer (GstAggregatorPad * pad) return buffer; } +/** + * 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 diff --git a/libs/gst/base/gstaggregator.h b/libs/gst/base/gstaggregator.h index d0f1cdc885..8c4e7cff8c 100644 --- a/libs/gst/base/gstaggregator.h +++ b/libs/gst/base/gstaggregator.h @@ -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); /*********************