summaryrefslogtreecommitdiff
path: root/src/v4l2/v4l2_camera_proxy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/v4l2/v4l2_camera_proxy.cpp')
-rw-r--r--src/v4l2/v4l2_camera_proxy.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 7bf9e7f8..a222795d 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -588,10 +588,17 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
return -EINVAL;
if (!file->nonBlocking())
- vcam_->bufferSema_.acquire();
- else if (!vcam_->bufferSema_.tryAcquire())
+ vcam_->waitForBufferAvailable();
+ else if (!vcam_->isBufferAvailable())
return -EAGAIN;
+ /*
+ * We need to check here again in case stream was turned off while we
+ * were blocked on waitForBufferAvailable().
+ */
+ if (!vcam_->isRunning())
+ return -EINVAL;
+
updateBuffers();
struct v4l2_buffer &buf = buffers_[currentBuf_];