diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-01-22 16:47:40 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-01-25 01:59:28 +0200 |
commit | 607a9d7f5698fa514b66b0f0a53393fb8435ed12 (patch) | |
tree | 9d9ee3d111f0d877c9ca08c9a19a2abd5f8e45cf /src/libcamera/pipeline/ipu3 | |
parent | 889726097613ae5ed4d83a6fd0cc3b0b562f8659 (diff) |
libcamera: pipeline_handler: Add camera disconnection support
Pipeline handlers are responsible for creating camera instances, but
also for destroying them when devices are unplugged. As camera objects
are reference-counted this isn't a straightforward operation and
involves the camera manager and camera object itself. Add two helper
methods in the PipelineHandler base class to register a camera and to
register a media device with the pipeline handler.
When registering a camera, the registerCamera() helper method will add
it to the camera manager. When registering a media device, the
registerMediaDevice() helper method will listen to device disconnection
events, and disconnect all cameras created by the pipeline handler as a
response.
Under the hood the PipelineHandler class needs to keep track of
registered cameras in order to handle disconnection. They can't be
stored as shared pointers as this would create a circular dependency
(the Camera class owns a shared pointer to the pipeline handler). Store
them as weak pointers instead. This is safe as a reference to the camera
is stored in the camera manager, and doesn't get removed until the
camera is unregistered from the manager by the PipelineHandler.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline/ipu3')
-rw-r--r-- | src/libcamera/pipeline/ipu3/ipu3.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 9831f74f..3161e714 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -9,7 +9,6 @@ #include <vector> #include <libcamera/camera.h> -#include <libcamera/camera_manager.h> #include "device_enumerator.h" #include "log.h" @@ -169,7 +168,7 @@ void PipelineHandlerIPU3::registerCameras() std::string cameraName = sensor->name() + " " + std::to_string(id); std::shared_ptr<Camera> camera = Camera::create(this, cameraName); - manager_->addCamera(std::move(camera)); + registerCamera(std::move(camera)); LOG(IPU3, Info) << "Registered Camera[" << numCameras << "] \"" |