summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas@ndufresne.ca>2018-10-17 02:28:13 +0000
committerTim-Philipp Müller <tim@centricular.com>2019-11-20 17:33:50 +0000
commitfba94862a9e8205c7a83bdf15adcee5e8535f605 (patch)
tree939a58b5a56c2f36f7ce87ed57c6dc5f1f430b1f
parent5fbc79c3a8ffb75e447b9e81f506da5b5bf073fe (diff)
v4l2bufferpool: Queue number of allocated buffers to capture
Before we do streamon, we queue all capture buffers by calling resurrect. When the driver supports CREATE_BUFS, this would lead to buffers being allocated till the maximum of 32 is reached. Instead, we now save the number of allocated buffers and queue this amount.
-rw-r--r--sys/v4l2/gstv4l2bufferpool.c7
-rw-r--r--sys/v4l2/gstv4l2bufferpool.h1
2 files changed, 6 insertions, 2 deletions
diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
index d7fa9fa2e..49f222b6e 100644
--- a/sys/v4l2/gstv4l2bufferpool.c
+++ b/sys/v4l2/gstv4l2bufferpool.c
@@ -650,12 +650,14 @@ gst_v4l2_buffer_pool_streamon (GstV4l2BufferPool * pool)
case GST_V4L2_IO_DMABUF:
case GST_V4L2_IO_DMABUF_IMPORT:
if (!V4L2_TYPE_IS_OUTPUT (pool->obj->type)) {
+ guint i;
+
/* For captures, we need to enqueue buffers before we start streaming,
* so the driver don't underflow immediatly. As we have put then back
* into the base class queue, resurrect them, then releasing will queue
* them back. */
- while (gst_v4l2_buffer_pool_resurrect_buffer (pool) == GST_FLOW_OK)
- continue;
+ for (i = 0; i < pool->num_allocated; i++)
+ gst_v4l2_buffer_pool_resurrect_buffer (pool);
}
if (obj->ioctl (pool->video_fd, VIDIOC_STREAMON, &obj->type) < 0)
@@ -791,6 +793,7 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool)
count = gst_v4l2_allocator_start (pool->vallocator, min_buffers,
V4L2_MEMORY_MMAP);
+ pool->num_allocated = count;
if (count < GST_V4L2_MIN_BUFFERS) {
min_buffers = count;
diff --git a/sys/v4l2/gstv4l2bufferpool.h b/sys/v4l2/gstv4l2bufferpool.h
index 285703cdb..bf0625d38 100644
--- a/sys/v4l2/gstv4l2bufferpool.h
+++ b/sys/v4l2/gstv4l2bufferpool.h
@@ -79,6 +79,7 @@ struct _GstV4l2BufferPool
guint min_latency; /* number of buffers we will hold */
guint max_latency; /* number of buffers we can hold */
guint num_queued; /* number of buffers queued in the driver */
+ guint num_allocated; /* number of buffers allocated */
guint copy_threshold; /* when our pool runs lower, start handing out copies */
gboolean streaming;