mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-03-31 09:07:13 +09:00
With this instead of kms_cuda/kms_vaapi/kms_software and xcomposite_cuda/xcomposite_vaapi/xcomposite_software there is now only kms and xcomposite.
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
#include "../include/xnvctrl.h"
|
|
#include "../include/library_loader.h"
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <dlfcn.h>
|
|
|
|
bool gsr_xnvctrl_load(gsr_xnvctrl *self, Display *display) {
|
|
memset(self, 0, sizeof(gsr_xnvctrl));
|
|
self->display = display;
|
|
|
|
dlerror(); /* clear */
|
|
void *lib = dlopen("libXNVCtrl.so.0", RTLD_LAZY);
|
|
if(!lib) {
|
|
fprintf(stderr, "gsr error: gsr_xnvctrl_load failed: failed to load libXNVCtrl.so.0, error: %s\n", dlerror());
|
|
return false;
|
|
}
|
|
|
|
const dlsym_assign required_dlsym[] = {
|
|
{ (void**)&self->XNVCTRLQueryExtension, "XNVCTRLQueryExtension" },
|
|
{ (void**)&self->XNVCTRLSetTargetAttributeAndGetStatus, "XNVCTRLSetTargetAttributeAndGetStatus" },
|
|
{ (void**)&self->XNVCTRLQueryValidTargetAttributeValues, "XNVCTRLQueryValidTargetAttributeValues" },
|
|
{ (void**)&self->XNVCTRLQueryTargetStringAttribute, "XNVCTRLQueryTargetStringAttribute" },
|
|
|
|
{ NULL, NULL }
|
|
};
|
|
|
|
if(!dlsym_load_list(lib, required_dlsym)) {
|
|
fprintf(stderr, "gsr error: gsr_xnvctrl_load failed: missing required symbols in libXNVCtrl.so.0\n");
|
|
goto fail;
|
|
}
|
|
|
|
self->library = lib;
|
|
return true;
|
|
|
|
fail:
|
|
dlclose(lib);
|
|
memset(self, 0, sizeof(gsr_xnvctrl));
|
|
return false;
|
|
}
|
|
|
|
void gsr_xnvctrl_unload(gsr_xnvctrl *self) {
|
|
if(self->library) {
|
|
dlclose(self->library);
|
|
memset(self, 0, sizeof(gsr_xnvctrl));
|
|
}
|
|
}
|