libcamera: pipeline: Fail match() when no camera is registered
The rkisp1 and simple pipeline handlers can fail to register any camera, if initialization of all the detected cameras fail. In that case, they still return success from their match function. As no camera gets registered, the pipeline handler is immediately destroyed, releasing the acquired media devices, and the camera manager immediately tries to match the same pipeline handler with the same media device, causing an endless loop. Fix it by returning false from the match function if no camera gets registered. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Tested-by: Andrey Konovalov <andrey.konovalov@linaro.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
@@ -1107,10 +1107,13 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)
|
||||
if (!pad)
|
||||
return false;
|
||||
|
||||
for (MediaLink *link : pad->links())
|
||||
createCamera(link->source()->entity());
|
||||
bool registered = false;
|
||||
for (MediaLink *link : pad->links()) {
|
||||
if (!createCamera(link->source()->entity()))
|
||||
registered = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return registered;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
||||
@@ -821,6 +821,8 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)
|
||||
}
|
||||
|
||||
/* Initialize each pipeline and register a corresponding camera. */
|
||||
bool registered = false;
|
||||
|
||||
for (std::unique_ptr<SimpleCameraData> &data : pipelines) {
|
||||
int ret = data->init();
|
||||
if (ret < 0)
|
||||
@@ -830,9 +832,10 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)
|
||||
Camera::create(this, data->sensor_->id(),
|
||||
data->streams());
|
||||
registerCamera(std::move(camera), std::move(data));
|
||||
registered = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return registered;
|
||||
}
|
||||
|
||||
V4L2VideoDevice *SimplePipelineHandler::video(const MediaEntity *entity)
|
||||
|
||||
Reference in New Issue
Block a user