From 94e323c10f2d7fa85bf63f357d203ca5305800c6 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Wed, 20 Nov 2019 15:32:29 +0100 Subject: [PATCH] v4l2bufferpool: request the maximum number of buffers for DMABUF There are often only two buffers queued in the kernel so no new buffers are requested. With every qbuf, the kernel receives a new DMABUF for the specified index. This most likely differs from the last DMABUF and the old cached entry is released. This results in a lot of map/unmap overhead if the kernel driver needs a mapping for the buffer. With a larger queue, it's quite likely, that both old and new DMABUFs are also mapped for another index. So the map/unmap is skipped, because the mapping is reference counted. The corresponding allocated buffers don't contain any actual memory, so allocating them is quite cheep. So the log message is updated to clarify this. --- sys/v4l2/gstv4l2bufferpool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 4375ea7..a362413 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -841,9 +841,9 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool) can_allocate = GST_V4L2_ALLOCATOR_CAN_ALLOCATE (pool->vallocator, DMABUF); - GST_DEBUG_OBJECT (pool, "requesting %d DMABUF buffers", min_buffers); + GST_DEBUG_OBJECT (pool, "requesting %d DMABUF import slots", max_buffers); - count = gst_v4l2_allocator_start (pool->vallocator, min_buffers, + count = gst_v4l2_allocator_start (pool->vallocator, max_buffers, V4L2_MEMORY_DMABUF); /* There is no rational to not get what we asked */ -- 2.7.4