forked from msys2/MINGW-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request msys2#19083 from lazka/libva-path-reloc
libva: add relocation support for the default drivers path
- Loading branch information
Showing
2 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
mingw-w64-libva/0001-libva-add-driver-path-relocation.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- libva-2.20.0/va/va.c.orig 2023-09-14 10:04:13.000000000 +0200 | ||
+++ libva-2.20.0/va/va.c 2023-11-14 21:13:59.128325000 +0100 | ||
@@ -370,6 +370,28 @@ | ||
return driver_path; | ||
} | ||
|
||
+#ifdef __MINGW32__ | ||
+static char *getDLLPath() | ||
+{ | ||
+ HMODULE hModule; | ||
+ if (GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)&getDLLPath, &hModule)) { | ||
+ char *modulePath = (char *)malloc(MAX_PATH); | ||
+ if (modulePath == NULL) { | ||
+ return NULL; | ||
+ } | ||
+ if (GetModuleFileNameA(hModule, modulePath, MAX_PATH) > 0) { | ||
+ char *lastBackslash = strrchr(modulePath, '\\'); | ||
+ if (lastBackslash) { | ||
+ *lastBackslash = '\0'; | ||
+ return modulePath; | ||
+ } | ||
+ } | ||
+ free(modulePath); | ||
+ } | ||
+ return NULL; | ||
+} | ||
+#endif | ||
+ | ||
static VAStatus va_openDriver(VADisplay dpy, char *driver_name) | ||
{ | ||
VADriverContextP ctx = CTX(dpy); | ||
@@ -381,10 +403,21 @@ | ||
if (geteuid() == getuid()) | ||
/* don't allow setuid apps to use LIBVA_DRIVERS_PATH */ | ||
search_path = secure_getenv("LIBVA_DRIVERS_PATH"); | ||
+#ifdef __MINGW32__ | ||
+ if (!search_path) { | ||
+ search_path = getDLLPath(); | ||
+ if (!search_path) { | ||
+ va_errorMessage(dpy, "Failed to detect drivers path\n"); | ||
+ return VA_STATUS_ERROR_OPERATION_FAILED; | ||
+ } | ||
+ } else | ||
+ search_path = strdup((const char *)search_path); | ||
+#else | ||
if (!search_path) | ||
search_path = VA_DRIVERS_PATH; | ||
|
||
search_path = strdup((const char *)search_path); | ||
+#endif | ||
if (!search_path) { | ||
va_errorMessage(dpy, "%s L%d Out of memory\n", | ||
__FUNCTION__, __LINE__); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters