mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-05-06 06:50:43 +09:00
Add overclocking option -oc to workaround a NVIDIA driver bug (forcefully set to p2 state when using cuda)
This commit is contained in:
44
src/xnvctrl.c
Normal file
44
src/xnvctrl.c
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "../include/xnvctrl.h"
|
||||
#include "../include/library_loader.h"
|
||||
#include <string.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;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user