livoxGen1: Make use of livoxProto1_getPcloudDataFdDesc

This commit is contained in:
2025-11-02 19:16:22 -04:00
parent b3bf0e2cb9
commit d88dd2cf44
5 changed files with 38 additions and 34 deletions
+26 -32
View File
@@ -45,40 +45,28 @@ getStimBuff(const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
return nullptr;
}
// LivoxProto1 library state
struct LivoxProto1DllState
// LivoxProto1DllState constructor implementation
LivoxProto1DllState::LivoxProto1DllState()
: dlopenHandle(nullptr, DlCloser),
livoxProto1_main(nullptr),
livoxProto1_exit(nullptr),
livoxProto1_getOrCreateDeviceReq(nullptr),
livoxProto1_destroyDeviceReq(nullptr),
livoxProto1_device_enablePcloudDataReq(nullptr),
livoxProto1_device_disablePcloudDataReq(nullptr),
livoxProto1_device_getReturnModeReq(nullptr),
livoxProto1_getPcloudDataFdDesc(nullptr)
{}
// LivoxProto1DllState DlCloser implementation
void LivoxProto1DllState::DlCloser(void* handle)
{
LivoxProto1DllState()
: dlopenHandle(nullptr, DlCloser),
livoxProto1_main(nullptr),
livoxProto1_exit(nullptr),
livoxProto1_getOrCreateDeviceReq(nullptr),
livoxProto1_destroyDeviceReq(nullptr),
livoxProto1_device_enablePcloudDataReq(nullptr),
livoxProto1_device_disablePcloudDataReq(nullptr),
livoxProto1_device_getReturnModeReq(nullptr)
{}
static void DlCloser(void* handle)
{
if (handle) {
dlclose(handle);
}
if (handle) {
dlclose(handle);
}
}
std::unique_ptr<void, void(*)(void*)> dlopenHandle;
livoxProto1_mainFn *livoxProto1_main;
livoxProto1_exitFn *livoxProto1_exit;
livoxProto1_getOrCreateDeviceReqFn *livoxProto1_getOrCreateDeviceReq;
livoxProto1_destroyDeviceReqFn *livoxProto1_destroyDeviceReq;
livoxProto1_device_enablePcloudDataReqFn
*livoxProto1_device_enablePcloudDataReq;
livoxProto1_device_disablePcloudDataReqFn
*livoxProto1_device_disablePcloudDataReq;
livoxProto1_device_getReturnModeReqFn *livoxProto1_device_getReturnModeReq;
};
static LivoxProto1DllState livoxProto1;
LivoxProto1DllState livoxProto1;
// Continuation classes for async operations
class AttachDeviceReq
@@ -470,13 +458,19 @@ extern "C" int livoxGen1_initializeInd(void)
dlsym(
livoxProto1.dlopenHandle.get(),
"livoxProto1_device_getReturnModeReq"));
livoxProto1.livoxProto1_getPcloudDataFdDesc = reinterpret_cast<
livoxProto1_getPcloudDataFdDescFn *>(
dlsym(
livoxProto1.dlopenHandle.get(),
"livoxProto1_getPcloudDataFdDesc"));
if (!livoxProto1.livoxProto1_main || !livoxProto1.livoxProto1_exit
|| !livoxProto1.livoxProto1_getOrCreateDeviceReq
|| !livoxProto1.livoxProto1_destroyDeviceReq
|| !livoxProto1.livoxProto1_device_enablePcloudDataReq
|| !livoxProto1.livoxProto1_device_disablePcloudDataReq
|| !livoxProto1.livoxProto1_device_getReturnModeReq)
|| !livoxProto1.livoxProto1_device_getReturnModeReq
|| !livoxProto1.livoxProto1_getPcloudDataFdDesc)
{
throw std::runtime_error(
std::string(__func__) +