diff options
Diffstat (limited to 'camera/CameraProperties.cpp')
-rw-r--r-- | camera/CameraProperties.cpp | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/camera/CameraProperties.cpp b/camera/CameraProperties.cpp index 5d3ff20..93bc953 100644 --- a/camera/CameraProperties.cpp +++ b/camera/CameraProperties.cpp @@ -21,16 +21,13 @@ * */ -//#include "CameraHal.h" -#include <utils/threads.h> - -#include "DebugUtils.h" #include "CameraProperties.h" #define CAMERA_ROOT "CameraRoot" #define CAMERA_INSTANCE "CameraInstance" -namespace android { +namespace Ti { +namespace Camera { // lower entries have higher priority static const char* g_camera_adapters[] = { @@ -71,23 +68,24 @@ status_t CameraProperties::initialize() status_t ret; - Mutex::Autolock lock(mLock); + android::AutoMutex lock(mLock); if(mInitialized) return NO_ERROR; ret = loadProperties(); - mInitialized = 1; + if (ret == NO_ERROR) { + mInitialized = 1; + } LOG_FUNCTION_NAME_EXIT; return ret; } -extern "C" int CameraAdapter_Capabilities(CameraProperties::Properties* properties_array, - const unsigned int starting_camera, - const unsigned int max_camera); +extern "C" status_t CameraAdapter_Capabilities(CameraProperties::Properties* properties_array, + int starting_camera, int max_camera, int & supported_cameras); ///Loads all the Camera related properties status_t CameraProperties::loadProperties() @@ -96,25 +94,32 @@ 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 - mCamerasSupported = CameraAdapter_Capabilities(mCameraProps, mCamerasSupported, MAX_CAMERAS_SUPPORTED); + const status_t err = CameraAdapter_Capabilities(mCameraProps, mCamerasSupported, + MAX_CAMERAS_SUPPORTED, mCamerasSupported); - if((int)mCamerasSupported < 0) { - ALOGE("error while getting capabilities"); + if(err != NO_ERROR) { + CAMHAL_LOGE("error while getting capabilities"); + ret = UNKNOWN_ERROR; + } else if (mCamerasSupported == 0) { + CAMHAL_LOGE("camera busy. properties not loaded. num_cameras = %d", mCamerasSupported); ret = UNKNOWN_ERROR; } else if (mCamerasSupported > MAX_CAMERAS_SUPPORTED) { - ALOGE("returned too many adapaters"); + CAMHAL_LOGE("returned too many adapaters"); ret = UNKNOWN_ERROR; } else { - ALOGE("num_cameras = %d", mCamerasSupported); + CAMHAL_LOGI("num_cameras = %d", mCamerasSupported); - for (unsigned int i = 0; i < mCamerasSupported; i++) { - mCameraProps[i].set(CAMERA_SENSOR_INDEX, i); + for (int i = 0; i < mCamerasSupported; i++) { + mCameraProps[i].setSensorIndex(i); mCameraProps[i].dump(); } } - ALOGV("mCamerasSupported = %d", mCamerasSupported); + CAMHAL_LOGV("mCamerasSupported = %d", mCamerasSupported); LOG_FUNCTION_NAME_EXIT; return ret; } @@ -126,4 +131,5 @@ int CameraProperties::camerasSupported() return mCamerasSupported; } -}; +} // namespace Camera +} // namespace Ti |