This commit is contained in:
wangjiyu 2025-04-15 17:23:17 +08:00
parent aced2e2308
commit 00672f25fe
1 changed files with 8 additions and 1 deletions

View File

@ -69,7 +69,9 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
std::cerr << "Python 解释器未初始化!" << std::endl;
return;
}
#ifdef GIL
PyGILState_STATE gstate = PyGILState_Ensure();
#endif
namespace py = boost::python;
try {
@ -125,7 +127,6 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
audioFrame.numChannels,
audioFrame.channelIndex
);
//PyGILState_Release(gstate);
std::cout << " after callback" << std::endl;
if (PyErr_Occurred()) {
PyObject *type, *value, *traceback;
@ -172,15 +173,21 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
std::cout << "[8] 释放共享内存资源..." << std::endl;
std::cout << "[9] 释放GIL..." << std::endl;
#ifdef GIL
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);
#endif
std::cerr << "Audio process error: " << e.what() << std::endl;
}
#ifdef GIL
PyGILState_Release(gstate);
#endif
}
void RTCContext::onProducer(uint32_t msgId, mrtc::MRTCProducerInfo& info)