summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/android/camera_device.cpp5
-rw-r--r--src/android/camera_device.h2
-rw-r--r--src/android/camera_hal_manager.cpp10
-rw-r--r--src/android/camera_hal_manager.h2
4 files changed, 8 insertions, 11 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 72a89258..d0955de7 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -350,11 +350,10 @@ CameraDevice::~CameraDevice()
delete it.second;
}
-std::shared_ptr<CameraDevice> CameraDevice::create(unsigned int id,
+std::unique_ptr<CameraDevice> CameraDevice::create(unsigned int id,
const std::shared_ptr<Camera> &cam)
{
- CameraDevice *camera = new CameraDevice(id, cam);
- return std::shared_ptr<CameraDevice>(camera);
+ return std::unique_ptr<CameraDevice>(new CameraDevice(id, cam));
}
/*
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index 823d561c..8be7f305 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -32,7 +32,7 @@
class CameraDevice : protected libcamera::Loggable
{
public:
- static std::shared_ptr<CameraDevice> create(unsigned int id,
+ static std::unique_ptr<CameraDevice> create(unsigned int id,
const std::shared_ptr<libcamera::Camera> &cam);
~CameraDevice();
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,
diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h
index 24bf716c..3cf31f4e 100644
--- a/src/android/camera_hal_manager.h
+++ b/src/android/camera_hal_manager.h
@@ -52,7 +52,7 @@ private:
libcamera::CameraManager *cameraManager_;
const camera_module_callbacks_t *callbacks_;
- std::vector<std::shared_ptr<CameraDevice>> cameras_;
+ std::vector<std::unique_ptr<CameraDevice>> cameras_;
std::map<std::string, unsigned int> cameraIdsMap_;
Mutex mutex_;