summaryrefslogtreecommitdiff
path: root/src/libcamera/camera_manager.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-03 04:01:15 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-16 18:23:42 +0200
commit34018d23d751e4818ce407b8bec5bafb158c1bb6 (patch)
treecb7d09792c3859dcc7ccb784940e8dcf97d3b784 /src/libcamera/camera_manager.cpp
parenta5e86d4396ae7221e431a748559e56a8d024e43e (diff)
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>
Diffstat (limited to 'src/libcamera/camera_manager.cpp')
-rw-r--r--src/libcamera/camera_manager.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index be327f5d..91ef6753 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -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 */