debug
This commit is contained in:
parent
650386806f
commit
4d439101ca
|
@ -18,7 +18,8 @@ add_executable(rtc_plugins
|
|||
rtc_plugins.cpp
|
||||
util/RTCContext.cpp
|
||||
util/numpyConfig.h
|
||||
util/numpyStub.h)
|
||||
util/numpyStub.h
|
||||
util/GIL.h)
|
||||
|
||||
add_library(rtc_plugins_lib SHARED rtc_plugins.cpp
|
||||
util/RTCContext.cpp)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#include <Python.h>
|
||||
struct PyLockGIL
|
||||
{
|
||||
|
||||
PyLockGIL(): gstate(PyGILState_Ensure())
|
||||
{
|
||||
}
|
||||
|
||||
~PyLockGIL()
|
||||
{
|
||||
PyGILState_Release(gstate);
|
||||
}
|
||||
|
||||
PyLockGIL(const PyLockGIL&) = delete;
|
||||
PyLockGIL& operator=(const PyLockGIL&) = delete;
|
||||
|
||||
PyGILState_STATE gstate;
|
||||
};
|
|
@ -75,7 +75,8 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
|||
// 1. 获取GIL
|
||||
std::cout << "[1] 获取GIL锁..." << std::endl;
|
||||
#ifdef GIL
|
||||
PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
//PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
PyLockGIL gil;
|
||||
#endif
|
||||
|
||||
try {
|
||||
|
@ -191,19 +192,19 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
|||
|
||||
std::cout << "[9] 释放GIL..." << std::endl;
|
||||
#ifdef GIL
|
||||
PyGILState_Release(gstate);
|
||||
//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);
|
||||
//PyGILState_Release(gstate);
|
||||
#endif
|
||||
std::cerr << "Audio process error: " << e.what() << std::endl;
|
||||
}
|
||||
#ifdef GIL
|
||||
PyGILState_Release(gstate);
|
||||
//PyGILState_Release(gstate);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
//#include "numpyConfig.h"
|
||||
#include "numpyStub.h"
|
||||
#include "GIL.h"
|
||||
|
||||
#include "IMRTCEngine.hpp"
|
||||
#include "MRTCEngineDefine.hpp"
|
||||
|
|
Loading…
Reference in New Issue