diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-05-07 14:02:28 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-05-07 12:22:28 +0000 |
commit | a0cae0211a9b3f8db7ea8807f02b0d47380e480c (patch) | |
tree | 81b0e51399fadc953222223ff4d159e761b9c2a5 | |
parent | ab84e0deb641a0976412feeaf03ee4b98c4652b6 (diff) |
Fix build on Windows
MSVC correctly complains that bytesPerFrame cannot be constexpr, as
bytesPerSample isn't.
Since bytesPerSample is a trivial switch, make it constexpr as well.
Change-Id: I3a803624639d0931c13776a14eca1f4b09a68492
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | src/multimedia/audio/qaudioformat.cpp | 17 | ||||
-rw-r--r-- | src/multimedia/audio/qaudioformat.h | 13 |
2 files changed, 13 insertions, 17 deletions
diff --git a/src/multimedia/audio/qaudioformat.cpp b/src/multimedia/audio/qaudioformat.cpp index fa9b8f740..404dda49e 100644 --- a/src/multimedia/audio/qaudioformat.cpp +++ b/src/multimedia/audio/qaudioformat.cpp @@ -267,26 +267,11 @@ qint64 QAudioFormat::durationForFrames(qint32 frameCount) const */ /*! + \fn int QAudioFormat::bytesPerSample() const Returns the number of bytes required to represent one sample in this format. Returns 0 if this format is invalid. */ -int QAudioFormat::bytesPerSample() const -{ - switch (m_sampleFormat) { - case Unknown: - case NSampleFormats: - return 0; - case UInt8: - return 1; - case Int16: - return 2; - case Int32: - case Float: - return 4; - } - return 0; -} /*! Normalizes the sample value to a number between -1 and 1. diff --git a/src/multimedia/audio/qaudioformat.h b/src/multimedia/audio/qaudioformat.h index 1b4eb170f..ee33ab5d8 100644 --- a/src/multimedia/audio/qaudioformat.h +++ b/src/multimedia/audio/qaudioformat.h @@ -87,7 +87,18 @@ public: Q_MULTIMEDIA_EXPORT qint64 durationForFrames(qint32 frameCount) const; constexpr int bytesPerFrame() const { return bytesPerSample()*channelCount(); } - Q_MULTIMEDIA_EXPORT int bytesPerSample() const; + constexpr int bytesPerSample() const noexcept + { + switch (m_sampleFormat) { + case Unknown: + case NSampleFormats: return 0; + case UInt8: return 1; + case Int16: return 2; + case Int32: + case Float: return 4; + } + return 0; + } Q_MULTIMEDIA_EXPORT float normalizedSampleValue(const void *sample) const; |