debug
This commit is contained in:
parent
3d51fe5610
commit
c2fe936ce2
|
@ -329,9 +329,20 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
|||
}
|
||||
std::cout << " 映射地址: " << ptr << std::endl;
|
||||
|
||||
namespace py = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
// 6. 拷贝数据到共享内存
|
||||
std::cout << "[6] 拷贝音频数据到共享内存..." << std::endl;
|
||||
memcpy(ptr, audioFrame.data, data_size);
|
||||
npy_intp shape[1] = { static_cast<npy_intp>(audioFrame.dataCount) };
|
||||
np::dtype dtype = np::dtype::get_builtin<int16_t>();
|
||||
np::ndarray audioArray = np::from_data(
|
||||
audioFrame.data, // 数据指针
|
||||
dtype, // 数据类型 (int16)
|
||||
py::make_tuple(shape[0]), // 形状 (1D)
|
||||
py::make_tuple(sizeof(int16_t)), // 步长
|
||||
py::object() // 所有者(Python管理)
|
||||
);
|
||||
std::cout << " 数据拷贝完成" << std::endl;
|
||||
|
||||
// 7. 执行回调
|
||||
|
@ -346,6 +357,7 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
|||
std::cout << " pyCallback_ repr: " << PyUnicode_AsUTF8(repr) << std::endl;
|
||||
Py_DECREF(repr); // 必须手动释放
|
||||
}
|
||||
/*
|
||||
// 传递共享内存信息
|
||||
pyCallback_(
|
||||
py::str(shm_name), // 共享内存名称
|
||||
|
@ -354,6 +366,15 @@ void RTCContext::onAudioProcess(const char* roomId, const char* peerId,
|
|||
audioFrame.sampleRate,
|
||||
audioFrame.numChannels,
|
||||
audioFrame.channelIndex
|
||||
);
|
||||
*/
|
||||
pyCallback_(
|
||||
audioArray, // numpy 数组
|
||||
data_size, // 数据大小
|
||||
audioFrame.dataCount,
|
||||
audioFrame.sampleRate,
|
||||
audioFrame.numChannels,
|
||||
audioFrame.channelIndex
|
||||
);
|
||||
std::cout << " after callback" << std::endl;
|
||||
if (PyErr_Occurred()) {
|
||||
|
|
Loading…
Reference in New Issue