pushsrc: make alloc method a vmethod

This commit is contained in:
Wim Taymans 2011-11-10 13:36:10 +01:00
parent 41bb41616b
commit 4760e1902a
2 changed files with 26 additions and 3 deletions

View file

@ -72,6 +72,8 @@ G_DEFINE_TYPE_WITH_CODE (GstPushSrc, gst_push_src, GST_TYPE_BASE_SRC, _do_init);
static gboolean gst_push_src_query (GstBaseSrc * src, GstQuery * query);
static GstFlowReturn gst_push_src_create (GstBaseSrc * bsrc, guint64 offset,
guint length, GstBuffer ** ret);
static GstFlowReturn gst_push_src_alloc (GstBaseSrc * bsrc, guint64 offset,
guint length, GstBuffer ** ret);
static GstFlowReturn gst_push_src_fill (GstBaseSrc * bsrc, guint64 offset,
guint length, GstBuffer * ret);
@ -81,6 +83,7 @@ gst_push_src_class_init (GstPushSrcClass * klass)
GstBaseSrcClass *gstbasesrc_class = (GstBaseSrcClass *) klass;
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_push_src_create);
gstbasesrc_class->alloc = GST_DEBUG_FUNCPTR (gst_push_src_alloc);
gstbasesrc_class->fill = GST_DEBUG_FUNCPTR (gst_push_src_fill);
gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_push_src_query);
}
@ -132,6 +135,24 @@ gst_push_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
return fret;
}
static GstFlowReturn
gst_push_src_alloc (GstBaseSrc * bsrc, guint64 offset, guint length,
GstBuffer ** ret)
{
GstFlowReturn fret;
GstPushSrc *src;
GstPushSrcClass *pclass;
src = GST_PUSH_SRC (bsrc);
pclass = GST_PUSH_SRC_GET_CLASS (src);
if (pclass->alloc)
fret = pclass->alloc (src, ret);
else
fret = GST_BASE_SRC_CLASS (parent_class)->alloc (bsrc, offset, length, ret);
return fret;
}
static GstFlowReturn
gst_push_src_fill (GstBaseSrc * bsrc, guint64 offset, guint length,
GstBuffer * ret)

View file

@ -54,11 +54,13 @@ struct _GstPushSrc {
struct _GstPushSrcClass {
GstBaseSrcClass parent_class;
/* ask the subclass to create a buffer */
/* ask the subclass to create a buffer, the default implementation
* uses alloc and fill */
GstFlowReturn (*create) (GstPushSrc *src, GstBuffer **buf);
/* allocate memory for a buffer */
GstFlowReturn (*alloc) (GstPushSrc *src, GstBuffer **buf);
/* ask the subclass to fill a buffer */
GstFlowReturn (*fill) (GstPushSrc *src, GstBuffer *buf);
GstFlowReturn (*fill) (GstPushSrc *src, GstBuffer *buf);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];