diff options
author | Hirokazu Honda <hiroh@chromium.org> | 2021-05-26 17:46:28 +0900 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-05-26 23:41:43 +0300 |
commit | 459b3bc6a979a778f1689a86be3589101853977e (patch) | |
tree | 82a67fd29894b6997877935a183e206a54b52a8e /src/android/camera_hal_manager.cpp | |
parent | a8c9fce10952393d90fde5c954c7515f649e74eb (diff) |
android: CameraHalManager: Create a static object dynamically
Originally CameraHalManager is created in the libcamera start up
and destroyed in the libcamera termination. However,
CameraHalManager destructor can access other static objects that
has been destroyed.
Avoid this issue by destroying CameraHalManager when tear_down() is
called in ChromeOS or leaking it in other platforms.
Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
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 | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index f5b86974..54087d3a 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -37,6 +37,13 @@ CameraHalManager::CameraHalManager() /* CameraManager calls stop() in the destructor. */ CameraHalManager::~CameraHalManager() = default; +/* static */ +CameraHalManager *CameraHalManager::instance() +{ + static CameraHalManager *cameraHalManager = new CameraHalManager; + return cameraHalManager; +} + int CameraHalManager::init() { cameraManager_ = std::make_unique<CameraManager>(); |