v4l2: v4l2_camera: Don't use libcamera::Semaphore for available buffers

In V4L2, a blocked dqbuf should not not also block a streamoff. This
means that on streamoff, the blocked dqbuf must return (with error). We
cannot do this with the libcamera semaphore, so pull out the necessary
components of a semaphore, and put them into V4L2Camera, so that dqbuf
from V4L2CameraProxy can wait on a disjunct condition of the
availability of the semaphore or the stopping of the stream.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Paul Elder 2020-06-16 16:40:34 +09:00
parent f155e63816
commit 566ccd75ca
3 changed files with 47 additions and 7 deletions

View file

@ -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_];