libcamera: camera_manager: Enforce unique camera IDs

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@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Niklas Söderlund
2020-07-16 16:01:32 +02:00
parent 2e7c80a4f9
commit 673201c4d5

View File

@@ -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;
}
}