[libcamera-devel,v2,10/17] v4l2: v4l2_camera_proxy: noop if streamon when stream is already on

Message ID 20200619054123.19052-11-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • Support v4l2-compliance
Related show

Commit Message

Paul Elder June 19, 2020, 5:41 a.m. UTC
If VIDIOC_STREMAON is called when the stream is already on, do a noop.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
New in v2: (split from "v4l2: v4l2_camera: Add isRunning()")
---
 src/v4l2/v4l2_camera_proxy.cpp | 3 +++
 1 file changed, 3 insertions(+)

Comments

Laurent Pinchart June 20, 2020, 1:54 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Fri, Jun 19, 2020 at 02:41:16PM +0900, Paul Elder wrote:
> If VIDIOC_STREMAON is called when the stream is already on, do a noop.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> 
> ---
> New in v2: (split from "v4l2: v4l2_camera: Add isRunning()")
> ---
>  src/v4l2/v4l2_camera_proxy.cpp | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 63c6a2c..4d37662 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -616,6 +616,9 @@ int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *cf, int *arg)
>  {
>  	LOG(V4L2Compat, Debug) << "Servicing vidioc_streamon fd = " << cf->efd();
>  
> +	if (vcam_->isRunning())
> +		return 0;
> +

This should also go after the lock.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  	int ret = lock(cf);
>  	if (ret < 0)
>  		return ret;

Patch

diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 63c6a2c..4d37662 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -616,6 +616,9 @@  int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *cf, int *arg)
 {
 	LOG(V4L2Compat, Debug) << "Servicing vidioc_streamon fd = " << cf->efd();
 
+	if (vcam_->isRunning())
+		return 0;
+
 	int ret = lock(cf);
 	if (ret < 0)
 		return ret;