libcamera: pipeline_handler: Don't index factories by name
Pipeline handler factories are register in a map indexed by their name, and the list of names is used to expose the factories and look them up. This is unnecessary cumbersome, we can instead store factories in a vector and expose it directly. The pipeline factory users will still have access to the factory names through the factory name() function. The PipelineHandlerFactory::create() method becomes so simple that it can be inlined in its single caller, removing the unneeded usage of the DeviceEnumerator in the factory. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
@@ -74,20 +74,24 @@ int CameraManager::start()
|
||||
* file and only fallback on all handlers if there is no
|
||||
* configuration file.
|
||||
*/
|
||||
std::vector<std::string> handlers = PipelineHandlerFactory::handlers();
|
||||
|
||||
for (std::string const &handler : handlers) {
|
||||
PipelineHandler *pipe;
|
||||
std::vector<PipelineHandlerFactory *> &handlers = PipelineHandlerFactory::handlers();
|
||||
|
||||
for (PipelineHandlerFactory *factory : handlers) {
|
||||
/*
|
||||
* Try each pipeline handler until it exhaust
|
||||
* all pipelines it can provide.
|
||||
*/
|
||||
do {
|
||||
pipe = PipelineHandlerFactory::create(handler, enumerator_);
|
||||
if (pipe)
|
||||
pipes_.push_back(pipe);
|
||||
} while (pipe);
|
||||
while (1) {
|
||||
PipelineHandler *pipe = factory->create();
|
||||
if (!pipe->match(enumerator_)) {
|
||||
delete pipe;
|
||||
break;
|
||||
}
|
||||
|
||||
LOG(Debug) << "Pipeline handler \"" << factory->name()
|
||||
<< "\" matched";
|
||||
pipes_.push_back(pipe);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: register hot-plug callback here */
|
||||
|
||||
Reference in New Issue
Block a user