diff options
author | Chris Robinson <[email protected]> | 2023-12-21 00:27:39 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-12-21 00:27:39 -0800 |
commit | e349b63335e9512a8434d72368520315c7b15197 (patch) | |
tree | d071a8608b1bdfa18bd6f6455c93fe5409ef06e3 /core/mixer/defs.h | |
parent | 10693d306340dfc4c6c7ee7c71aa73a31f0b8ea9 (diff) |
Use a variant instead of a union for InterpState
Diffstat (limited to 'core/mixer/defs.h')
-rw-r--r-- | core/mixer/defs.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/core/mixer/defs.h b/core/mixer/defs.h index 6e68978c..4d0d19bf 100644 --- a/core/mixer/defs.h +++ b/core/mixer/defs.h @@ -2,7 +2,8 @@ #define CORE_MIXER_DEFS_H #include <array> -#include <stdlib.h> +#include <cstdlib> +#include <variant> #include "alspan.h" #include "core/bufferline.h" @@ -17,12 +18,12 @@ using uint = unsigned int; using float2 = std::array<float,2>; -constexpr int MixerFracBits{16}; -constexpr int MixerFracOne{1 << MixerFracBits}; -constexpr int MixerFracMask{MixerFracOne - 1}; -constexpr int MixerFracHalf{MixerFracOne >> 1}; +inline constexpr int MixerFracBits{16}; +inline constexpr int MixerFracOne{1 << MixerFracBits}; +inline constexpr int MixerFracMask{MixerFracOne - 1}; +inline constexpr int MixerFracHalf{MixerFracOne >> 1}; -constexpr float GainSilenceThreshold{0.00001f}; /* -100dB */ +inline constexpr float GainSilenceThreshold{0.00001f}; /* -100dB */ enum class Resampler : uint8_t { @@ -59,10 +60,7 @@ struct CubicState { const CubicCoefficients *filter; }; -union InterpState { - CubicState cubic; - BsincState bsinc; -}; +using InterpState = std::variant<CubicState,BsincState>; using ResamplerFunc = void(*)(const InterpState *state, const float *RESTRICT src, uint frac, const uint increment, const al::span<float> dst); |