Fix NV12 crash issue when recreate camera object
This commit is contained in:
@@ -575,8 +575,13 @@ void CVideoDecoder::Start() {
|
||||
}
|
||||
|
||||
void CVideoDecoder::Stop() {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
m_bRunning = FALSE;
|
||||
// Atomically signal the decoder to stop WITHOUT acquiring _mutex.
|
||||
// decode() holds _mutex while inside avcodec_send_packet / CUDA calls
|
||||
// that can block on the nvcuda64 SRW lock for a long time.
|
||||
// If we waited for _mutex here, Stop() would deadlock whenever a
|
||||
// concurrent decode() is stuck waiting for a CUDA operation held by
|
||||
// an inference thread.
|
||||
m_bRunning.store(FALSE, std::memory_order_release);
|
||||
log_print(HT_LOG_INFO, "%s, Video decoder stopped\r\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "sys_inc.h"
|
||||
#include "media_format.h"
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
extern "C"
|
||||
@@ -152,7 +153,7 @@ private:
|
||||
int hwDecoderInit(AVCodecContext* ctx, int hwMode, int preferredGpu = -1);
|
||||
private:
|
||||
BOOL m_bInited;
|
||||
BOOL m_bRunning;
|
||||
std::atomic<BOOL> m_bRunning;
|
||||
BOOL m_bHardwareDecoderEnabled; // Track if hardware decoder is enabled
|
||||
bool m_bCudaHWAccel; // true when using AV_HWDEVICE_TYPE_CUDA
|
||||
int m_hwGpuIndex; // GPU index assigned by HWDecoderPool (-1 = legacy)
|
||||
|
||||
Reference in New Issue
Block a user