|
38 | 38 | #include <string.h> |
39 | 39 | #if defined(_WIN32) |
40 | 40 | #include "compat_win32.h" |
41 | | -#define DRIVER_EXTENSION "_drv_video.dll" |
42 | 41 | #define DRIVER_PATH_STRING "%s\\%s%s" |
43 | 42 | #define ENV_VAR_SEPARATOR ";" |
44 | 43 | #else |
45 | 44 | #include <dlfcn.h> |
46 | 45 | #include <unistd.h> |
47 | | -#define DRIVER_EXTENSION "_drv_video.so" |
48 | | -#define DRIVER_PATH_STRING "%s/%s%s" |
| 46 | +#define DRIVER_PATH_STRING "%s/%s%s.so" |
49 | 47 | #define ENV_VAR_SEPARATOR ":" |
50 | 48 | #endif |
51 | 49 | #ifdef ANDROID |
@@ -353,16 +351,16 @@ va_getDriverInitName(char *name, int namelen, int major, int minor) |
353 | 351 | return ret > 0 && ret < namelen; |
354 | 352 | } |
355 | 353 |
|
356 | | -static char *va_getDriverPath(const char *driver_dir, const char *driver_name) |
| 354 | +static char *va_getDriverPath(const char *driver_dir, const char *driver_name, bool use_suffix) |
357 | 355 | { |
358 | | - int n = snprintf(0, 0, DRIVER_PATH_STRING, driver_dir, driver_name, DRIVER_EXTENSION); |
| 356 | + int n = snprintf(0, 0, DRIVER_PATH_STRING, driver_dir, driver_name, use_suffix ? "_drv_video" : ""); |
359 | 357 | if (n < 0) |
360 | 358 | return NULL; |
361 | 359 | char *driver_path = (char *) malloc(n + 1); |
362 | 360 | if (!driver_path) |
363 | 361 | return NULL; |
364 | 362 | n = snprintf(driver_path, n + 1, DRIVER_PATH_STRING, |
365 | | - driver_dir, driver_name, DRIVER_EXTENSION); |
| 363 | + driver_dir, driver_name, use_suffix ? "_drv_video" : ""); |
366 | 364 | if (n < 0) { |
367 | 365 | free(driver_path); |
368 | 366 | return NULL; |
@@ -529,19 +527,20 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) |
529 | 527 | } |
530 | 528 | driver_dir = strtok_r(search_path, ENV_VAR_SEPARATOR, &saveptr); |
531 | 529 | while (driver_dir) { |
532 | | - char *driver_path = va_getDriverPath(driver_dir, driver_name); |
533 | | - if (!driver_path) { |
534 | | - va_errorMessage(dpy, "%s L%d Out of memory\n", |
535 | | - __FUNCTION__, __LINE__); |
536 | | - free(search_path); |
537 | | - return VA_STATUS_ERROR_ALLOCATION_FAILED; |
538 | | - } |
539 | | - |
540 | | - vaStatus = va_openDriverFromPath(dpy, driver_path); |
541 | | - free(driver_path); |
542 | | - if (VA_STATUS_SUCCESS == vaStatus) |
543 | | - break; |
| 530 | + for (int use_suffix = 1; use_suffix >= 0; use_suffix--) { |
| 531 | + char *driver_path = va_getDriverPath(driver_dir, driver_name, use_suffix); |
| 532 | + if (!driver_path) { |
| 533 | + va_errorMessage(dpy, "%s L%d Out of memory\n", |
| 534 | + __FUNCTION__, __LINE__); |
| 535 | + free(search_path); |
| 536 | + return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 537 | + } |
544 | 538 |
|
| 539 | + vaStatus = va_openDriverFromPath(dpy, driver_path); |
| 540 | + free(driver_path); |
| 541 | + if (VA_STATUS_SUCCESS == vaStatus) |
| 542 | + break; |
| 543 | + } |
545 | 544 | driver_dir = strtok_r(NULL, ENV_VAR_SEPARATOR, &saveptr); |
546 | 545 | } |
547 | 546 |
|
|
0 commit comments