diff --git a/rtc_plugins.cpp b/rtc_plugins.cpp index 8c4c742..7cf544a 100644 --- a/rtc_plugins.cpp +++ b/rtc_plugins.cpp @@ -40,14 +40,21 @@ int sendCustomAudioData(int16_t destChannelIndex, py::array_t inputArra int32_t sampleRate, uint64_t channelNum, uint64_t dataLen) { py::gil_scoped_release release; - auto buf = inputArray.request(); + py::array_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 localCopy(static_cast(buf.ptr), + static_cast(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();