Skip to content

Commit

Permalink
Fix deadlock at the end of decoding. (#3767)
Browse files Browse the repository at this point in the history
For some h264 files, h264dec hangs at the end of decoding. This is
regression caused by the commit 1c23887. This patch fixes the
issue by adding SET_EVENT(&m_sReleaseBufferEvent) to SetOption(
DECODER_OPTION_END_OF_STREAM) and CloseDecoderThreads().
  • Loading branch information
tyan0 committed Jul 18, 2024
1 parent 4ab86b8 commit e0bbb7f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions codec/decoder/plus/src/welsDecoderExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e0bbb7f

Please sign in to comment.