Skip to content

Commit

Permalink
(Continued)
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed May 21, 2024
1 parent eb2f4a6 commit c36d810
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 86 deletions.
60 changes: 30 additions & 30 deletions src/hal/sstar/i6_aud.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,89 +120,89 @@ typedef struct {
int (*fnGetFrame)(int device, int channel, i6_aud_frm *frame, i6_aud_efrm *encFrame, int millis);
} i6_aud_impl;

static int i6_aud_load(i6_aud_impl *aenc_lib) {
if (!(aenc_lib->handle = dlopen("libmi_ai.so", RTLD_LAZY | RTLD_GLOBAL))) {
static int i6_aud_load(i6_aud_impl *aud_lib) {
if (!(aud_lib->handle = dlopen("libmi_ai.so", RTLD_LAZY | RTLD_GLOBAL))) {
fprintf(stderr, "[i6_aud] Failed to load library!\nError: %s\n", dlerror());
return EXIT_FAILURE;
}

if (!(aenc_lib->fnDisableDevice = (int(*)(int device))
dlsym(aenc_lib->handle, "MI_AI_Disable"))) {
if (!(aud_lib->fnDisableDevice = (int(*)(int device))
dlsym(aud_lib->handle, "MI_AI_Disable"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_Disable!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnEnableDevice = (int(*)(int device))
dlsym(aenc_lib->handle, "MI_AI_Enable"))) {
if (!(aud_lib->fnEnableDevice = (int(*)(int device))
dlsym(aud_lib->handle, "MI_AI_Enable"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_Enable!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetDeviceConfig = (int(*)(int device, i6_aud_cnf *config))
dlsym(aenc_lib->handle, "MI_AI_SetPubAttr"))) {
if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, i6_aud_cnf *config))
dlsym(aud_lib->handle, "MI_AI_SetPubAttr"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_SetPubAttr!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnDisableChannel = (int(*)(int device, int channel))
dlsym(aenc_lib->handle, "MI_AI_DisableChn"))) {
if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel))
dlsym(aud_lib->handle, "MI_AI_DisableChn"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_DisableChn!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnEnableChannel = (int(*)(int device, int channel))
dlsym(aenc_lib->handle, "MI_AI_EnableChn"))) {
if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel))
dlsym(aud_lib->handle, "MI_AI_EnableChn"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_EnableChn!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnDisableEncoding = (int(*)(int device, int channel))
dlsym(aenc_lib->handle, "MI_AI_DisableAenc"))) {
if (!(aud_lib->fnDisableEncoding = (int(*)(int device, int channel))
dlsym(aud_lib->handle, "MI_AI_DisableAenc"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_DisableChn!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnEnableEncoding = (int(*)(int device, int channel))
dlsym(aenc_lib->handle, "MI_AI_EnableAenc"))) {
if (!(aud_lib->fnEnableEncoding = (int(*)(int device, int channel))
dlsym(aud_lib->handle, "MI_AI_EnableAenc"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_EnableChn!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetEncodingParam = (int(*)(int device, int channel, i6_aud_para *param))
dlsym(aenc_lib->handle, "MI_AI_SetAencAttr"))) {
if (!(aud_lib->fnSetEncodingParam = (int(*)(int device, int channel, i6_aud_para *param))
dlsym(aud_lib->handle, "MI_AI_SetAencAttr"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_SetAencAttr!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetMute = (int(*)(int device, int channel, char active))
dlsym(aenc_lib->handle, "MI_AI_SetMute"))) {
if (!(aud_lib->fnSetMute = (int(*)(int device, int channel, char active))
dlsym(aud_lib->handle, "MI_AI_SetMute"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_SetMute!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetVolume = (int(*)(int device, int channel, int dbLevel))
dlsym(aenc_lib->handle, "MI_AI_SetVqeVolume"))) {
if (!(aud_lib->fnSetVolume = (int(*)(int device, int channel, int dbLevel))
dlsym(aud_lib->handle, "MI_AI_SetVqeVolume"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_SetVqeVolume!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnFreeFrame = (int(*)(int device, int channel, i6_aud_frm *frame, i6_aud_efrm *encFrame))
dlsym(aenc_lib->handle, "MI_AI_ReleaseFrame"))) {
if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, i6_aud_frm *frame, i6_aud_efrm *encFrame))
dlsym(aud_lib->handle, "MI_AI_ReleaseFrame"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_ReleaseFrame!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnGetFrame = (int(*)(int device, int channel, i6_aud_frm *frame, i6_aud_efrm *encFrame, int millis))
dlsym(aenc_lib->handle, "MI_AI_GetFrame"))) {
if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, i6_aud_frm *frame, i6_aud_efrm *encFrame, int millis))
dlsym(aud_lib->handle, "MI_AI_GetFrame"))) {
fprintf(stderr, "[i6_aud] Failed to acquire symbol MI_AI_GetFrame!\n");
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}

static void i6_aud_unload(i6_aud_impl *aenc_lib) {
if (aenc_lib->handle)
dlclose(aenc_lib->handle = NULL);
memset(aenc_lib, 0, sizeof(*aenc_lib));
static void i6_aud_unload(i6_aud_impl *aud_lib) {
if (aud_lib->handle)
dlclose(aud_lib->handle = NULL);
memset(aud_lib, 0, sizeof(*aud_lib));
}
52 changes: 26 additions & 26 deletions src/hal/sstar/i6c_aud.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,77 +142,77 @@ typedef struct {
int (*fnGetFrame)(int device, unsigned char group, i6c_aud_frm *frame, i6c_aud_frm *echoFrame, int millis);
} i6c_aud_impl;

static int i6c_aud_load(i6c_aud_impl *aenc_lib) {
if (!(aenc_lib->handle = dlopen("libmi_ai.so", RTLD_LAZY | RTLD_GLOBAL))) {
static int i6c_aud_load(i6c_aud_impl *aud_lib) {
if (!(aud_lib->handle = dlopen("libmi_ai.so", RTLD_LAZY | RTLD_GLOBAL))) {
fprintf(stderr, "[i6c_aud] Failed to load library!\nError: %s\n", dlerror());
return EXIT_FAILURE;
}

if (!(aenc_lib->fnAttachToDevice = (int(*)(int device, i6c_aud_input inputs[], unsigned char inputSize))
dlsym(aenc_lib->handle, "MI_AI_AttachIf"))) {
if (!(aud_lib->fnAttachToDevice = (int(*)(int device, i6c_aud_input inputs[], unsigned char inputSize))
dlsym(aud_lib->handle, "MI_AI_AttachIf"))) {
fprintf(stderr, "[i6c_aud] Failed to acquire symbol MI_AI_AttachIf!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnDisableDevice = (int(*)(int device))
dlsym(aenc_lib->handle, "MI_AI_Close"))) {
if (!(aud_lib->fnDisableDevice = (int(*)(int device))
dlsym(aud_lib->handle, "MI_AI_Close"))) {
fprintf(stderr, "[i6c_aud] Failed to acquire symbol MI_AI_Close!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnEnableDevice = (int(*)(int device, i6c_aud_cnf *config))
dlsym(aenc_lib->handle, "MI_AI_Open"))) {
if (!(aud_lib->fnEnableDevice = (int(*)(int device, i6c_aud_cnf *config))
dlsym(aud_lib->handle, "MI_AI_Open"))) {
fprintf(stderr, "[i6c_aud] Failed to acquire symbol MI_AI_Open!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnDisableGroup = (int(*)(int device, unsigned char group))
dlsym(aenc_lib->handle, "MI_AI_DisableChnGroup"))) {
if (!(aud_lib->fnDisableGroup = (int(*)(int device, unsigned char group))
dlsym(aud_lib->handle, "MI_AI_DisableChnGroup"))) {
fprintf(stderr, "[i6c_aud] Failed to acquire symbol MI_AI_DisableChnGroup!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnEnableGroup = (int(*)(int device, unsigned char group))
dlsym(aenc_lib->handle, "MI_AI_EnableChnGroup"))) {
if (!(aud_lib->fnEnableGroup = (int(*)(int device, unsigned char group))
dlsym(aud_lib->handle, "MI_AI_EnableChnGroup"))) {
fprintf(stderr, "[i6c_aud] Failed to acquire symbol MI_AI_EnableChnGroup!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetI2SConfig = (int(*)(i6c_aud_input input, i6c_aud_i2s *config))
dlsym(aenc_lib->handle, "MI_AI_SetI2SConfig"))) {
if (!(aud_lib->fnSetI2SConfig = (int(*)(i6c_aud_input input, i6c_aud_i2s *config))
dlsym(aud_lib->handle, "MI_AI_SetI2SConfig"))) {
fprintf(stderr, "[i6c_aud] Failed to acquire symbol MI_AI_SetI2SConfig!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetGain = (int(*)(int device, unsigned char group, char gains[], unsigned char gainSize))
dlsym(aenc_lib->handle, "MI_AI_SetGain"))) {
if (!(aud_lib->fnSetGain = (int(*)(int device, unsigned char group, char gains[], unsigned char gainSize))
dlsym(aud_lib->handle, "MI_AI_SetGain"))) {
fprintf(stderr, "[i6c_aud] Failed to acquire symbol MI_AI_SetGain!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetMute = (int(*)(int device, unsigned char group, char actives[], unsigned char activeSize))
dlsym(aenc_lib->handle, "MI_AI_SetMute"))) {
if (!(aud_lib->fnSetMute = (int(*)(int device, unsigned char group, char actives[], unsigned char activeSize))
dlsym(aud_lib->handle, "MI_AI_SetMute"))) {
fprintf(stderr, "[i6c_aud] Failed to acquire symbol MI_AI_SetMute!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnFreeFrame = (int(*)(int device, unsigned char group, i6c_aud_frm *frame, i6c_aud_frm *echoFrame))
dlsym(aenc_lib->handle, "MI_AI_ReleaseData"))) {
if (!(aud_lib->fnFreeFrame = (int(*)(int device, unsigned char group, i6c_aud_frm *frame, i6c_aud_frm *echoFrame))
dlsym(aud_lib->handle, "MI_AI_ReleaseData"))) {
fprintf(stderr, "[i6c_aud] Failed to acquire symbol MI_AI_ReleaseData!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnGetFrame = (int(*)(int device, unsigned char group, i6c_aud_frm *frame, i6c_aud_frm *echoFrame, int millis))
dlsym(aenc_lib->handle, "MI_AI_Read"))) {
if (!(aud_lib->fnGetFrame = (int(*)(int device, unsigned char group, i6c_aud_frm *frame, i6c_aud_frm *echoFrame, int millis))
dlsym(aud_lib->handle, "MI_AI_Read"))) {
fprintf(stderr, "[i6c_aud] Failed to acquire symbol MI_AI_Read!\n");
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}

static void i6c_aud_unload(i6c_aud_impl *aenc_lib) {
if (aenc_lib->handle)
dlclose(aenc_lib->handle = NULL);
memset(aenc_lib, 0, sizeof(*aenc_lib));
static void i6c_aud_unload(i6c_aud_impl *aud_lib) {
if (aud_lib->handle)
dlclose(aud_lib->handle = NULL);
memset(aud_lib, 0, sizeof(*aud_lib));
}
60 changes: 30 additions & 30 deletions src/hal/sstar/i6f_aud.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,89 +129,89 @@ typedef struct {
int (*fnGetFrame)(int device, int channel, i6f_aud_frm *frame, i6f_aud_efrm *encFrame, int millis);
} i6f_aud_impl;

static int i6f_aud_load(i6f_aud_impl *aenc_lib) {
if (!(aenc_lib->handle = dlopen("libmi_ai.so", RTLD_LAZY | RTLD_GLOBAL))) {
static int i6f_aud_load(i6f_aud_impl *aud_lib) {
if (!(aud_lib->handle = dlopen("libmi_ai.so", RTLD_LAZY | RTLD_GLOBAL))) {
fprintf(stderr, "[i6f_aud] Failed to load library!\nError: %s\n", dlerror());
return EXIT_FAILURE;
}

if (!(aenc_lib->fnDisableDevice = (int(*)(int device))
dlsym(aenc_lib->handle, "MI_AI_Disable"))) {
if (!(aud_lib->fnDisableDevice = (int(*)(int device))
dlsym(aud_lib->handle, "MI_AI_Disable"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_Disable!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnEnableDevice = (int(*)(int device))
dlsym(aenc_lib->handle, "MI_AI_Enable"))) {
if (!(aud_lib->fnEnableDevice = (int(*)(int device))
dlsym(aud_lib->handle, "MI_AI_Enable"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_Enable!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetDeviceConfig = (int(*)(int device, i6f_aud_cnf *config))
dlsym(aenc_lib->handle, "MI_AI_SetPubAttr"))) {
if (!(aud_lib->fnSetDeviceConfig = (int(*)(int device, i6f_aud_cnf *config))
dlsym(aud_lib->handle, "MI_AI_SetPubAttr"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_SetPubAttr!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnDisableChannel = (int(*)(int device, int channel))
dlsym(aenc_lib->handle, "MI_AI_DisableChn"))) {
if (!(aud_lib->fnDisableChannel = (int(*)(int device, int channel))
dlsym(aud_lib->handle, "MI_AI_DisableChn"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_DisableChn!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnEnableChannel = (int(*)(int device, int channel))
dlsym(aenc_lib->handle, "MI_AI_EnableChn"))) {
if (!(aud_lib->fnEnableChannel = (int(*)(int device, int channel))
dlsym(aud_lib->handle, "MI_AI_EnableChn"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_EnableChn!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnDisableEncoding = (int(*)(int device, int channel))
dlsym(aenc_lib->handle, "MI_AI_DisableAenc"))) {
if (!(aud_lib->fnDisableEncoding = (int(*)(int device, int channel))
dlsym(aud_lib->handle, "MI_AI_DisableAenc"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_DisableChn!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnEnableEncoding = (int(*)(int device, int channel))
dlsym(aenc_lib->handle, "MI_AI_EnableAenc"))) {
if (!(aud_lib->fnEnableEncoding = (int(*)(int device, int channel))
dlsym(aud_lib->handle, "MI_AI_EnableAenc"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_EnableChn!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetEncodingParam = (int(*)(int device, int channel, i6f_aud_para *param))
dlsym(aenc_lib->handle, "MI_AI_SetAencAttr"))) {
if (!(aud_lib->fnSetEncodingParam = (int(*)(int device, int channel, i6f_aud_para *param))
dlsym(aud_lib->handle, "MI_AI_SetAencAttr"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_SetAencAttr!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetMute = (int(*)(int device, int channel, char active))
dlsym(aenc_lib->handle, "MI_AI_SetMute"))) {
if (!(aud_lib->fnSetMute = (int(*)(int device, int channel, char active))
dlsym(aud_lib->handle, "MI_AI_SetMute"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_SetMute!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnSetVolume = (int(*)(int device, int channel, int dbLevel))
dlsym(aenc_lib->handle, "MI_AI_SetVqeVolume"))) {
if (!(aud_lib->fnSetVolume = (int(*)(int device, int channel, int dbLevel))
dlsym(aud_lib->handle, "MI_AI_SetVqeVolume"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_SetVqeVolume!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnFreeFrame = (int(*)(int device, int channel, i6f_aud_frm *frame, i6f_aud_efrm *encFrame))
dlsym(aenc_lib->handle, "MI_AI_ReleaseFrame"))) {
if (!(aud_lib->fnFreeFrame = (int(*)(int device, int channel, i6f_aud_frm *frame, i6f_aud_efrm *encFrame))
dlsym(aud_lib->handle, "MI_AI_ReleaseFrame"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_ReleaseFrame!\n");
return EXIT_FAILURE;
}

if (!(aenc_lib->fnGetFrame = (int(*)(int device, int channel, i6f_aud_frm *frame, i6f_aud_efrm *encFrame, int millis))
dlsym(aenc_lib->handle, "MI_AI_GetFrame"))) {
if (!(aud_lib->fnGetFrame = (int(*)(int device, int channel, i6f_aud_frm *frame, i6f_aud_efrm *encFrame, int millis))
dlsym(aud_lib->handle, "MI_AI_GetFrame"))) {
fprintf(stderr, "[i6f_aud] Failed to acquire symbol MI_AI_GetFrame!\n");
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}

static void i6f_aud_unload(i6f_aud_impl *aenc_lib) {
if (aenc_lib->handle)
dlclose(aenc_lib->handle = NULL);
memset(aenc_lib, 0, sizeof(*aenc_lib));
static void i6f_aud_unload(i6f_aud_impl *aud_lib) {
if (aud_lib->handle)
dlclose(aud_lib->handle = NULL);
memset(aud_lib, 0, sizeof(*aud_lib));
}

0 comments on commit c36d810

Please sign in to comment.