From: Wim Taymans Date: Wed, 14 Mar 2012 17:45:55 +0000 (+0100) Subject: basesrc: take prefix into account when allocating X-Git-Tag: RELEASE-0.11.3~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72ac5f516536d6a229ac5093fb152ab3440d417e;p=platform%2Fupstream%2Fgstreamer.git basesrc: take prefix into account when allocating Take into account the prefix that we received from the allocation query and use it to allocate and resize a larger buffer. --- diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index 1113405..3d2f671 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -1354,10 +1354,24 @@ gst_base_src_default_alloc (GstBaseSrc * src, guint64 offset, if (priv->pool) { ret = gst_buffer_pool_acquire_buffer (priv->pool, buffer, NULL); } else if (size != -1) { - *buffer = gst_buffer_new_allocate (priv->allocator, size, priv->alignment); - if (G_UNLIKELY (*buffer == NULL)) + GstMemory *mem; + guint maxsize; + + maxsize = size + priv->prefix; + + mem = gst_allocator_alloc (priv->allocator, maxsize, priv->alignment); + if (G_UNLIKELY (mem == NULL)) goto alloc_failed; + if (priv->prefix != 0) + gst_memory_resize (mem, priv->prefix, size); + + *buffer = gst_buffer_new (); + if (G_UNLIKELY (*buffer == NULL)) + goto buffer_failed; + + gst_buffer_take_memory (*buffer, -1, mem); + ret = GST_FLOW_OK; } else { GST_WARNING_OBJECT (src, "Not trying to alloc %u bytes. Blocksize not set?", @@ -1372,6 +1386,11 @@ alloc_failed: GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", size); return GST_FLOW_ERROR; } +buffer_failed: + { + GST_ERROR_OBJECT (src, "Failed to allocate buffer"); + return GST_FLOW_ERROR; + } } static GstFlowReturn