diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-01-24 01:55:17 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-01-24 22:24:15 +0200 |
commit | 889726097613ae5ed4d83a6fd0cc3b0b562f8659 (patch) | |
tree | f8478c93c38ee0e0d6c0f724e2beec75bab7d976 /src | |
parent | 124aaffde0b25d847442876beb16600d448d9feb (diff) |
libcamera: camera_manager: Add method to unregister a camera
The new removeCamera() method is meant to be used by pipeline handlers
to unregister a camera in case of device disconnection.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/camera_manager.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 3eccf20c..f90201ad 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -192,6 +192,27 @@ void CameraManager::addCamera(std::shared_ptr<Camera> camera) } /** + * \brief Remove a camera from the camera manager + * \param[in] camera The camera to be removed + * + * This function is called by pipeline handlers to unregister cameras from the + * camera manager. Unregistered cameras won't be reported anymore by the + * cameras() and get() calls, but references may still exist in applications. + */ +void CameraManager::removeCamera(Camera *camera) +{ + for (auto iter = cameras_.begin(); iter != cameras_.end(); ++iter) { + if (iter->get() == camera) { + LOG(Camera, Debug) + << "Unregistering camera '" + << camera->name() << "'"; + cameras_.erase(iter); + return; + } + } +} + +/** * \brief Retrieve the camera manager instance * * The CameraManager is a singleton and can't be constructed manually. This |