From 4474f815af66d2ad5e501064565edb3b4bea03a7 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 25 May 2024 14:39:09 -0500 Subject: [PATCH] Only use fallback VDPAU/VAAPI driver paths on AppImages Native packages and Flatpak/Snap packages both have properly set driver path values embedded in libva.so/libvdpau.so. Let's not go splunking for drivers in random folders on those systems. --- app/streaming/video/ffmpeg-renderers/vaapi.cpp | 11 ++++++++++- app/streaming/video/ffmpeg-renderers/vdpau.cpp | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/streaming/video/ffmpeg-renderers/vaapi.cpp b/app/streaming/video/ffmpeg-renderers/vaapi.cpp index 5922bd1f..18f48386 100644 --- a/app/streaming/video/ffmpeg-renderers/vaapi.cpp +++ b/app/streaming/video/ffmpeg-renderers/vaapi.cpp @@ -277,6 +277,13 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params) break; } +#if defined(APP_IMAGE) || defined(USE_FALLBACK_DRIVER_PATHS) + // AppImages will be running with our libva.so which means they don't know about + // distro-specific driver paths. To avoid failing in this scenario, we'll hardcode + // some such paths here for common distros. Non-AppImage packaging mechanisms won't + // need this fallback because either: + // a) They are using both distro libva.so and distro libva drivers (native packages) + // b) They are using both runtime libva.so and runtime libva drivers (Flatpak/Snap) if (qEnvironmentVariableIsEmpty("LIBVA_DRIVERS_PATH")) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Trying fallback VAAPI driver paths"); @@ -298,7 +305,9 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params) ); setPathVar = true; } - else { + else +#endif + { if (setPathVar) { // Unset LIBVA_DRIVERS_PATH if we set it ourselves // and we didn't find any working VAAPI drivers. diff --git a/app/streaming/video/ffmpeg-renderers/vdpau.cpp b/app/streaming/video/ffmpeg-renderers/vdpau.cpp index 9e2569a0..ae90f9d2 100644 --- a/app/streaming/video/ffmpeg-renderers/vdpau.cpp +++ b/app/streaming/video/ffmpeg-renderers/vdpau.cpp @@ -149,6 +149,13 @@ bool VDPAURenderer::initialize(PDECODER_PARAMETERS params) AV_HWDEVICE_TYPE_VDPAU, nullptr, nullptr, 0); +#if defined(APP_IMAGE) || defined(USE_FALLBACK_DRIVER_PATHS) + // AppImages will be running with our libvdpau.so which means they don't know about + // distro-specific driver paths. To avoid failing in this scenario, we'll hardcode + // some such paths here for common distros. Non-AppImage packaging mechanisms won't + // need this fallback because either: + // a) They are using both distro libvdpau.so and distro VDPAU drivers (native packages) + // b) They are using both runtime libvdpau.so and runtime VDPAU drivers (Flatpak/Snap) if (err < 0 && qEnvironmentVariableIsEmpty("VDPAU_DRIVER_PATH")) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Trying fallback VDPAU driver paths"); @@ -173,6 +180,7 @@ bool VDPAURenderer::initialize(PDECODER_PARAMETERS params) qunsetenv("VDPAU_DRIVER_PATH"); } } +#endif if (err < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,