libcamera: camera: Associate cameras with their pipeline handler

The PipelineHandler which creates a Camera is responsible for serving
any operation requested by the user. In order forward the public API
calls, the camera needs to store a reference to its pipeline handler.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes since v1:

- Create pipeline handlers is shared pointers, make them inherit from
  std::enable_shared_from_this<> and stored them in shared pointers.
This commit is contained in:
Niklas Söderlund
2019-01-24 22:24:11 +02:00
committed by Laurent Pinchart
parent a29b7fc7d5
commit 5b02e03199
9 changed files with 44 additions and 31 deletions
+9 -8
View File
@@ -98,16 +98,14 @@ int CameraManager::start()
* all pipelines it can provide.
*/
while (1) {
PipelineHandler *pipe = factory->create(this);
if (!pipe->match(enumerator_.get())) {
delete pipe;
std::shared_ptr<PipelineHandler> pipe = factory->create(this);
if (!pipe->match(enumerator_.get()))
break;
}
LOG(Camera, Debug)
<< "Pipeline handler \"" << factory->name()
<< "\" matched";
pipes_.push_back(pipe);
pipes_.push_back(std::move(pipe));
}
}
@@ -130,10 +128,13 @@ void CameraManager::stop()
{
/* TODO: unregister hot-plug callback here */
for (PipelineHandler *pipe : pipes_)
delete pipe;
/*
* Release all references to cameras and pipeline handlers to ensure
* they all get destroyed before the device enumerator deletes the
* media devices.
*/
pipes_.clear();
cameras_.clear();
enumerator_.reset(nullptr);
}