debug
This commit is contained in:
parent
3fbe05cf92
commit
815956c01c
|
@ -702,19 +702,26 @@ RetAudioFrame RTCContext::getData() {
|
|||
namespace bp = boost::python;
|
||||
namespace np = boost::python::numpy;
|
||||
np::ndarray RTCContext::getNumpydata() {
|
||||
std::cout << "step1" << std::endl;
|
||||
std::lock_guard<std::mutex> lock(dataMutex_);
|
||||
RetAudioFrame frame = getData();
|
||||
std::cout << "step2" << std::endl;
|
||||
int16_t* data_ptr = frame.data.get(); // 你的数据指针
|
||||
std::cout << "step3" << std::endl;
|
||||
size_t length = frame.dataCount; // 数据长度
|
||||
std::cout << "step4" << std::endl;
|
||||
|
||||
// 创建 NumPy 数组(拷贝数据)
|
||||
if (!data_ptr || length == 0) {
|
||||
// 返回空数组或抛出异常
|
||||
return np::zeros(bp::make_tuple(0), np::dtype::get_builtin<int16_t>());
|
||||
}
|
||||
std::cout << "step5" << std::endl;
|
||||
|
||||
np::ndarray result = np::empty(bp::make_tuple(length), np::dtype::get_builtin<int16_t>());
|
||||
std::cout << "step6" << std::endl;
|
||||
std::memcpy(result.get_data(), data_ptr, length * sizeof(int16_t));
|
||||
std::cout << "step7" << std::endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue