From 48206bcf95b580984b44e905fb5530965c6173c0 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 27 Aug 2023 00:08:29 +0400 Subject: [PATCH] Re-use base_linux_library --- .../SourceFiles/ffmpeg/ffmpeg_utility.cpp | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp index e105cd4418..a2072b0652 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp @@ -10,19 +10,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/algorithm.h" #include "logs.h" +#if !defined DESKTOP_APP_USE_PACKAGED && !defined Q_OS_WIN && !defined Q_OS_MAC +#include "base/platform/linux/base_linux_library.h" +#include +#endif // !DESKTOP_APP_USE_PACKAGED && !Q_OS_WIN && !Q_OS_MAC + #include #ifdef LIB_FFMPEG_USE_QT_PRIVATE_API #include #endif // LIB_FFMPEG_USE_QT_PRIVATE_API -#include - extern "C" { #include -#if !defined DESKTOP_APP_USE_PACKAGED && !defined Q_OS_WIN && !defined Q_OS_MAC -#include -#endif // !DESKTOP_APP_USE_PACKAGED && !Q_OS_WIN && !Q_OS_MAC } // extern "C" namespace FFmpeg { @@ -95,19 +95,10 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { auto list = std::deque{ AV_PIX_FMT_CUDA, }; - const auto vdpau = [&] { - if (const auto handle = dlopen("libvdpau.so.1", RTLD_LAZY)) { - dlclose(handle); - } - if (dlerror()) { - return false; - } - return true; - }(); - if (vdpau) { + if (base::Platform::LoadLibrary("libvdpau.so.1")) { list.push_front(AV_PIX_FMT_VDPAU); } - const auto va = [&] { + if ([&] { const auto list = std::array{ "libva-drm.so.1", "libva-x11.so.1", @@ -115,16 +106,12 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { "libdrm.so.2", }; for (const auto lib : list) { - if (const auto handle = dlopen(lib, RTLD_LAZY)) { - dlclose(handle); - } - if (dlerror()) { + if (!base::Platform::LoadLibrary(lib)) { return false; } } return true; - }(); - if (va) { + }()) { list.push_front(AV_PIX_FMT_VAAPI); } return list;