From f155e638168cb0d6cbd9dde8748301fa12a0736f Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Tue, 16 Jun 2020 12:28:34 +0900 Subject: v4l2: v4l2_camera_proxy: Clear internal buffer vector on reqbufs 0 If VIDIOC_REQBUFS with count = 0 is called when the stream is not on, clear the proxy's internal vector of buffer. If the stream is on when reqbufs 0 is called, return -EBUSY. Note that this is contrary to what the V4L2 docs say (reqbufs 0 when streaming should also streamoff), but it is how the V4L2 implementation works. v4l2-compliance doesn't seem to care either way, however, so we cater to the implementation, and no longer call streamoff on reqbufs 0. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- src/v4l2/v4l2_camera_proxy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/v4l2') diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 225ce42b..7bf9e7f8 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -445,11 +445,8 @@ void V4L2CameraProxy::freeBuffers() { LOG(V4L2Compat, Debug) << "Freeing libcamera bufs"; - int ret = vcam_->streamOff(); - if (ret < 0) - LOG(V4L2Compat, Error) << "Failed to stop stream"; - vcam_->freeBuffers(); + buffers_.clear(); bufferCount_ = 0; } @@ -473,6 +470,9 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf memset(arg->reserved, 0, sizeof(arg->reserved)); if (arg->count == 0) { + if (vcam_->isRunning()) + return -EBUSY; + freeBuffers(); release(file); -- cgit v1.2.1