From e0bbb7f1e43e4bb6075efe15a6d3bd7da5ee11f1 Mon Sep 17 00:00:00 2001 From: tyan0 <32232575+tyan0@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:32:58 +0900 Subject: [PATCH] Fix deadlock at the end of decoding. (#3767) For some h264 files, h264dec hangs at the end of decoding. This is regression caused by the commit 1c2388750acf. This patch fixes the issue by adding SET_EVENT(&m_sReleaseBufferEvent) to SetOption( DECODER_OPTION_END_OF_STREAM) and CloseDecoderThreads(). --- codec/decoder/plus/src/welsDecoderExt.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codec/decoder/plus/src/welsDecoderExt.cpp b/codec/decoder/plus/src/welsDecoderExt.cpp index 7753505d5..08f2a2743 100644 --- a/codec/decoder/plus/src/welsDecoderExt.cpp +++ b/codec/decoder/plus/src/welsDecoderExt.cpp @@ -325,6 +325,7 @@ void CWelsDecoder::OpenDecoderThreads() { } void CWelsDecoder::CloseDecoderThreads() { if (m_iThreadCount >= 1) { + SET_EVENT (&m_sReleaseBufferEvent); for (int32_t i = 0; i < m_iThreadCount; i++) { //waiting the completion begun slices WAIT_SEMAPHORE (&m_pDecThrCtx[i].sThreadInfo.sIsIdle, WELS_DEC_THREAD_WAIT_INFINITE); m_pDecThrCtx[i].sThreadInfo.uiCommand = WELS_DEC_THREAD_COMMAND_ABORT; @@ -513,6 +514,8 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { if (pDecContext == NULL) return dsInitialOptExpected; pDecContext->bEndOfStreamFlag = iVal ? true : false; + if (iVal && m_iThreadCount >= 1) + SET_EVENT (&m_sReleaseBufferEvent); return cmResultSuccess; } else if (eOptID == DECODER_OPTION_ERROR_CON_IDC) { // Indicate error concealment status