diff options
author | Paul Elder <paul.elder@ideasonboard.com> | 2020-06-03 22:14:37 +0900 |
---|---|---|
committer | Paul Elder <paul.elder@ideasonboard.com> | 2020-06-08 17:11:34 +0900 |
commit | 4ed996990dba907c8916ccf2e3b08f9c4988b641 (patch) | |
tree | 55f7fc5f5671c2f07fa96044bd12eb5b3902931f /src/v4l2/v4l2_camera_proxy.cpp | |
parent | d072fd6e07487e20cbe4d781999e5c025702a091 (diff) |
v4l2: v4l2_camera_proxy: Acquire only one buffer semaphore on VIDIOC_DQBUF
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@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/v4l2/v4l2_camera_proxy.cpp')
-rw-r--r-- | src/v4l2/v4l2_camera_proxy.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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(); |