diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-06-17 15:35:05 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-08-08 09:19:32 +0000 |
commit | 11c4ad2c8a39819c9359341ef0145984b9ac16d0 (patch) | |
tree | 7f418e5cfef57d0aca2aef9d031678f6ed36aec3 | |
parent | 1dca8d87a1317d2a69384e4cff8d486a4b12e432 (diff) |
QAudioHelpers: fix C++20 -Werror,-Wdeprecated-enum-float-conversion
Says Clang 10.0.0 -std=c++20:
qaudiohelpers.cpp:71:44: error: arithmetic between enumeration type 'QAudioHelperInternal::signedVersion<unsigned char>::(anonymous enum at /home/marc/Qt/qt5/qtmultimedia/src/multimedia/audio/qaudiohelpers.cpp:63:5)' and floating-point type 'double' is deprecated [-Werror,-Wdeprecated-enum-float-conversion]
pDst[i] = signedVersion<T>::offset + ((typename signedVersion<T>::TS)(pSrc[i] - signedVersion<T>::offset) * factor);
~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix by turning the enum { offset } into a static constexpr int
instead.
Manual conflict resolutions:
- extended the fix to the Qt5-only quint{16,32} specializations
which are missing from the Qt 6 code. For the quint32 code,
chose uint as decltype(offset), because 0x8000'0000 is not a
proper value for int, and the subtraction for which offset is
used doesn't promote its arguents to int, like for quint{8,16},
but stays in uint space, so an uint offset is suitable.
Task-number: QTBUG-104172
Change-Id: I92a22583fc5e1fc524364b64701aa8d416b82671
Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
(cherry picked from commit 94d43085b3f3327b2bf2d644c5f984391f608d3a)
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
-rw-r--r-- | src/multimedia/audio/qaudiohelpers.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/multimedia/audio/qaudiohelpers.cpp b/src/multimedia/audio/qaudiohelpers.cpp index aba4ae38f..2e31286d7 100644 --- a/src/multimedia/audio/qaudiohelpers.cpp +++ b/src/multimedia/audio/qaudiohelpers.cpp @@ -103,19 +103,19 @@ template<class T> struct signedVersion {}; template<> struct signedVersion<quint8> { typedef qint8 TS; - enum {offset = 0x80}; + static constexpr int offset = 0x80; }; template<> struct signedVersion<quint16> { typedef qint16 TS; - enum {offset = 0x8000}; + static constexpr int offset = 0x8000; }; template<> struct signedVersion<quint32> { typedef qint32 TS; - enum {offset = 0x80000000}; + static constexpr uint offset = 0x80000000; }; template<class T> void adjustUnsignedSamples(qreal factor, const void *src, void *dst, int samples) |