Commit 72ac5f51 authored by Wim Taymans's avatar Wim Taymans
Browse files

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.
parent f2d81f4c
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment