summaryrefslogtreecommitdiff
path: root/src/v4l2/v4l2_camera_proxy.cpp
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2020-06-18 18:50:11 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2020-06-25 23:47:13 +0900
commit12fa2fe02027a96de6adfddef01381128f23a0dd (patch)
tree7dc530237881a06c55dd9656d6d22cfee58fa25e /src/v4l2/v4l2_camera_proxy.cpp
parent3f01ccf24b5866b23ca37bcee9e92a648363e4e1 (diff)
v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing
Fix buffer flags related to queueing and dequeueing: - don't allow a buffer with the same index that is already in the queue to be enqueued again - don't clear the done flag upon qbuf - do clear the done flag upon dqbuf - set the flags in V4L2CameraProxy's internal buffers, and not just in the buffers returned from qbuf Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/v4l2/v4l2_camera_proxy.cpp')
-rw-r--r--src/v4l2/v4l2_camera_proxy.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index d0a12bc3..7579d93b 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -565,6 +565,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
if (arg->index >= bufferCount_)
return -EINVAL;
+ if (buffers_[arg->index].flags & V4L2_BUF_FLAG_QUEUED)
+ return -EINVAL;
+
if (!hasOwnership(file))
return -EBUSY;
@@ -577,8 +580,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
if (ret < 0)
return ret;
- arg->flags |= V4L2_BUF_FLAG_QUEUED;
- arg->flags &= ~V4L2_BUF_FLAG_DONE;
+ buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED;
+
+ arg->flags = buffers_[arg->index].flags;
return ret;
}
@@ -616,7 +620,7 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
struct v4l2_buffer &buf = buffers_[currentBuf_];
- buf.flags &= ~V4L2_BUF_FLAG_QUEUED;
+ buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);
buf.length = sizeimage_;
*arg = buf;