From cc557c4d60f0b6545c6720ac0b11ddf03b1e5670 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 19 Jul 2022 15:11:59 -0700 Subject: [PATCH 1/4] meson: port ncpmc iconv solution Properly deals with iconv, unlike the current solution. have_iconv fails when libiconv CFLAGS are passed to the compiler. Tested under OpenWrt with its CONFIG_BUILD_NLS, which adds libiconv include flags. Signed-off-by: Rosen Penev --- NEWS | 1 + src/lib/icu/meson.build | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 60016adfa..76fe8a886 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ver 0.23.9 (not yet released) * output - pipewire: set app icon +* improve iconv detection ver 0.23.8 (2022/07/09) * storage diff --git a/src/lib/icu/meson.build b/src/lib/icu/meson.build index 6e489876b..92f9e6b1f 100644 --- a/src/lib/icu/meson.build +++ b/src/lib/icu/meson.build @@ -18,17 +18,25 @@ if icu_dep.found() 'Util.cxx', 'Init.cxx', ] -elif not get_option('iconv').disabled() - # an installed iconv library will make the builtin iconv() unavailable, - # so search for the library first and pass it as (possible) dependency - iconv_dep = compiler.find_library('libiconv', required: false) - have_iconv = compiler.has_function('iconv', - dependencies: iconv_dep, - prefix : '#include ') - if not have_iconv and get_option('iconv').enabled() - error('iconv() not available') +else + if meson.version().version_compare('>= 0.60') + iconv_dep = dependency('iconv', required: get_option('iconv')) + conf.set('HAVE_ICONV', iconv_dep.found()) + elif not get_option('iconv').disabled() + iconv_open_snippet = '''#include + int main() { + iconv_open("",""); + }''' + have_iconv = compiler.links(iconv_open_snippet, name: 'iconv_open') + if not have_iconv + iconv_dep = compiler.find_library('iconv', required: false) + have_iconv = compiler.links(iconv_open_snippet, dependencies: iconv_dep, name: 'iconv_open') + endif + if not have_iconv and get_option('iconv').enabled() + error('iconv() not available') + endif + conf.set('HAVE_ICONV', have_iconv) endif - conf.set('HAVE_ICONV', have_iconv) endif icu = static_library( From 59792cb0b801854ee41be72d33db9542735df754 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 27 Jul 2022 10:59:48 +0200 Subject: [PATCH 2/4] decoder/ffmpeg: wrap FFmpeg include in "extern C" Commit ebae25d175eb31 added that #include, but forgot to wrap it in "extern C", so the linker tried to look up C++ symbols, causing linker failure. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1582 --- NEWS | 2 ++ src/decoder/plugins/FfmpegIo.cxx | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 76fe8a886..704af63c1 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.23.9 (not yet released) +* decoder + - ffmpeg: support FFmpeg 5.1 * output - pipewire: set app icon * improve iconv detection diff --git a/src/decoder/plugins/FfmpegIo.cxx b/src/decoder/plugins/FfmpegIo.cxx index 2e22d9599..5b5c8b40e 100644 --- a/src/decoder/plugins/FfmpegIo.cxx +++ b/src/decoder/plugins/FfmpegIo.cxx @@ -21,10 +21,13 @@ #define __STDC_CONSTANT_MACROS #include "FfmpegIo.hxx" -#include "libavutil/mem.h" #include "../DecoderAPI.hxx" #include "input/InputStream.hxx" +extern "C" { +#include +} + AvioStream::~AvioStream() { if (io != nullptr) { From 57d5df8118ba1fa70be892d631b5d6a278cea498 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 27 Jul 2022 10:55:43 +0200 Subject: [PATCH 3/4] decoder/ffmpeg: fix FFmpeg 5.1 deprecation warnings --- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 17 +++++++++++++++-- src/lib/ffmpeg/Interleave.cxx | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index d575a6eb1..b0d9f2c3e 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -523,9 +523,15 @@ FfmpegDecode(DecoderClient &client, InputStream *input, return; } +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100) + const unsigned channels = codec_context->ch_layout.nb_channels; +#else + const unsigned channels = codec_context->channels; +#endif + const auto audio_format = CheckAudioFormat(codec_context->sample_rate, sample_format, - codec_context->channels); + channels); const SignedSongTime total_time = av_stream.duration != (int64_t)AV_NOPTS_VALUE @@ -635,10 +641,17 @@ FfmpegScanStream(AVFormatContext &format_context, TagHandler &handler) AV_TIME_BASE_Q)); const auto &codec_params = *stream.codecpar; + +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100) + const unsigned channels = codec_params.ch_layout.nb_channels; +#else + const unsigned channels = codec_params.channels; +#endif + try { handler.OnAudioFormat(CheckAudioFormat(codec_params.sample_rate, ffmpeg_sample_format(AVSampleFormat(codec_params.format)), - codec_params.channels)); + channels)); } catch (...) { } diff --git a/src/lib/ffmpeg/Interleave.cxx b/src/lib/ffmpeg/Interleave.cxx index 4e901315f..47c2a85d8 100644 --- a/src/lib/ffmpeg/Interleave.cxx +++ b/src/lib/ffmpeg/Interleave.cxx @@ -38,7 +38,11 @@ InterleaveFrame(const AVFrame &frame, FfmpegBuffer &buffer) assert(frame.nb_samples > 0); const auto format = AVSampleFormat(frame.format); +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100) + const unsigned channels = frame.ch_layout.nb_channels; +#else const unsigned channels = frame.channels; +#endif const std::size_t n_frames = frame.nb_samples; int plane_size; From fe195257d808886d8681b3779ec16789ee40257b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 27 Jul 2022 10:48:30 +0200 Subject: [PATCH 4/4] python/build/libs.py: update FFmpeg to 5.1 --- python/build/libs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/build/libs.py b/python/build/libs.py index 0fca3daca..3409c63f6 100644 --- a/python/build/libs.py +++ b/python/build/libs.py @@ -151,8 +151,8 @@ gme = CmakeProject( ) ffmpeg = FfmpegProject( - 'http://ffmpeg.org/releases/ffmpeg-5.0.1.tar.xz', - 'ef2efae259ce80a240de48ec85ecb062cecca26e4352ffb3fda562c21a93007b', + 'http://ffmpeg.org/releases/ffmpeg-5.1.tar.xz', + '55eb6aab5ee235550fa54a33eaf8bf1b4ec66c01453182b12f6a993d75698b03', 'lib/libavcodec.a', [ '--disable-shared', '--enable-static', @@ -166,7 +166,6 @@ ffmpeg = FfmpegProject( '--disable-swscale', '--disable-postproc', '--disable-avfilter', - '--disable-lzo', '--disable-faan', '--disable-pixelutils', '--disable-network',