From a038aa84011c540c88d997107e80a9b6394e9180 Mon Sep 17 00:00:00 2001 From: Hyeonmyeong Choi Date: Tue, 9 Oct 2012 09:19:00 +0900 Subject: [PATCH] hardware: samsung_slsi: libcamera2: Fixed release stream bug. This patch fixed bug that could not release recording stream. BUG: 7300841 Change-Id: Icbbe4f23b24a410a0686c57f7ce5b3b9cacbebe6 Signed-off-by: Hyeonmyeong Choi --- libcamera2/ExynosCameraHWInterface2.cpp | 58 +++++++++++++------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/libcamera2/ExynosCameraHWInterface2.cpp b/libcamera2/ExynosCameraHWInterface2.cpp index 0975d7c..c8c6602 100644 --- a/libcamera2/ExynosCameraHWInterface2.cpp +++ b/libcamera2/ExynosCameraHWInterface2.cpp @@ -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__); -- 2.20.1