[libcamera-devel] [PATCH 3/5] v4l2: v4l2_camera_proxy: Acquire only one buffer semaphore on VIDIOC_DQBUF

Paul Elder paul.elder at ideasonboard.com
Wed Jun 3 16:16:07 CEST 2020


We use a semaphore to atomically keep track of how many buffers are
available for dequeueing. The check for how to acquire the semaphore was
incorrect, leading to a double acquire upon a successful nonblocking
acquire. Fix this.

Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
---
 src/v4l2/v4l2_camera_proxy.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index ec6d265d..d2419b96 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -428,7 +428,7 @@ int V4L2CameraProxy::vidioc_dqbuf(struct v4l2_buffer *arg)
 
 	if (nonBlocking_ && !vcam_->bufferSema_.tryAcquire())
 		return -EAGAIN;
-	else
+	else if (!nonBlocking_)
 		vcam_->bufferSema_.acquire();
 
 	updateBuffers();
-- 
2.20.1



More information about the libcamera-devel mailing list