[libcamera-devel] [PATCH v7 9/9] libcamera: camera_manager: Enforce unique camera IDs
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Aug 4 20:56:40 CEST 2020
Hi Niklas,
Thank you for the patch.
On Tue, Aug 04, 2020 at 06:13:58PM +0200, Niklas Söderlund wrote:
> The camera ID is documented that it should be unique but it's not
> enforced. Change this by refusing to add cameras to the CameraManager
> that would create two cameras with the exact same ID.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> * Changes since v5
> - Rename 'name' to 'id'.
> - Make error Fatal.
>
> * Changes since v4
> - Update string in error message.
>
> * Changes since v3
> - Update commit message.
> ---
> src/libcamera/camera_manager.cpp | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
> index 76543b6aac8df9c4..47d56256abd6d490 100644
> --- a/src/libcamera/camera_manager.cpp
> +++ b/src/libcamera/camera_manager.cpp
> @@ -182,10 +182,10 @@ void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera,
>
> for (std::shared_ptr<Camera> c : cameras_) {
> if (c->id() == camera->id()) {
> - LOG(Camera, Warning)
> - << "Registering camera with duplicate ID '"
> + LOG(Camera, Fatal)
> + << "Trying to register a camera with a duplicated ID '"
> << camera->id() << "'";
> - break;
> + return;
> }
> }
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list