54 lines
1.7 KiB
Diff
54 lines
1.7 KiB
Diff
--- 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__);
|