diff options
author | Hirokazu Honda <hiroh@chromium.org> | 2021-03-24 16:07:50 +0900 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-03-25 00:45:25 +0200 |
commit | 212f410c7c5cdacd18141d9b9234272fb55396d2 (patch) | |
tree | bcdd611c283a58cf9df68de83bbae36a127a3307 /src/android/camera_hal_manager.cpp | |
parent | 1d8cc0a3ec7dc04958fec12f4fdd05aabd2f7d06 (diff) |
android: CameraHalManager: Hold CameraDevice with std::unique_ptr
CameraDevice is owned by CameraHalManager. The ownership of the
object is not shared with other classes. So CameraHalManager
should manage CameraDevice with std::unique_ptr.
Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/android/camera_hal_manager.cpp')
-rw-r--r-- | src/android/camera_hal_manager.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index aeff14bd..79c5169e 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -36,8 +36,6 @@ CameraHalManager::CameraHalManager() CameraHalManager::~CameraHalManager() { - cameras_.clear(); - if (cameraManager_) { cameraManager_->stop(); delete cameraManager_; @@ -125,7 +123,7 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam) } /* Create a CameraDevice instance to wrap the libcamera Camera. */ - std::shared_ptr<CameraDevice> camera = CameraDevice::create(id, std::move(cam)); + std::unique_ptr<CameraDevice> camera = CameraDevice::create(id, std::move(cam)); int ret = camera->initialize(); if (ret) { LOG(HAL, Error) << "Failed to initialize camera: " << cam->id(); @@ -155,7 +153,7 @@ void CameraHalManager::cameraRemoved(std::shared_ptr<Camera> cam) MutexLocker locker(mutex_); auto iter = std::find_if(cameras_.begin(), cameras_.end(), - [&cam](std::shared_ptr<CameraDevice> &camera) { + [&cam](const std::unique_ptr<CameraDevice> &camera) { return cam == camera->camera(); }); if (iter == cameras_.end()) @@ -192,7 +190,7 @@ int32_t CameraHalManager::cameraLocation(const Camera *cam) CameraDevice *CameraHalManager::cameraDeviceFromHalId(unsigned int id) { auto iter = std::find_if(cameras_.begin(), cameras_.end(), - [id](std::shared_ptr<CameraDevice> &camera) { + [id](const std::unique_ptr<CameraDevice> &camera) { return camera->id() == id; }); if (iter == cameras_.end()) @@ -244,7 +242,7 @@ void CameraHalManager::setCallbacks(const camera_module_callbacks_t *callbacks) * Internal cameras are already assumed to be present at module load * time by the Android framework. */ - for (std::shared_ptr<CameraDevice> &camera : cameras_) { + for (const std::unique_ptr<CameraDevice> &camera : cameras_) { unsigned int id = camera->id(); if (id >= firstExternalCameraId_) callbacks_->camera_device_status_change(callbacks_, id, |