From a9d531c6fcd8f25ee36067f346d29c49e6356b82 Mon Sep 17 00:00:00 2001 From: wangjiyu Date: Sun, 4 May 2025 11:14:22 +0800 Subject: [PATCH] debug --- rtc_plugins.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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();