{
GstFlowReturn ret;
GstBaseSrcPrivate *priv = src->priv;
+ GstBufferPool *pool = NULL;
+ GstAllocator *allocator = NULL;
+ GstAllocationParams params;
+ GST_OBJECT_LOCK (src);
if (priv->pool) {
- ret = gst_buffer_pool_acquire_buffer (priv->pool, buffer, NULL);
+ pool = gst_object_ref (priv->pool);
+ } else if (priv->allocator) {
+ allocator = gst_object_ref (priv->allocator);
+ }
+ params = priv->params;
+ GST_OBJECT_UNLOCK (src);
+
+ if (pool) {
+ ret = gst_buffer_pool_acquire_buffer (pool, buffer, NULL);
} else if (size != -1) {
- *buffer = gst_buffer_new_allocate (priv->allocator, size, &priv->params);
+ *buffer = gst_buffer_new_allocate (allocator, size, ¶ms);
if (G_UNLIKELY (*buffer == NULL))
goto alloc_failed;
size);
goto alloc_failed;
}
+
+done:
+ if (pool)
+ gst_object_unref (pool);
+ if (allocator)
+ gst_object_unref (allocator);
+
return ret;
/* ERRORS */
alloc_failed:
{
GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", size);
- return GST_FLOW_ERROR;
+ ret = GST_FLOW_ERROR;
+ goto done;
}
}
GstBufferPool *
gst_base_src_get_buffer_pool (GstBaseSrc * src)
{
+ GstBufferPool *ret = NULL;
+
g_return_val_if_fail (GST_IS_BASE_SRC (src), NULL);
+ GST_OBJECT_LOCK (src);
if (src->priv->pool)
- return gst_object_ref (src->priv->pool);
+ ret = gst_object_ref (src->priv->pool);
+ GST_OBJECT_UNLOCK (src);
- return NULL;
+ return ret;
}
/**
{
g_return_if_fail (GST_IS_BASE_SRC (src));
+ GST_OBJECT_LOCK (src);
if (allocator)
*allocator = src->priv->allocator ?
gst_object_ref (src->priv->allocator) : NULL;
if (params)
*params = src->priv->params;
+ GST_OBJECT_UNLOCK (src);
}