hardware: samsung_slsi: libcamera2: Fix memory leak on exit
authorSungjoong Kang <sj3.kang@samsung.com>
Fri, 14 Sep 2012 09:46:47 +0000 (02:46 -0700)
committerRebecca Schultz Zavin <rebecca@android.com>
Fri, 14 Sep 2012 17:19:05 +0000 (10:19 -0700)
Fix memory leak caused by not freeing image buffers.

Change-Id: I151fb374f75256c2c96ec4256c11aa2a235d93a0
Signed-off-by: Sungjoong Kang <sj3.kang@samsung.com>
libcamera2/ExynosCameraHWInterface2.cpp
libcamera2/ExynosCameraHWInterface2.h

index 605798ed010f373f82d8aad787a7f2c33de07cb0..c0fe2c24a15948b3cb38ce1c6712a67d106b6068 100644 (file)
@@ -1058,7 +1058,7 @@ void ExynosCameraHWInterface2::release()
     for (i = 0; i < NUM_BAYER_BUFFERS; i++)
         freeCameraMemory(&m_camera_info.sensor.buffer[i], m_camera_info.sensor.planes);
 
-    for(i = 0; i < m_camera_info.capture.buffers; i++)
+    for (i = 0; i < NUM_SCC_BUFFERS; i++)
         freeCameraMemory(&m_camera_info.capture.buffer[i], m_camera_info.capture.planes);
 
     ALOGV("DEBUG(%s): calling exynos_v4l2_close - sensor", __FUNCTION__);
@@ -1257,7 +1257,7 @@ int ExynosCameraHWInterface2::InitializeISPChain()
 #else
     m_camera_info.capture.planes = 1;
 #endif
-    m_camera_info.capture.buffers = 8;
+    m_camera_info.capture.buffers = NUM_SCC_BUFFERS;
     m_camera_info.capture.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
     m_camera_info.capture.memory = V4L2_MEMORY_DMABUF;
 
@@ -1289,7 +1289,7 @@ void ExynosCameraHWInterface2::StartSCCThread(bool threadExists)
     newParameters.height            = m_camera2->getSensorH();
     newParameters.format            = format_actual;
     newParameters.streamOps         = NULL;
-    newParameters.numHwBuffers      = 8;
+    newParameters.numHwBuffers      = NUM_SCC_BUFFERS;
 #ifdef ENABLE_FRAME_SYNC
     newParameters.planes            = 2;
 #else
@@ -1317,7 +1317,7 @@ void ExynosCameraHWInterface2::StartSCCThread(bool threadExists)
         }
     }
     cam_int_s_input(newParameters.node, m_camera_info.sensor_id);
-    m_camera_info.capture.buffers = 8;
+    m_camera_info.capture.buffers = NUM_SCC_BUFFERS;
     cam_int_s_fmt(newParameters.node);
     ALOGV("DEBUG(%s): capture calling reqbuf", __FUNCTION__);
     cam_int_reqbufs(newParameters.node);
@@ -1418,7 +1418,7 @@ int ExynosCameraHWInterface2::notifyRequestQueueNotEmpty()
             StartSCCThread(true);
         } else {
             if (m_camera_info.capture.status == false) {
-                m_camera_info.capture.buffers = 8;
+                m_camera_info.capture.buffers = NUM_SCC_BUFFERS;
                 cam_int_s_fmt(&(m_camera_info.capture));
                 ALOGV("DEBUG(%s): capture calling reqbuf", __FUNCTION__);
                 cam_int_reqbufs(&(m_camera_info.capture));
@@ -1558,7 +1558,7 @@ int ExynosCameraHWInterface2::allocateStream(uint32_t width, uint32_t height, in
             newParameters.format                = *format_actual;
             newParameters.streamOps             = stream_ops;
             newParameters.usage                 = *usage;
-            newParameters.numHwBuffers          = 8;
+            newParameters.numHwBuffers          = NUM_SCP_BUFFERS;
             newParameters.numOwnSvcBuffers      = *max_buffers;
             newParameters.planes                = NUM_PLANES(*format_actual);
             newParameters.metaPlanes            = 1;
@@ -1653,7 +1653,7 @@ int ExynosCameraHWInterface2::allocateStream(uint32_t width, uint32_t height, in
             newParameters.format                = *format_actual;
             newParameters.streamOps             = stream_ops;
             newParameters.usage                 = *usage;
-            newParameters.numHwBuffers          = 8;
+            newParameters.numHwBuffers          = NUM_SCC_BUFFERS;
             newParameters.numOwnSvcBuffers      = *max_buffers;
             newParameters.planes                = NUM_PLANES(*format_actual);
             newParameters.metaPlanes            = 1;
index d26280d24b26b5233c8235eb8ebce2d75913a638..ba861429006aa6b751f4b8ce6f307aea36aadd9f 100644 (file)
@@ -64,6 +64,8 @@ namespace android {
 #define NUM_MAX_REQUEST_MGR_ENTRY   (4)
 #define NUM_MAX_CAMERA_BUFFERS      (16)
 #define NUM_BAYER_BUFFERS           (8)
+#define NUM_SCC_BUFFERS             (8)
+#define NUM_SCP_BUFFERS             (8)
 #define NUM_MIN_SENSOR_QBUF         (3)
 #define NUM_MAX_SUBSTREAM           (4)