[libcamera-devel,2/3] libcamera: raspberrypi: Fail on unsupported stream role

Message ID 20200628161723.30625-3-jacopo@jmondi.org
State Accepted
Headers show
Series
  • libcamera: pipeline handlers: Fail if roles are not supported
Related show

Commit Message

Jacopo Mondi June 28, 2020, 4:17 p.m. UTC
When an unsupported stream roles is requested to
generateConfiguration(), the function shall fail instead of simply
ignoring the request.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Niklas Söderlund June 28, 2020, 6:31 p.m. UTC | #1
Hi Jacopo,

Thanks for your work.

On 2020-06-28 18:17:22 +0200, Jacopo Mondi wrote:
> When an unsupported stream roles is requested to
> generateConfiguration(), the function shall fail instead of simply
> ignoring the request.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index d1338b640e3c..aa7b7eb93aab 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -568,7 +568,8 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,
>  		default:
>  			LOG(RPI, Error) << "Requested stream role not supported: "
>  					<< role;
> -			break;
> +			delete config;
> +			return nullptr;
>  		}
>  
>  		if (rawCount > 1 || outCount > 2) {
> -- 
> 2.27.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart June 28, 2020, 11:29 p.m. UTC | #2
Hi Jacopo,

Thank you for the patch.

On Sun, Jun 28, 2020 at 06:17:22PM +0200, Jacopo Mondi wrote:
> When an unsupported stream roles is requested to
> generateConfiguration(), the function shall fail instead of simply
> ignoring the request.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index d1338b640e3c..aa7b7eb93aab 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -568,7 +568,8 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,
>  		default:
>  			LOG(RPI, Error) << "Requested stream role not supported: "
>  					<< role;
> -			break;
> +			delete config;
> +			return nullptr;
>  		}
>  
>  		if (rawCount > 1 || outCount > 2) {

Patch

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index d1338b640e3c..aa7b7eb93aab 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -568,7 +568,8 @@  CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,
 		default:
 			LOG(RPI, Error) << "Requested stream role not supported: "
 					<< role;
-			break;
+			delete config;
+			return nullptr;
 		}
 
 		if (rawCount > 1 || outCount > 2) {