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