summaryrefslogtreecommitdiffstats
path: root/camera/MemoryManager.cpp
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2012-06-12 17:03:30 +0300
committerDaniel Levin <dendy@ti.com>2012-07-25 08:56:43 -0500
commit8bae9523b8df3d3a65d2fea0c9ec4f3afd9b9bc0 (patch)
treec93bd5355ce1463951a8a24bcdb29eb4fcacbb4a /camera/MemoryManager.cpp
parentc4b947c5581d346dc469a7a465f645fd50cebff0 (diff)
downloadhardware_ti_omap4-8bae9523b8df3d3a65d2fea0c9ec4f3afd9b9bc0.zip
hardware_ti_omap4-8bae9523b8df3d3a65d2fea0c9ec4f3afd9b9bc0.tar.gz
hardware_ti_omap4-8bae9523b8df3d3a65d2fea0c9ec4f3afd9b9bc0.tar.bz2
CameraHAL: Fixed memory leak because of missing ion_close()
This patch prevents ION device from infinite openings without close. Added missing MemoryManager::initialize() calls through the code. Change-Id: I053bfd2076d355439c5cb8adc4a041a6650eac5c Signed-off-by: Anatolii.Shuba <x0158321@ti.com> Signed-off-by: Daniel Levin <dendy@ti.com>
Diffstat (limited to 'camera/MemoryManager.cpp')
-rw-r--r--camera/MemoryManager.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/camera/MemoryManager.cpp b/camera/MemoryManager.cpp
index f93a427..be33968 100644
--- a/camera/MemoryManager.cpp
+++ b/camera/MemoryManager.cpp
@@ -38,20 +38,35 @@ namespace android {
///Utility Macro Declarations
/*--------------------MemoryManager Class STARTS here-----------------------------*/
+MemoryManager::MemoryManager() {
+ mIonFd = -1;
+}
+
+MemoryManager::~MemoryManager() {
+ if ( mIonFd >= 0 ) {
+ ion_close(mIonFd);
+ mIonFd = -1;
+ }
+}
+
+status_t MemoryManager::initialize() {
+ if ( mIonFd == -1 ) {
+ mIonFd = ion_open();
+ if ( mIonFd < 0 ) {
+ CAMHAL_LOGE("ion_open() failed, error: %d", mIonFd);
+ mIonFd = -1;
+ return NO_INIT;
+ }
+ }
+
+ return OK;
+}
+
CameraBuffer* MemoryManager::allocateBufferList(int width, int height, const char* format, int &size, int numBufs)
{
LOG_FUNCTION_NAME;
- if(mIonFd == 0)
- {
- mIonFd = ion_open();
- if(mIonFd <= 0)
- {
- CAMHAL_LOGEA("ion_open failed!!!");
- mIonFd = 0;
- return NULL;
- }
- }
+ CAMHAL_ASSERT(mIonFd != -1);
///We allocate numBufs+1 because the last entry will be marked NULL to indicate end of array, which is used when freeing
///the buffers
@@ -127,12 +142,6 @@ error:
mErrorNotifier->errorNotify(-ENOMEM);
}
- if ( 0 < mIonFd )
- {
- ion_close(mIonFd);
- mIonFd = 0;
- }
-
LOG_FUNCTION_NAME_EXIT;
return NULL;
}