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