diff options
author | Anu Sundararajan <sanuradha@ti.com> | 2012-03-20 13:09:20 -0500 |
---|---|---|
committer | Daniel Levin <dendy@ti.com> | 2012-07-25 08:55:47 -0500 |
commit | 8ec2813f803f7a0b9260872cfa27ac2395478814 (patch) | |
tree | 840cc3c8d6cb7a799e22cf6cdb5a1b5b17ea6694 | |
parent | de6f9a2636a291726d3620048dfaa4786e218f56 (diff) | |
download | hardware_ti_omap4-8ec2813f803f7a0b9260872cfa27ac2395478814.zip hardware_ti_omap4-8ec2813f803f7a0b9260872cfa27ac2395478814.tar.gz hardware_ti_omap4-8ec2813f803f7a0b9260872cfa27ac2395478814.tar.bz2 |
CameraHal: Fixed minor bugs that were exposed while testing multiple instances of camera
CameraHal_Module: When there is an error, camera_get_camera_info should return a
negative value. If it returns NULL, the caller would interpret it as 0 which implies OK.
CameraProperties:
- The flag mInitialized must be set to true only if the properties were loaded successfully.
Previously, the flag was being set without checking the return value from loadProperties.
- Since loadProperties could be called more than once, it is important to initialize mCamerasSupported here.
- Added additional error handling. If for some reason, CameraAdapter_Capabilities returns
that 0 cameras are available, then it must be flagged as an error. This is possible when
one tries to query the properties while a camera is in use.
Change-Id: I15e9935735f8d2c548fb2f378a310650771c54e2
Signed-off-by: Anu Sundararajan <sanuradha@ti.com>
-rw-r--r-- | camera/CameraHal_Module.cpp | 3 | ||||
-rw-r--r-- | camera/CameraProperties.cpp | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/camera/CameraHal_Module.cpp b/camera/CameraHal_Module.cpp index 69a47f3..b107bc7 100644 --- a/camera/CameraHal_Module.cpp +++ b/camera/CameraHal_Module.cpp @@ -644,7 +644,8 @@ int camera_get_camera_info(int camera_id, struct camera_info *info) if(gCameraProperties.initialize() != android::NO_ERROR) { CAMHAL_LOGEA("Unable to create or initialize CameraProperties"); - return NULL; + rv = -EINVAL; + goto end; } //Get camera properties for camera index diff --git a/camera/CameraProperties.cpp b/camera/CameraProperties.cpp index 0664083..7d4034d 100644 --- a/camera/CameraProperties.cpp +++ b/camera/CameraProperties.cpp @@ -78,7 +78,9 @@ status_t CameraProperties::initialize() ret = loadProperties(); - mInitialized = 1; + if (ret == NO_ERROR) { + mInitialized = 1; + } LOG_FUNCTION_NAME_EXIT; @@ -95,6 +97,9 @@ status_t CameraProperties::loadProperties() status_t ret = NO_ERROR; + //Must be re-initialized here, since loadProperties() could potentially be called more than once. + mCamerasSupported = 0; + // adapter updates capabilities and we update camera count const status_t err = CameraAdapter_Capabilities(mCameraProps, mCamerasSupported, MAX_CAMERAS_SUPPORTED, mCamerasSupported); @@ -102,11 +107,14 @@ status_t CameraProperties::loadProperties() if(err != NO_ERROR) { LOGE("error while getting capabilities"); ret = UNKNOWN_ERROR; + } else if (mCamerasSupported == 0) { + LOGE("camera busy. properties not loaded. num_cameras = %d", mCamerasSupported); + ret = UNKNOWN_ERROR; } else if (mCamerasSupported > MAX_CAMERAS_SUPPORTED) { LOGE("returned too many adapaters"); ret = UNKNOWN_ERROR; } else { - LOGE("num_cameras = %d", mCamerasSupported); + LOGI("num_cameras = %d", mCamerasSupported); for (int i = 0; i < mCamerasSupported; i++) { mCameraProps[i].set(CAMERA_SENSOR_INDEX, i); |