This commit is contained in:
wangjiyu 2025-04-10 18:22:50 +08:00
parent 99f6c1fce3
commit 34b1c30424
1 changed files with 8 additions and 5 deletions

View File

@ -57,11 +57,14 @@ public:
return instance;
}
static void** numpy_api() {
static void** api = [](){
// 延迟获取实际指针
return reinterpret_cast<void**>(RTC_PLUGINS_ARRAY_API);
}();
return api;
void** ptr = reinterpret_cast<void**>(RTC_PLUGINS_ARRAY_API);
// 深度验证API有效性
if (!ptr || !ptr[93]) { // 93是PyArray_SimpleNew的偏移量
PyErr_Print();
throw std::runtime_error("Invalid NumPy API structure");
}
return ptr;
}
RTCContext(const RTCContext&) = delete;
RTCContext& operator=(const RTCContext&) = delete;