From 4ed996990dba907c8916ccf2e3b08f9c4988b641 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Wed, 3 Jun 2020 22:14:37 +0900 Subject: v4l2: v4l2_camera_proxy: Acquire only one buffer semaphore on VIDIOC_DQBUF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/v4l2/v4l2_camera_proxy.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/v4l2') diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index ec6d265d..a0c6deea 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -426,10 +426,10 @@ int V4L2CameraProxy::vidioc_dqbuf(struct v4l2_buffer *arg) !validateMemoryType(arg->memory)) return -EINVAL; - if (nonBlocking_ && !vcam_->bufferSema_.tryAcquire()) - return -EAGAIN; - else + if (!nonBlocking_) vcam_->bufferSema_.acquire(); + else if (!vcam_->bufferSema_.tryAcquire()) + return -EAGAIN; updateBuffers(); -- cgit v1.2.1