This commit is contained in:
wangjiyu 2025-04-16 11:15:19 +08:00
parent c668b06ef8
commit 80fe99160f
1 changed files with 5 additions and 4 deletions

View File

@ -303,7 +303,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
// 1. 获取GIL
std::cout << "[1] 获取GIL锁..." << std::endl;
PyGILState_STATE gstate = PyGILState_Ensure();
//PyGILState_STATE gstate = PyGILState_Ensure();
try {
// 2. 输入参数校验
@ -321,7 +321,8 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
// 3. 创建共享内存
std::cout << "[3] 创建共享内存..." << std::endl;
char shm_name[32];
snprintf(shm_name, sizeof(shm_name), "/audio_shm_%d", getpid());
//snprintf(shm_name, sizeof(shm_name), "/audio_shm_%d", getpid());
snprintf(shm_name, sizeof(shm_name), "/audio_shm_test");
int fd = shm_open(shm_name, O_CREAT | O_RDWR, 0666);
if (fd == -1) {
@ -452,12 +453,12 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
shm_unlink(shm_name);
std::cout << "[9] 释放GIL..." << std::endl;
PyGILState_Release(gstate);
//PyGILState_Release(gstate);
std::cout << "=== 音频处理完成 ===" << std::endl;
} catch (const std::exception& e) {
std::cout << "[EXCEPTION] 异常捕获: " << e.what() << std::endl;
PyGILState_Release(gstate);
//PyGILState_Release(gstate);
std::cerr << "Audio process error: " << e.what() << std::endl;
}
}