This commit is contained in:
wangjiyu 2025-04-15 19:50:21 +08:00
parent 9c8c15a924
commit 7c64255cbd
1 changed files with 4 additions and 9 deletions

View File

@ -71,9 +71,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
// 1. 获取GIL
std::cout << "[1] 获取GIL锁..." << std::endl;
#ifdef GIL
//PyGILState_STATE gstate = PyGILState_Ensure();
Py_BEGIN_ALLOW_THREADS;
Py_END_ALLOW_THREADS;
PyGILState_STATE gstate = PyGILState_Ensure();
#endif
try {
@ -189,22 +187,19 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
std::cout << "[9] 释放GIL..." << std::endl;
#ifdef GIL
//PyGILState_Release(gstate);
Py_BEGIN_ALLOW_THREADS;
PyGILState_Release(gstate);
#endif
std::cout << "=== 音频处理完成 ===" << std::endl;
} catch (const std::exception& e) {
std::cout << "[EXCEPTION] 异常捕获: " << e.what() << std::endl;
#ifdef GIL
//PyGILState_Release(gstate);
Py_BEGIN_ALLOW_THREADS;
PyGILState_Release(gstate);
#endif
std::cerr << "Audio process error: " << e.what() << std::endl;
}
#ifdef GIL
//PyGILState_Release(gstate);
Py_BEGIN_ALLOW_THREADS;
PyGILState_Release(gstate);
#endif
}