summaryrefslogtreecommitdiffstats
path: root/camera/ANativeWindowDisplayAdapter.cpp
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2011-08-31 10:24:52 +0300
committerIliyan Malchev <malchev@google.com>2011-08-31 20:02:33 -0700
commit97e6bcc45eb2161c10761abc4fbf12ce3e1d52c8 (patch)
tree6932d10347af4c221600530bcf4c27ab14793b5f /camera/ANativeWindowDisplayAdapter.cpp
parentb2fb762fda58b35be6da475582e3f623f9f1e46a (diff)
downloadhardware_ti_omap4xxx-97e6bcc45eb2161c10761abc4fbf12ce3e1d52c8.zip
hardware_ti_omap4xxx-97e6bcc45eb2161c10761abc4fbf12ce3e1d52c8.tar.gz
hardware_ti_omap4xxx-97e6bcc45eb2161c10761abc4fbf12ce3e1d52c8.tar.bz2
CameraHAL: Fixes memory leaks inside ANativeWindowDisplayAdapter
- Every call to 'allocateBuffer()' is allocating a 'buffers' array on the heap, which is never used and never released. - Every call to 'setFrameProvider()' is instantiating a new FrameProvider instance, which is never released. Change-Id: I73ee9d35d9cb32709078334d199932fe78c2b7bb Original-author: Emilian Peev <epeev@mm-sol.com> Signed-off-by: Emilian Peev <epeev@mm-sol.com> Signed-off-by: Tyler Luu <tluu@ti.com>
Diffstat (limited to 'camera/ANativeWindowDisplayAdapter.cpp')
-rw-r--r--camera/ANativeWindowDisplayAdapter.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/camera/ANativeWindowDisplayAdapter.cpp b/camera/ANativeWindowDisplayAdapter.cpp
index 4942193..3c9396b 100644
--- a/camera/ANativeWindowDisplayAdapter.cpp
+++ b/camera/ANativeWindowDisplayAdapter.cpp
@@ -194,10 +194,11 @@ ANativeWindowDisplayAdapter::~ANativeWindowDisplayAdapter()
LOG_FUNCTION_NAME;
///If Frame provider exists
- if(mFrameProvider)
- {
+ if (mFrameProvider) {
// Unregister with the frame provider
mFrameProvider->disableFrameNotification(CameraFrame::ALL_FRAMES);
+ delete mFrameProvider;
+ mFrameProvider = NULL;
}
///The ANativeWindow object will get destroyed here
@@ -284,13 +285,17 @@ int ANativeWindowDisplayAdapter::setFrameProvider(FrameNotifier *frameProvider)
LOG_FUNCTION_NAME;
// Check for NULL pointer
- if ( !frameProvider )
- {
+ if ( !frameProvider ) {
CAMHAL_LOGEA("NULL passed for frame provider");
LOG_FUNCTION_NAME_EXIT;
return BAD_VALUE;
}
+ //Release any previous frame providers
+ if ( NULL != mFrameProvider ) {
+ delete mFrameProvider;
+ }
+
/** Dont do anything here, Just save the pointer for use when display is
actually enabled or disabled
*/
@@ -534,7 +539,6 @@ void* ANativeWindowDisplayAdapter::allocateBuffer(int width, int height, const c
status_t err;
int i = -1;
const int lnumBufs = numBufs;
- int32_t *buffers = new int32_t[lnumBufs];
mBufferHandleMap = new buffer_handle_t*[lnumBufs];
mGrallocHandleMap = new IMG_native_handle_t*[lnumBufs];
int undequeued = 0;
@@ -599,11 +603,10 @@ void* ANativeWindowDisplayAdapter::allocateBuffer(int width, int height, const c
///We just return the buffers from ANativeWindow, if the width and height are same, else (vstab, vnf case)
///re-allocate buffers using ANativeWindow and then get them
///@todo - Re-allocate buffers for vnf and vstab using the width, height, format, numBufs etc
- if ( (buffers == NULL) || (mBufferHandleMap == NULL) )
+ if ( mBufferHandleMap == NULL )
{
CAMHAL_LOGEA("Couldn't create array for ANativeWindow buffers");
LOG_FUNCTION_NAME_EXIT;
- delete [] buffers;
return NULL;
}
@@ -637,7 +640,6 @@ void* ANativeWindowDisplayAdapter::allocateBuffer(int width, int height, const c
bytes = getBufSize(format, width, height);
- CAMHAL_LOGDB("Adding buffer index=%d, address=0x%x", i, buffers[i]);
}
// lock the initial queueable buffers
@@ -694,10 +696,6 @@ void* ANativeWindowDisplayAdapter::allocateBuffer(int width, int height, const c
mFramesWithCameraAdapterMap.removeItem((int) mGrallocHandleMap[start]);
}
CAMHAL_LOGEA("Error occurred, performing cleanup");
- if ( buffers )
- {
- delete [] buffers;
- }
if ( NULL != mErrorNotifier.get() )
{