This commit is contained in:
wangjiyu 2025-05-04 11:14:22 +08:00
parent 00bd8c4c64
commit a9d531c6fc
1 changed files with 9 additions and 2 deletions

View File

@ -40,14 +40,21 @@ int sendCustomAudioData(int16_t destChannelIndex, py::array_t<int16_t> inputArra
int32_t sampleRate, uint64_t channelNum, uint64_t dataLen) {
py::gil_scoped_release release;
auto buf = inputArray.request();
py::array_t<int16_t> contiguous = py::array::ensure(inputArray);
if (!contiguous) throw py::value_error("Array conversion failed");
auto buf = contiguous.request();
if (buf.size != dataLen) {
throw py::value_error("Array length does not match dataLen");
}
std::vector<int16_t> localCopy(static_cast<int16_t*>(buf.ptr),
static_cast<int16_t*>(buf.ptr) + buf.size);
return RTCContext::instance().sendCustomAudioData(
destChannelIndex, buf.ptr, sampleRate, channelNum, dataLen
destChannelIndex, localCopy.data(), sampleRate, channelNum, dataLen
);
//return RTCContext::instance().sendCustomAudioData(
// destChannelIndex, buf.ptr, sampleRate, channelNum, dataLen
//);
}
py::list getListData() {
return RTCContext::instance().getListData();