summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/android')
-rw-r--r--src/android/camera_device.cpp7
-rw-r--r--src/android/camera_device.h5
-rw-r--r--src/android/camera_hal_manager.cpp4
-rw-r--r--src/android/camera_hal_manager.h2
4 files changed, 14 insertions, 4 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 3419236a..de6f86f7 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -233,6 +233,13 @@ CameraDevice::~CameraDevice()
delete it.second;
}
+std::shared_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);
+}
+
/*
* Initialize the camera static information.
* This method is called before the camera device is opened.
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index 7be9e119..3e472c71 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -47,7 +47,8 @@ struct CameraStream {
class CameraDevice : protected libcamera::Loggable
{
public:
- CameraDevice(unsigned int id, const std::shared_ptr<libcamera::Camera> &camera);
+ static std::shared_ptr<CameraDevice> create(unsigned int id,
+ const std::shared_ptr<libcamera::Camera> &cam);
~CameraDevice();
int initialize();
@@ -72,6 +73,8 @@ protected:
std::string logPrefix() const override;
private:
+ CameraDevice(unsigned int id, const std::shared_ptr<libcamera::Camera> &camera);
+
struct Camera3RequestDescriptor {
Camera3RequestDescriptor(unsigned int frameNumber,
unsigned int numBuffers);
diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp
index 3d6d2b45..3a744af5 100644
--- a/src/android/camera_hal_manager.cpp
+++ b/src/android/camera_hal_manager.cpp
@@ -64,12 +64,12 @@ int CameraHalManager::init()
*/
unsigned int index = 0;
for (auto &cam : cameraManager_->cameras()) {
- CameraDevice *camera = new CameraDevice(index, cam);
+ std::shared_ptr<CameraDevice> camera = CameraDevice::create(index, cam);
ret = camera->initialize();
if (ret)
continue;
- cameras_.emplace_back(camera);
+ cameras_.emplace_back(std::move(camera));
++index;
}
diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h
index a582f042..3e34d63f 100644
--- a/src/android/camera_hal_manager.h
+++ b/src/android/camera_hal_manager.h
@@ -36,7 +36,7 @@ private:
libcamera::CameraManager *cameraManager_;
const camera_module_callbacks_t *callbacks_;
- std::vector<std::unique_ptr<CameraDevice>> cameras_;
+ std::vector<std::shared_ptr<CameraDevice>> cameras_;
};
#endif /* __ANDROID_CAMERA_MANAGER_H__ */