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>
This commit is contained in:
parent
124aaffde0
commit
8897260976
2 changed files with 22 additions and 0 deletions
|
@ -28,6 +28,7 @@ public:
|
||||||
std::shared_ptr<Camera> get(const std::string &name);
|
std::shared_ptr<Camera> get(const std::string &name);
|
||||||
|
|
||||||
void addCamera(std::shared_ptr<Camera> camera);
|
void addCamera(std::shared_ptr<Camera> camera);
|
||||||
|
void removeCamera(Camera *camera);
|
||||||
|
|
||||||
static CameraManager *instance();
|
static CameraManager *instance();
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,27 @@ void CameraManager::addCamera(std::shared_ptr<Camera> camera)
|
||||||
cameras_.push_back(std::move(camera));
|
cameras_.push_back(std::move(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
|
* \brief Retrieve the camera manager instance
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue