This commit is contained in:
wangjiyu 2025-04-10 15:46:57 +08:00
parent 1ca1cc77cc
commit e7b19b4e9a
1 changed files with 0 additions and 7 deletions

View File

@ -63,12 +63,6 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
{ {
namespace py = boost::python; namespace py = boost::python;
// 1. 获取 GIL绝对必要
if (!Py_IsInitialized()) {
std::cerr << "Python interpreter not initialized" << std::endl;
return;
}
boost::python::gil_scoped_acquire gil;
PyGILState_STATE gstate = PyGILState_Ensure(); PyGILState_STATE gstate = PyGILState_Ensure();
try { try {
@ -99,7 +93,6 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
// 5. 创建NumPy数组带内存保护 // 5. 创建NumPy数组带内存保护
PyObject* pyArray = nullptr; PyObject* pyArray = nullptr;
{ {
py::gil_scoped_acquire gil; // 确保在创建数组时持有GIL
pyArray = PyArray_SimpleNew(1, dims, NPY_INT16); pyArray = PyArray_SimpleNew(1, dims, NPY_INT16);
if (!pyArray) { if (!pyArray) {
PyGILState_Release(gstate); PyGILState_Release(gstate);