From f00ed230a00aa655679b3f095fad4c31e90f35f4 Mon Sep 17 00:00:00 2001 From: wangjiyu Date: Wed, 16 Apr 2025 19:38:34 +0800 Subject: [PATCH] debug --- rtc_plugins.cpp | 2 +- util/RTCContext.cpp | 11 +++++++---- util/RTCContext.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/rtc_plugins.cpp b/rtc_plugins.cpp index fa82489..dd37a82 100644 --- a/rtc_plugins.cpp +++ b/rtc_plugins.cpp @@ -56,7 +56,7 @@ namespace np = boost::python::numpy; np::ndarray getNumpyData() { return RTCContext::instance().getNumpyData(); } -std::vector getListData() { +bp::list getListData() { return RTCContext::instance().getListData(); } int16_t getDataCount() { diff --git a/util/RTCContext.cpp b/util/RTCContext.cpp index 96bed36..80c8b9f 100644 --- a/util/RTCContext.cpp +++ b/util/RTCContext.cpp @@ -728,7 +728,7 @@ np::ndarray RTCContext::getNumpyData() { return result; } -std::vector RTCContext::getListData() { +bp::list RTCContext::getListData() { std::cout << "step1" << std::endl; std::lock_guard lock(dataMutex_); RetAudioFrame frame = getData(); @@ -737,10 +737,13 @@ std::vector RTCContext::getListData() { std::cout << "step3" << std::endl; size_t length = frame.dataCount; // 数据长度 std::cout << "step4" << std::endl; - if (!dataPtr || length == 0) { - return {}; // 返回空 vector + bp::list result; + if (dataPtr && length > 0) { + for (size_t i = 0; i < length; ++i) { + result.append(dataPtr[i]); // 逐个元素添加(值传递) + } } - return std::vector(dataPtr, dataPtr + length); // 深拷贝 + return result; } int16_t RTCContext::getDataCount() { std::lock_guard lock(dataMutex_); diff --git a/util/RTCContext.h b/util/RTCContext.h index a180bf1..490e40e 100644 --- a/util/RTCContext.h +++ b/util/RTCContext.h @@ -101,7 +101,7 @@ public: void setData(const mrtc::MRTCAudioFrame& frame); RetAudioFrame getData(); np::ndarray getNumpyData(); - std::vector getListData(); + bp::list getListData(); int16_t getDataCount(); void* getpData() const;