debug
This commit is contained in:
parent
85528e9023
commit
0f7c98f2f2
|
@ -155,6 +155,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
||||||
mrtc::MRTCAudioFrame& audioFrame,
|
mrtc::MRTCAudioFrame& audioFrame,
|
||||||
mrtc::MRTCAudioSourceType audioSourceType)
|
mrtc::MRTCAudioSourceType audioSourceType)
|
||||||
|
@ -173,11 +174,13 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
||||||
|
|
||||||
if (!audioFrame.data || audioFrame.dataCount <= 0) {
|
if (!audioFrame.data || audioFrame.dataCount <= 0) {
|
||||||
std::cout << "[ERROR] 无效音频数据指针或长度" << std::endl;
|
std::cout << "[ERROR] 无效音频数据指针或长度" << std::endl;
|
||||||
|
PyGILState_Release(gstate);
|
||||||
throw std::invalid_argument("Invalid audio frame data");
|
throw std::invalid_argument("Invalid audio frame data");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audioFrame.dataCount > std::numeric_limits<npy_intp>::max()) {
|
if (audioFrame.dataCount > std::numeric_limits<npy_intp>::max()) {
|
||||||
std::cout << "[ERROR] 数据长度超过最大值" << std::endl;
|
std::cout << "[ERROR] 数据长度超过最大值" << std::endl;
|
||||||
|
PyGILState_Release(gstate);
|
||||||
throw std::overflow_error("Audio frame size exceeds maximum limit");
|
throw std::overflow_error("Audio frame size exceeds maximum limit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +194,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
||||||
PyObject* numpy_module = PyImport_ImportModule("numpy.core.multiarray");
|
PyObject* numpy_module = PyImport_ImportModule("numpy.core.multiarray");
|
||||||
if (!numpy_module) {
|
if (!numpy_module) {
|
||||||
std::cout << "[ERROR] 无法导入numpy模块" << std::endl;
|
std::cout << "[ERROR] 无法导入numpy模块" << std::endl;
|
||||||
|
PyGILState_Release(gstate);
|
||||||
throw std::runtime_error("Failed to import numpy.core");
|
throw std::runtime_error("Failed to import numpy.core");
|
||||||
}
|
}
|
||||||
std::cout << " 模块导入成功: " << numpy_module << std::endl;
|
std::cout << " 模块导入成功: " << numpy_module << std::endl;
|
||||||
|
@ -201,6 +205,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
||||||
if (!empty_func) {
|
if (!empty_func) {
|
||||||
Py_DECREF(numpy_module);
|
Py_DECREF(numpy_module);
|
||||||
std::cout << "[ERROR] 无法获取empty函数" << std::endl;
|
std::cout << "[ERROR] 无法获取empty函数" << std::endl;
|
||||||
|
PyGILState_Release(gstate);
|
||||||
throw std::runtime_error("Failed to get numpy.empty");
|
throw std::runtime_error("Failed to get numpy.empty");
|
||||||
}
|
}
|
||||||
std::cout << " 函数获取成功: " << empty_func << std::endl;
|
std::cout << " 函数获取成功: " << empty_func << std::endl;
|
||||||
|
@ -210,7 +215,18 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
||||||
PyObject* py_dims = PyTuple_New(1);
|
PyObject* py_dims = PyTuple_New(1);
|
||||||
PyTuple_SetItem(py_dims, 0, PyLong_FromLong(dims[0]));
|
PyTuple_SetItem(py_dims, 0, PyLong_FromLong(dims[0]));
|
||||||
|
|
||||||
PyObject* dtype = PyArray_DescrFromType(NPY_INT16);
|
// 修正点:显式处理dtype类型转换
|
||||||
|
PyArray_Descr* np_dtype = PyArray_DescrFromType(NPY_INT16);
|
||||||
|
if (!np_dtype) {
|
||||||
|
Py_DECREF(py_dims);
|
||||||
|
Py_DECREF(empty_func);
|
||||||
|
Py_DECREF(numpy_module);
|
||||||
|
std::cout << "[ERROR] 无法创建dtype" << std::endl;
|
||||||
|
PyGILState_Release(gstate);
|
||||||
|
throw std::runtime_error("Failed to create numpy dtype");
|
||||||
|
}
|
||||||
|
PyObject* dtype = reinterpret_cast<PyObject*>(np_dtype);
|
||||||
|
|
||||||
PyObject* args = PyTuple_Pack(2, py_dims, dtype);
|
PyObject* args = PyTuple_Pack(2, py_dims, dtype);
|
||||||
std::cout << " 参数构建完成: " << args << std::endl;
|
std::cout << " 参数构建完成: " << args << std::endl;
|
||||||
|
|
||||||
|
@ -229,6 +245,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
||||||
|
|
||||||
if (!pyArray) {
|
if (!pyArray) {
|
||||||
std::cout << "[ERROR] 数组创建失败" << std::endl;
|
std::cout << "[ERROR] 数组创建失败" << std::endl;
|
||||||
|
PyGILState_Release(gstate);
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,6 +254,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
||||||
if (reinterpret_cast<uintptr_t>(audioFrame.data) % alignof(int16_t) != 0) {
|
if (reinterpret_cast<uintptr_t>(audioFrame.data) % alignof(int16_t) != 0) {
|
||||||
Py_DECREF(pyArray);
|
Py_DECREF(pyArray);
|
||||||
std::cout << "[ERROR] 内存未对齐" << std::endl;
|
std::cout << "[ERROR] 内存未对齐" << std::endl;
|
||||||
|
PyGILState_Release(gstate);
|
||||||
throw std::runtime_error("Unaligned audio data pointer");
|
throw std::runtime_error("Unaligned audio data pointer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,6 +280,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
std::cout << "[ERROR] 回调执行异常" << std::endl;
|
std::cout << "[ERROR] 回调执行异常" << std::endl;
|
||||||
Py_DECREF(pyArray);
|
Py_DECREF(pyArray);
|
||||||
|
PyGILState_Release(gstate);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -282,6 +301,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
||||||
std::cerr << "Audio process error: " << e.what() << std::endl;
|
std::cerr << "Audio process error: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTCContext::onProducer(uint32_t msgId, mrtc::MRTCProducerInfo& info)
|
void RTCContext::onProducer(uint32_t msgId, mrtc::MRTCProducerInfo& info)
|
||||||
{
|
{
|
||||||
std::cout << "-----------------------------------" << std::endl;
|
std::cout << "-----------------------------------" << std::endl;
|
||||||
|
|
Loading…
Reference in New Issue