debug
This commit is contained in:
parent
a098a6a825
commit
d1a3495378
|
@ -1,7 +1,8 @@
|
|||
#include <boost/python/module.hpp>
|
||||
#include <boost/python/def.hpp>
|
||||
#define PY_ARRAY_UNIQUE_SYMBOL rtc_plugins_ARRAY_API
|
||||
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
||||
#include <numpy/arrayobject.h>
|
||||
#include <numpy/ndarrayobject.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
@ -104,20 +105,23 @@ int sendCustomAudioData(const int16_t destChannelIndex, py::object pD, int32_t s
|
|||
}
|
||||
}
|
||||
|
||||
// 修改后的初始化函数
|
||||
int init_numpy() {
|
||||
if (import_array() < 0) {
|
||||
PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void init_numpy() {
|
||||
// 直接调用底层函数,绕过宏的问题
|
||||
if (_import_array() < 0) {
|
||||
PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
|
||||
throw std::runtime_error("NumPy initialization failed");
|
||||
}
|
||||
}
|
||||
BOOST_PYTHON_MODULE(rtc_plugins) {
|
||||
if (init_numpy() != 0) return;
|
||||
try {
|
||||
init_numpy();
|
||||
|
||||
py::def("init", &init);
|
||||
py::def("initRecv", &initRecv);
|
||||
py::def("initSend", &initSend);
|
||||
py::def("sendCustomAudioData", &sendCustomAudioData);
|
||||
} catch (...) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Module initialization failed");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue