diff options
author | Tyler Luu <tluu@ti.com> | 2011-10-05 23:32:09 -0500 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2011-10-07 09:38:51 -0700 |
commit | 9a412956d5327ec851ff8adc3e9804640fa30c7f (patch) | |
tree | b488adec634153f56e0199962b32d5fe48f4b3e2 /camera/V4LCameraAdapter | |
parent | 3ce041c37296bf7aabef099f49980277eb00b7a3 (diff) | |
download | hardware_ti_omap4xxx-9a412956d5327ec851ff8adc3e9804640fa30c7f.zip hardware_ti_omap4xxx-9a412956d5327ec851ff8adc3e9804640fa30c7f.tar.gz hardware_ti_omap4xxx-9a412956d5327ec851ff8adc3e9804640fa30c7f.tar.bz2 |
CameraHal: Allow only certain number of instances
1) Protect against simultaneous access to camera_device_open
2) Set a value of MAX_SIMUL_CAMERAS_SUPPORTED to dictate number
of simultaneous cameras that can be open at once. Set to 1 for
now in this patch. Return error if more is requested.
3) Change OMXCameraAdapter to allocate new instance for each
factory create call.
4) Add lock to capabalities factory function in OMXCameraAdapter
to protected against multiple OMXCamera GetHandles...
b/5401791 b/5404200 b/5405235
Change-Id: I179d493f8070d228877ebfac637047978afc7d55
Signed-off-by: Tyler Luu <tluu@ti.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
Diffstat (limited to 'camera/V4LCameraAdapter')
-rw-r--r-- | camera/V4LCameraAdapter/V4LCameraAdapter.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp index 446a809..3fb3380 100644 --- a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -55,14 +55,13 @@ namespace android { //frames skipped before recalculating the framerate #define FPS_PERIOD 30 -static V4LCameraAdapter *gCameraAdapter = NULL; Mutex gAdapterLock; const char *device = DEVICE; /*--------------------Camera Adapter Class STARTS here-----------------------------*/ -status_t V4LCameraAdapter::initialize(CameraProperties::Properties* caps, int sensor_index) +status_t V4LCameraAdapter::initialize(CameraProperties::Properties* caps) { LOG_FUNCTION_NAME; @@ -483,7 +482,7 @@ void V4LCameraAdapter::onOrientationEvent(uint32_t orientation, uint32_t tilt) } -V4LCameraAdapter::V4LCameraAdapter() +V4LCameraAdapter::V4LCameraAdapter(size_t sensor_index) { LOG_FUNCTION_NAME; @@ -563,24 +562,21 @@ int V4LCameraAdapter::previewThread() extern "C" CameraAdapter* CameraAdapter_Factory() { + CameraAdapter *adapter = NULL; Mutex::Autolock lock(gAdapterLock); LOG_FUNCTION_NAME; - if ( NULL == gCameraAdapter ) - { - CAMHAL_LOGDA("Creating new Camera adapter instance"); - gCameraAdapter= new V4LCameraAdapter(); - } - else - { - CAMHAL_LOGDA("Reusing existing Camera adapter instance"); - } - + adapter = new V4LCameraAdapter(sensor_index); + if ( adapter ) { + CAMHAL_LOGDB("New OMX Camera adapter instance created for sensor %d",sensor_index); + } else { + CAMHAL_LOGEA("Camera adapter create failed!"); + } LOG_FUNCTION_NAME_EXIT; - return gCameraAdapter; + return adapter; } extern "C" int CameraAdapter_Capabilities(CameraProperties::Properties* properties_array, |