[0.11] gstreamer: basesrc: add alloc vmethod
Wim Taymans
wtay at kemper.freedesktop.org
Thu Aug 4 09:00:43 PDT 2011
Module: gstreamer
Branch: 0.11
Commit: 10485ea8036d8d81753585fc2793ae636732122f
URL: http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=10485ea8036d8d81753585fc2793ae636732122f
Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date: Thu Aug 4 18:00:02 2011 +0200
basesrc: add alloc vmethod
Make an alloc vmethod so that subclasses can override or call the default
implementation when they want.
---
libs/gst/base/gstbasesrc.c | 11 ++++++++---
libs/gst/base/gstbasesrc.h | 6 +++++-
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c
index c716fb0..b0c93e9 100644
--- a/libs/gst/base/gstbasesrc.c
+++ b/libs/gst/base/gstbasesrc.c
@@ -305,6 +305,8 @@ static gboolean gst_base_src_default_prepare_seek_segment (GstBaseSrc * src,
GstEvent * event, GstSegment * segment);
static GstFlowReturn gst_base_src_default_create (GstBaseSrc * basesrc,
guint64 offset, guint size, GstBuffer ** buf);
+static GstFlowReturn gst_base_src_default_alloc (GstBaseSrc * basesrc,
+ guint64 offset, guint size, GstBuffer ** buf);
static gboolean gst_base_src_set_flushing (GstBaseSrc * basesrc,
gboolean flushing, gboolean live_play, gboolean unlock, gboolean * playing);
@@ -374,6 +376,7 @@ gst_base_src_class_init (GstBaseSrcClass * klass)
klass->prepare_seek_segment =
GST_DEBUG_FUNCPTR (gst_base_src_default_prepare_seek_segment);
klass->create = GST_DEBUG_FUNCPTR (gst_base_src_default_create);
+ klass->alloc = GST_DEBUG_FUNCPTR (gst_base_src_default_alloc);
/* Registering debug symbols for function pointers */
GST_DEBUG_REGISTER_FUNCPTR (gst_base_src_activate_push);
@@ -1264,7 +1267,7 @@ gst_base_src_prepare_seek_segment (GstBaseSrc * src, GstEvent * event,
}
static GstFlowReturn
-gst_base_src_alloc_buffer (GstBaseSrc * src, guint64 offset,
+gst_base_src_default_alloc (GstBaseSrc * src, guint64 offset,
guint size, GstBuffer ** buffer)
{
GstFlowReturn ret;
@@ -1298,10 +1301,12 @@ gst_base_src_default_create (GstBaseSrc * src, guint64 offset,
bclass = GST_BASE_SRC_GET_CLASS (src);
+ if (G_UNLIKELY (!bclass->alloc))
+ goto no_function;
if (G_UNLIKELY (!bclass->fill))
goto no_function;
- ret = gst_base_src_alloc_buffer (src, offset, size, buffer);
+ ret = bclass->alloc (src, offset, size, buffer);
if (G_UNLIKELY (ret != GST_FLOW_OK))
goto alloc_failed;
@@ -1317,7 +1322,7 @@ gst_base_src_default_create (GstBaseSrc * src, guint64 offset,
/* ERRORS */
no_function:
{
- GST_DEBUG_OBJECT (src, "no fill function");
+ GST_DEBUG_OBJECT (src, "no fill or alloc function");
return GST_FLOW_NOT_SUPPORTED;
}
alloc_failed:
diff --git a/libs/gst/base/gstbasesrc.h b/libs/gst/base/gstbasesrc.h
index 9746eae..ec8419b 100644
--- a/libs/gst/base/gstbasesrc.h
+++ b/libs/gst/base/gstbasesrc.h
@@ -205,9 +205,13 @@ struct _GstBaseSrcClass {
gboolean (*event) (GstBaseSrc *src, GstEvent *event);
/* ask the subclass to create a buffer with offset and size, the default
- * implementation will use the negotiated allocator and call fill. */
+ * implementation will call alloc and fill. */
GstFlowReturn (*create) (GstBaseSrc *src, guint64 offset, guint size,
GstBuffer **buf);
+ /* ask the subclass to allocate an output buffer. The default implementation
+ * will use the negotiated allocator. */
+ GstFlowReturn (*alloc) (GstBaseSrc *src, guint64 offset, guint size,
+ GstBuffer **buf);
/* ask the subclass to fill the buffer with data from offset and size */
GstFlowReturn (*fill) (GstBaseSrc *src, guint64 offset, guint size,
GstBuffer *buf);
More information about the gstreamer-commits
mailing list