summaryrefslogtreecommitdiffstats
path: root/camera/ANativeWindowDisplayAdapter.cpp
diff options
context:
space:
mode:
authorSundar Raman <sunds@ti.com>2011-09-25 23:10:19 -0700
committerIliyan Malchev <malchev@google.com>2011-09-27 17:33:06 -0700
commitb3fb1a45ce906ab0365f247caf596665ea0c9f39 (patch)
treed70eef52ead1e65ce2b2de3e07de073226cf61a2 /camera/ANativeWindowDisplayAdapter.cpp
parent4af5978e0677b13118611721f265e2dbaba849ff (diff)
downloadhardware_ti_omap4xxx-b3fb1a45ce906ab0365f247caf596665ea0c9f39.zip
hardware_ti_omap4xxx-b3fb1a45ce906ab0365f247caf596665ea0c9f39.tar.gz
hardware_ti_omap4xxx-b3fb1a45ce906ab0365f247caf596665ea0c9f39.tar.bz2
CameraHAL: Improved error handling inside the adapters
1. unlock and cancel buffers to ANativeWindow when freeBuffers is called 2. Free the omx handle and deinitialize DOMX when errors occur while calling critical OMXCamera apis 3. Retry OMX_GetHandle if it fails to take care of error recovery scenarios. "Fixes b/5379663" Change-Id: I4729fab40e6104dfa6660ba6f6b1a90f805c2f59 Signed-off-by: Sundar Raman <sunds@ti.com>
Diffstat (limited to 'camera/ANativeWindowDisplayAdapter.cpp')
-rw-r--r--camera/ANativeWindowDisplayAdapter.cpp98
1 files changed, 60 insertions, 38 deletions
diff --git a/camera/ANativeWindowDisplayAdapter.cpp b/camera/ANativeWindowDisplayAdapter.cpp
index 8b2bb9e..cb325cc 100644
--- a/camera/ANativeWindowDisplayAdapter.cpp
+++ b/camera/ANativeWindowDisplayAdapter.cpp
@@ -465,35 +465,17 @@ int ANativeWindowDisplayAdapter::disableDisplay(bool cancel_buffer)
if(cancel_buffer)
{
- if (mANativeWindow)
- for(unsigned int i = 0; i < mFramesWithCameraAdapterMap.size(); i++) {
- int value = mFramesWithCameraAdapterMap.valueAt(i);
-
- // unlock buffer before giving it up
- mapper.unlock((buffer_handle_t) mGrallocHandleMap[value]);
-
- ret = mANativeWindow->cancel_buffer(mANativeWindow, mBufferHandleMap[value]);
- if ( ENODEV == ret ) {
- CAMHAL_LOGEA("Preview surface abandoned!");
- mANativeWindow = NULL;
- return -ret;
- } else if ( NO_ERROR != ret ) {
- CAMHAL_LOGEB("cancel_buffer() failed: %s (%d)",
- strerror(-ret),
- -ret);
- return -ret;
- }
- }
- else
- LOGE("mANativeWindow is NULL");
+ // Return the buffers to ANativeWindow here, the mFramesWithCameraAdapterMap is also cleared inside
+ returnBuffersToWindow();
}
else
{
mANativeWindow = NULL;
+ // Clear the frames with camera adapter map
+ mFramesWithCameraAdapterMap.clear();
}
- ///Clear the frames with camera adapter map
- mFramesWithCameraAdapterMap.clear();
+
}
LOG_FUNCTION_NAME_EXIT;
@@ -565,23 +547,21 @@ void* ANativeWindowDisplayAdapter::allocateBuffer(int width, int height, const c
}
CAMHAL_LOGDB("Number of buffers set to ANativeWindow %d", numBufs);
- //if(mBufferCount != numBufs)
- // {
- ///Set the number of buffers needed for camera preview
- err = mANativeWindow->set_buffer_count(mANativeWindow, numBufs);
- if (err != 0) {
- LOGE("native_window_set_buffer_count failed: %s (%d)", strerror(-err), -err);
-
- if ( ENODEV == err ) {
- CAMHAL_LOGEA("Preview surface abandoned!");
- mANativeWindow = NULL;
- }
+ ///Set the number of buffers needed for camera preview
+ err = mANativeWindow->set_buffer_count(mANativeWindow, numBufs);
+ if (err != 0) {
+ LOGE("native_window_set_buffer_count failed: %s (%d)", strerror(-err), -err);
- return NULL;
+ if ( ENODEV == err ) {
+ CAMHAL_LOGEA("Preview surface abandoned!");
+ mANativeWindow = NULL;
}
- CAMHAL_LOGDB("Configuring %d buffers for ANativeWindow", numBufs);
- mBufferCount = numBufs;
- //}
+
+ return NULL;
+ }
+ CAMHAL_LOGDB("Configuring %d buffers for ANativeWindow", numBufs);
+ mBufferCount = numBufs;
+
// Set window geometry
err = mANativeWindow->set_buffers_geometry(
@@ -817,11 +797,50 @@ int ANativeWindowDisplayAdapter::getFd()
}
+status_t ANativeWindowDisplayAdapter::returnBuffersToWindow()
+{
+ status_t ret = NO_ERROR;
+
+ GraphicBufferMapper &mapper = GraphicBufferMapper::get();
+ //Give the buffers back to display here - sort of free it
+ if (mANativeWindow)
+ for(unsigned int i = 0; i < mFramesWithCameraAdapterMap.size(); i++) {
+ int value = mFramesWithCameraAdapterMap.valueAt(i);
+
+ // unlock buffer before giving it up
+ mapper.unlock((buffer_handle_t) mGrallocHandleMap[value]);
+
+ ret = mANativeWindow->cancel_buffer(mANativeWindow, mBufferHandleMap[value]);
+ if ( ENODEV == ret ) {
+ CAMHAL_LOGEA("Preview surface abandoned!");
+ mANativeWindow = NULL;
+ return -ret;
+ } else if ( NO_ERROR != ret ) {
+ CAMHAL_LOGEB("cancel_buffer() failed: %s (%d)",
+ strerror(-ret),
+ -ret);
+ return -ret;
+ }
+ }
+ else
+ LOGE("mANativeWindow is NULL");
+
+ ///Clear the frames with camera adapter map
+ mFramesWithCameraAdapterMap.clear();
+
+ return ret;
+
+}
+
int ANativeWindowDisplayAdapter::freeBuffer(void* buf)
{
LOG_FUNCTION_NAME;
int *buffers = (int *) buf;
+ status_t ret = NO_ERROR;
+
+ Mutex::Autolock lock(mLock);
+
if((int *)mGrallocHandleMap != buffers)
{
CAMHAL_LOGEA("CameraHal passed wrong set of buffers to free!!!");
@@ -830,6 +849,9 @@ int ANativeWindowDisplayAdapter::freeBuffer(void* buf)
mGrallocHandleMap = NULL;
}
+
+ returnBuffersToWindow();
+
if ( NULL != buf )
{
delete [] buffers;