In app/src/main/cpp/player/HWCodecPlayer.cpp, AudioDecodeThreadProc and InitDecoder both run on a std::thread. GetJNIEnv attaches that thread and sets isAttach = true. Two early exits skip the matching DetachCurrentThread, so the thread can exit while still attached to the JVM.
· AudioDecodeThreadProc: stop and an empty packet queue use break and still reach the detach at line 364. If avcodec_send_packet fails, line 308 returns and skips it.
· InitDecoder is a do ... while (false). break before GetJNIEnv (line 546) is fine, because the thread is not attached yet. After that, the breaks at line 559 (AMediaExtractor_setDataSourceFd failure) and line 588 (m_MediaCodec == nullptr) skip the detach at line 591. The break at line 573 only leaves the for loop. PostMessage later sees the thread already attached and does not detach it either.
Fix both exits so every path that set isAttach calls DetachCurrentThread before the thread returns.
In app/src/main/cpp/player/HWCodecPlayer.cpp, AudioDecodeThreadProc and InitDecoder both run on a std::thread. GetJNIEnv attaches that thread and sets isAttach = true. Two early exits skip the matching DetachCurrentThread, so the thread can exit while still attached to the JVM.
· AudioDecodeThreadProc: stop and an empty packet queue use break and still reach the detach at line 364. If avcodec_send_packet fails, line 308 returns and skips it.
· InitDecoder is a do ... while (false). break before GetJNIEnv (line 546) is fine, because the thread is not attached yet. After that, the breaks at line 559 (AMediaExtractor_setDataSourceFd failure) and line 588 (m_MediaCodec == nullptr) skip the detach at line 591. The break at line 573 only leaves the for loop. PostMessage later sees the thread already attached and does not detach it either.
Fix both exits so every path that set isAttach calls DetachCurrentThread before the thread returns.