debug
This commit is contained in:
parent
f1414abe5c
commit
ee1d84cb1c
|
@ -58,6 +58,7 @@ py::object create_int16_array() {
|
|||
// 4. 转换为 py::object(自动管理引用计数)
|
||||
return py::object(py::handle<>(py_array));
|
||||
}
|
||||
|
||||
int sendCustomAudioData(int16_t destChannelIndex, py::object pD,
|
||||
int32_t sampleRate, uint64_t channelNum, uint64_t dataLen) {
|
||||
try {
|
||||
|
@ -71,10 +72,12 @@ int sendCustomAudioData(int16_t destChannelIndex, py::object pD,
|
|||
throw std::runtime_error("Failed to convert input to int16 array");
|
||||
}
|
||||
|
||||
py::object arr = py::handle<>(py_array);
|
||||
PyArrayObject* npArray = reinterpret_cast<PyArrayObject*>(arr.ptr());
|
||||
// 修复点:显式构造 py::object(两种写法均可)
|
||||
py::object arr(py::handle<>(py_array)); // 写法1:构造函数
|
||||
// py::object arr = py::reinterpret_borrow<py::object>(py_array); // 写法2:borrow语义
|
||||
|
||||
// 检查数据长度
|
||||
PyArrayObject* npArray = reinterpret_cast<PyArrayObject*>(arr.ptr());
|
||||
if (PyArray_SIZE(npArray) != static_cast<npy_intp>(dataLen)) {
|
||||
throw std::runtime_error("Array length does not match dataLen");
|
||||
}
|
||||
|
@ -89,6 +92,7 @@ int sendCustomAudioData(int16_t destChannelIndex, py::object pD,
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
int sendCustomAudioData(const int16_t destChannelIndex, py::object pyData, int32_t sampleRate, uint64_t channelNum,
|
||||
uint64_t dataLen) {
|
||||
|
|
Loading…
Reference in New Issue