summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/android/camera3_hal.cpp4
-rw-r--r--src/android/camera_hal_manager.cpp15
-rw-r--r--src/android/camera_hal_manager.h4
3 files changed, 13 insertions, 10 deletions
diff --git a/src/android/camera3_hal.cpp b/src/android/camera3_hal.cpp
index d6e04af2..08773d33 100644
--- a/src/android/camera3_hal.cpp
+++ b/src/android/camera3_hal.cpp
@@ -77,11 +77,11 @@ static int hal_dev_open(const hw_module_t *module, const char *name,
LOG(HAL, Debug) << "Open camera " << name;
int id = atoi(name);
- CameraDevice *camera = cameraManager.open(id, module);
+ auto [camera, ret] = cameraManager.open(id, module);
if (!camera) {
LOG(HAL, Error)
<< "Failed to open camera module '" << id << "'";
- return -ENODEV;
+ return ret == -EBUSY ? -EUSERS : ret;
}
*device = &camera->camera3Device()->common;
diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp
index 189eda2b..aeff14bd 100644
--- a/src/android/camera_hal_manager.cpp
+++ b/src/android/camera_hal_manager.cpp
@@ -65,28 +65,29 @@ int CameraHalManager::init()
return 0;
}
-CameraDevice *CameraHalManager::open(unsigned int id,
- const hw_module_t *hardwareModule)
+std::tuple<CameraDevice *, int>
+CameraHalManager::open(unsigned int id, const hw_module_t *hardwareModule)
{
MutexLocker locker(mutex_);
if (!callbacks_) {
LOG(HAL, Error) << "Can't open camera before callbacks are set";
- return nullptr;
+ return { nullptr, -ENODEV };
}
CameraDevice *camera = cameraDeviceFromHalId(id);
if (!camera) {
LOG(HAL, Error) << "Invalid camera id '" << id << "'";
- return nullptr;
+ return { nullptr, -ENODEV };
}
- if (camera->open(hardwareModule))
- return nullptr;
+ int ret = camera->open(hardwareModule);
+ if (ret)
+ return { nullptr, ret };
LOG(HAL, Info) << "Open camera '" << id << "'";
- return camera;
+ return { camera, 0 };
}
void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)
diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h
index a91decc7..24bf716c 100644
--- a/src/android/camera_hal_manager.h
+++ b/src/android/camera_hal_manager.h
@@ -10,6 +10,7 @@
#include <map>
#include <mutex>
#include <stddef.h>
+#include <tuple>
#include <vector>
#include <hardware/camera_common.h>
@@ -28,7 +29,8 @@ public:
int init();
- CameraDevice *open(unsigned int id, const hw_module_t *module);
+ std::tuple<CameraDevice *, int>
+ open(unsigned int id, const hw_module_t *module);
unsigned int numCameras() const;
int getCameraInfo(unsigned int id, struct camera_info *info);