[libcamera-devel,2/4] cam: improve error checking when capturing

Message ID 20190220143736.529-3-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • cam: improve error paths
Related show

Commit Message

Niklas Söderlund Feb. 20, 2019, 2:37 p.m. UTC
The return value when start() and stop() the camera should be checked
and handled.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/cam/main.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart Feb. 22, 2019, 12:34 a.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Wed, Feb 20, 2019 at 03:37:34PM +0100, Niklas Söderlund wrote:
> The return value when start() and stop() the camera should be checked
> and handled.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

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

> ---
>  src/cam/main.cpp | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> index b034eb25429abeb3..30267970a2c8485f 100644
> --- a/src/cam/main.cpp
> +++ b/src/cam/main.cpp
> @@ -183,11 +183,18 @@ static int capture()
>  	}
>  
>  	std::cout << "Capture until user interrupts by SIGINT" << std::endl;
> -	camera->start();
> +
> +	ret = camera->start();
> +	if (ret) {
> +		std::cout << "Failed to start capture" << std::endl;
> +		goto out;
> +	}
>  
>  	ret = loop->exec();
>  
> -	camera->stop();
> +	ret = camera->stop();
> +	if (ret)
> +		std::cout << "Failed to stop capture" << std::endl;
>  out:
>  	camera->freeBuffers();
>

Patch

diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index b034eb25429abeb3..30267970a2c8485f 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -183,11 +183,18 @@  static int capture()
 	}
 
 	std::cout << "Capture until user interrupts by SIGINT" << std::endl;
-	camera->start();
+
+	ret = camera->start();
+	if (ret) {
+		std::cout << "Failed to start capture" << std::endl;
+		goto out;
+	}
 
 	ret = loop->exec();
 
-	camera->stop();
+	ret = camera->stop();
+	if (ret)
+		std::cout << "Failed to stop capture" << std::endl;
 out:
 	camera->freeBuffers();