hardware: samsung_slsi: libcamera2: Fixed release stream bug.
authorHyeonmyeong Choi <hyeon.choi@samsung.com>
Tue, 9 Oct 2012 00:19:00 +0000 (09:19 +0900)
committerAlex Ray <aray@google.com>
Tue, 9 Oct 2012 21:37:23 +0000 (14:37 -0700)
This patch fixed bug that could not release recording stream.

BUG: 7300841
Change-Id: Icbbe4f23b24a410a0686c57f7ce5b3b9cacbebe6
Signed-off-by: Hyeonmyeong Choi <hyeon.choi@samsung.com>
libcamera2/ExynosCameraHWInterface2.cpp

index 0975d7c1117b6bcbb4d662c8c17e23fe557e76e2..c8c6602412f4651688fd79c5d3be8d268ad3aca7 100644 (file)
@@ -2164,7 +2164,7 @@ int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id)
         targetStream = (StreamThread*)(m_streamThreads[0].get());
         if (!targetStream) {
             ALOGW("(%s): Stream Not Exists", __FUNCTION__);
-            return 1;
+            return NO_ERROR;
         }
         targetStream->m_numRegisteredStream--;
         ALOGV("(%s): m_numRegisteredStream = %d", __FUNCTION__, targetStream->m_numRegisteredStream);
@@ -2180,58 +2180,65 @@ int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id)
             }
         }
     } else if (stream_id == STREAM_ID_JPEG) {
+        if (m_resizeBuf.size.s != 0) {
+            freeCameraMemory(&m_resizeBuf, 1);
+        }
+        memset(&m_subStreams[stream_id], 0, sizeof(substream_parameters_t));
+
         targetStream = (StreamThread*)(m_streamThreads[1].get());
         if (!targetStream) {
             ALOGW("(%s): Stream Not Exists", __FUNCTION__);
-            return 1;
-        }
-        memset(&m_subStreams[stream_id], 0, sizeof(substream_parameters_t));
-        if (m_resizeBuf.size.s != 0) {
-            freeCameraMemory(&m_resizeBuf, 1);
+            return NO_ERROR;
         }
-        if (targetStream)
-            res = targetStream->detachSubStream(stream_id);
-        if (res != NO_ERROR) {
+
+        if (targetStream->detachSubStream(stream_id) != NO_ERROR) {
             ALOGE("(%s): substream detach failed. res(%d)", __FUNCTION__, res);
             return 1;
         }
         ALOGV("(%s): m_numRegisteredStream = %d", __FUNCTION__, targetStream->m_numRegisteredStream);
         return 0;
     } else if (stream_id == STREAM_ID_RECORD) {
+        memset(&m_subStreams[stream_id], 0, sizeof(substream_parameters_t));
+
         targetStream = (StreamThread*)(m_streamThreads[0].get());
         if (!targetStream) {
             ALOGW("(%s): Stream Not Exists", __FUNCTION__);
+            return NO_ERROR;
+        }
+
+        if (targetStream->detachSubStream(stream_id) != NO_ERROR) {
+            ALOGE("(%s): substream detach failed. res(%d)", __FUNCTION__, res);
             return 1;
         }
-        memset(&m_subStreams[stream_id], 0, sizeof(substream_parameters_t));
-        if (targetStream)
-            res = targetStream->detachSubStream(stream_id);
-        else
-            return 0;
+
         if (targetStream->m_numRegisteredStream != 0)
             return 0;
     } else if (stream_id == STREAM_ID_PRVCB) {
+        if (m_previewCbBuf.size.s != 0) {
+            freeCameraMemory(&m_previewCbBuf, m_subStreams[stream_id].internalPlanes);
+        }
+        memset(&m_subStreams[stream_id], 0, sizeof(substream_parameters_t));
+
         targetStream = (StreamThread*)(m_streamThreads[0].get());
         if (!targetStream) {
             ALOGW("(%s): Stream Not Exists", __FUNCTION__);
-            return 1;
+            return NO_ERROR;
         }
-        if (m_resizeBuf.size.s != 0) {
-            freeCameraMemory(&m_previewCbBuf, m_subStreams[stream_id].internalPlanes);
+
+        if (targetStream->detachSubStream(stream_id) != NO_ERROR) {
+            ALOGE("(%s): substream detach failed. res(%d)", __FUNCTION__, res);
+            return 1;
         }
-        memset(&m_subStreams[stream_id], 0, sizeof(substream_parameters_t));
-        if (targetStream)
-            res = targetStream->detachSubStream(stream_id);
-        else
-            return 0;
+
         if (targetStream->m_numRegisteredStream != 0)
             return 0;
     } else if (stream_id == STREAM_ID_ZSL) {
         targetStream = (StreamThread*)(m_streamThreads[1].get());
         if (!targetStream) {
             ALOGW("(%s): Stream Not Exists", __FUNCTION__);
-            return 1;
+            return NO_ERROR;
         }
+
         targetStream->m_numRegisteredStream--;
         ALOGV("(%s): m_numRegisteredStream = %d", __FUNCTION__, targetStream->m_numRegisteredStream);
         if (targetStream->m_parameters.needsIonMap) {
@@ -2249,16 +2256,13 @@ int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id)
         return 1;
     }
 
-    if (m_sensorThread != NULL) {
+    if (m_sensorThread != NULL && releasingScpMain) {
         m_sensorThread->release();
         ALOGD("(%s): START Waiting for (indirect) sensor thread termination", __FUNCTION__);
         while (!m_sensorThread->IsTerminated())
             usleep(SIG_WAITING_TICK);
         ALOGD("(%s): END   Waiting for (indirect) sensor thread termination", __FUNCTION__);
     }
-    else {
-        ALOGE("+++++++ sensor thread is NULL %d", __LINE__);
-    }
 
     if (m_streamThreads[1]->m_numRegisteredStream == 0 && m_streamThreads[1]->m_activated) {
         ALOGV("(%s): deactivating stream thread 1 ", __FUNCTION__);