gst: pool: Fix GstBuffer leak on error

We borrowed a GstBuffer from the pool, if preparing the buffer failed,
we need to push it back to avoid leaking it.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Nicolas Dufresne
2021-03-11 15:52:55 -05:00
committed by Laurent Pinchart
parent 488bbe40a9
commit 6795ffe67f

View File

@@ -40,8 +40,10 @@ gst_libcamera_pool_acquire_buffer(GstBufferPool *pool, GstBuffer **buffer,
if (!buf)
return GST_FLOW_ERROR;
if (!gst_libcamera_allocator_prepare_buffer(self->allocator, self->stream, buf))
if (!gst_libcamera_allocator_prepare_buffer(self->allocator, self->stream, buf)) {
gst_atomic_queue_push(self->queue, buf);
return GST_FLOW_ERROR;
}
*buffer = buf;
return GST_FLOW_OK;