From ead22a2ad8e458ec34514e23b291aab5146c9f95 Mon Sep 17 00:00:00 2001 From: Artem Dyomin Date: Wed, 24 Jan 2024 11:59:50 +0100 Subject: Fix build with ffmpeg swrresample version < 4.9.100 swr_alloc_set_opts2 takes 'const AVChannelLayout*' from LIBSWRESAMPLE_VERSION 4.9.100 Fixes: QTBUG-121455 Pick-to: 6.6 6.5 Change-Id: I06812f9efedd53e12152fb3cf1574ad8c7c61d27 Reviewed-by: Artem Dyomin (cherry picked from commit b0cffad4411a0c8d6469a892bcf98cf4384ae6f5) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/multimedia/ffmpeg/qffmpeg.cpp | 11 +++++++++-- src/plugins/multimedia/ffmpeg/qffmpeg_p.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/multimedia/ffmpeg/qffmpeg.cpp b/src/plugins/multimedia/ffmpeg/qffmpeg.cpp index f5b97566a..d7095edee 100644 --- a/src/plugins/multimedia/ffmpeg/qffmpeg.cpp +++ b/src/plugins/multimedia/ffmpeg/qffmpeg.cpp @@ -479,11 +479,18 @@ SwrContextUPtr createResampleContext(const ResampleAudioFormat& inputFormat, 0, nullptr); #else + +#if QT_FFMPEG_SWR_CONST_CH_LAYOUT + using AVChannelLayoutPrm = const AVChannelLayout*; +#else + using AVChannelLayoutPrm = AVChannelLayout*; +#endif + swr_alloc_set_opts2(&resampler, - &outputFormat.channelLayout, + const_cast(&outputFormat.channelLayout), outputFormat.sampleFormat, outputFormat.sampleRate, - &inputFormat.channelLayout, + const_cast(&inputFormat.channelLayout), inputFormat.sampleFormat, inputFormat.sampleRate, 0, diff --git a/src/plugins/multimedia/ffmpeg/qffmpeg_p.h b/src/plugins/multimedia/ffmpeg/qffmpeg_p.h index 27d5e723c..76c50887f 100644 --- a/src/plugins/multimedia/ffmpeg/qffmpeg_p.h +++ b/src/plugins/multimedia/ffmpeg/qffmpeg_p.h @@ -24,6 +24,8 @@ extern "C" { (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(60, 3, 100)) // since ffmpeg n6.0 #define QT_FFMPEG_STREAM_SIDE_DATA_DEPRECATED \ (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(60, 15, 100)) // since ffmpeg n6.1 +#define QT_FFMPEG_SWR_CONST_CH_LAYOUT \ + (LIBSWRESAMPLE_VERSION_INT >= AV_VERSION_INT(4, 9, 100)) QT_BEGIN_NAMESPACE -- cgit v1.2.3