diff --git a/src/audio/types.h b/src/audio/types.h index 6967fc5d5d1..a94697fd838 100644 --- a/src/audio/types.h +++ b/src/audio/types.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "util/assert.h" #include "util/optional.h" @@ -34,7 +35,9 @@ QDebug operator<<(QDebug dbg, ChannelLayout arg); class ChannelCount { public: - typedef SINT value_t; + // Use a native type with more than 8 bits to avoid -Werror=type-limits + // errors on comparisons with the min/max constants. + typedef uint16_t value_t; private: // The default value is invalid and indicates a missing or unknown value. @@ -73,8 +76,7 @@ class ChannelCount { } constexpr bool isValid() const { - return (kValueMin <= m_value) && - (m_value <= kValueMax); + return kValueMin <= m_value && m_value <= kValueMax; } /*implicit*/ constexpr operator value_t() const { @@ -87,7 +89,7 @@ class ChannelCount { class SampleRate { public: - typedef SINT value_t; + typedef uint32_t value_t; private: // The default value is invalid and indicates a missing or unknown value. @@ -114,8 +116,7 @@ class SampleRate { } constexpr bool isValid() const { - return (kValueMin <= m_value) && - (m_value <= kValueMax); + return kValueMin <= m_value && m_value <= kValueMax; } void operator=(const value_t& value) { @@ -145,7 +146,7 @@ QDebug operator<<(QDebug dbg, SampleRate arg); // expected quality. class Bitrate { public: - typedef SINT value_t; + typedef uint32_t value_t; private: // The default value is invalid and indicates a missing or unknown value. diff --git a/src/encoder/encoderopus.cpp b/src/encoder/encoderopus.cpp index c65c6c59d12..6c6e9d3dd4f 100644 --- a/src/encoder/encoderopus.cpp +++ b/src/encoder/encoderopus.cpp @@ -21,7 +21,7 @@ constexpr int kMaxOpusBufferSize = 1+1275; constexpr int kOpusFrameMs = 60; constexpr int kOpusChannelCount = 2; // Opus only supports 48 and 96 kHz samplerates -constexpr int kMasterSamplerate = 48000; +constexpr mixxx::audio::SampleRate kMasterSamplerate = mixxx::audio::SampleRate(48000); const mixxx::Logger kLogger("EncoderOpus"); @@ -73,7 +73,7 @@ int getSerial() { } // namespace //static -int EncoderOpus::getMasterSamplerate() { +mixxx::audio::SampleRate EncoderOpus::getMasterSamplerate() { return kMasterSamplerate; } diff --git a/src/encoder/encoderopus.h b/src/encoder/encoderopus.h index d51be33d385..733b112bc47 100644 --- a/src/encoder/encoderopus.h +++ b/src/encoder/encoderopus.h @@ -1,12 +1,13 @@ #pragma once +#include +#include + #include #include #include -#include -#include - +#include "audio/types.h" #include "encoder/encoder.h" #include "encoder/encodercallback.h" #include "util/fifo.h" @@ -16,7 +17,7 @@ class EncoderOpus: public Encoder { public: - static int getMasterSamplerate(); + static mixxx::audio::SampleRate getMasterSamplerate(); static QString getInvalidSamplerateMessage(); explicit EncoderOpus(EncoderCallback* pCallback = nullptr);