| 1 | From 3c20057d0cbbbed453a692d4dd4589d865808024 Mon Sep 17 00:00:00 2001
|
| 2 | From: Liliana Marie Prikler <[email protected]>
|
| 3 | Date: Sat, 29 Jan 2022 10:44:44 +0100
|
| 4 | Subject: [PATCH] Add pkg-config fallback for locating ffmpeg.
|
| 5 |
|
| 6 | Audacity >=3.1.0 no longer links against ffmpeg, but instead dynamically loads
|
| 7 | it. This dynamic loading mechanism fails to properly locate libraries outside
|
| 8 | of LD_LIBRARY_PATH.
|
| 9 |
|
| 10 | See <https://issues.guix.gnu.org/53591>.
|
| 11 |
|
| 12 | Bugs-added-by: Marius Bakke <[email protected]>
|
| 13 |
|
| 14 | diff --git a/libraries/lib-ffmpeg-support/CMakeLists.txt b/libraries/lib-ffmpeg-support/CMakeLists.txt
|
| 15 | index b8803a1f5..f86559cca 100644
|
| 16 | |
| 17 | |
| 18 | @@ -1,5 +1,7 @@
|
| 19 |
|
| 20 | if (${_OPT}use_ffmpeg)
|
| 21 | + pkg_check_modules(FFMPEG libavcodec libavformat libavutil)
|
| 22 | +
|
| 23 | set( SOURCES
|
| 24 | FFmpegTypes.h
|
| 25 |
|
| 26 | @@ -107,6 +109,12 @@ if (${_OPT}use_ffmpeg)
|
| 27 | list(APPEND DEFINITIONS PRIVATE _DARWIN_C_SOURCE )
|
| 28 | endif()
|
| 29 |
|
| 30 | + if (FFMPEG_FOUND)
|
| 31 | + pkg_get_variable(LIBAVCODEC_LIBDIR libavcodec libdir)
|
| 32 | + list(APPEND DEFINITIONS PRIVATE
|
| 33 | + "-DFFMPEG_PC_LIBDIR=\"${LIBAVCODEC_LIBDIR}\"")
|
| 34 | + endif()
|
| 35 | +
|
| 36 | audacity_library( lib-ffmpeg-support "${SOURCES}" "${LIBRARIES}"
|
| 37 | "${DEFINITIONS}" ""
|
| 38 | )
|
| 39 | diff --git a/libraries/lib-ffmpeg-support/FFmpegFunctions.cpp b/libraries/lib-ffmpeg-support/FFmpegFunctions.cpp
|
| 40 | index 55d6f676b..46640ef83 100644
|
| 41 | |
| 42 | |
| 43 | @@ -246,6 +246,18 @@ struct FFmpegFunctions::Private final
|
| 44 | if (library->IsLoaded())
|
| 45 | return library;
|
| 46 |
|
| 47 | +#if defined(FFMPEG_PC_LIBDIR)
|
| 48 | + {
|
| 49 | + static const wxString libdir{FFMPEG_PC_LIBDIR};
|
| 50 | + const wxString fullName = wxFileName(libdir, libraryName).GetFullPath();
|
| 51 | +
|
| 52 | + auto library = std::make_shared<wxDynamicLibrary>(fullName);
|
| 53 | +
|
| 54 | + if (library->IsLoaded())
|
| 55 | + return library;
|
| 56 | + }
|
| 57 | +#endif
|
| 58 | +
|
| 59 | return {};
|
| 60 | }
|
| 61 | };
|