android: Return -EUSERS when failed to open a Camera that's in use
The correct return value for the HAL for hal_dev_open() when trying to open a camera that's already opened is EUSERS. Make hal_dev_open() return -EUSERS, and plumb the logic for this through CameraHalManager::open(). This allows the following CTS tests to pass: - android.hardware.camera2.cts.CameraManagerTest#testCameraManagerOpenAllCameras - android.hardware.camera2.cts.MultiViewTest#testDualCameraPreview Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
67e791373d
commit
500c9a1f98
3 changed files with 13 additions and 10 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue