diff --git a/src/per/sai.cpp b/src/per/sai.cpp index d581f99c5..8b0787939 100644 --- a/src/per/sai.cpp +++ b/src/per/sai.cpp @@ -23,7 +23,7 @@ class SaiHandle::Impl SaiHandle::Result StopDmaTransfer(); // Utility functions - float GetSampleRate(); + constexpr float GetSampleRate(); size_t GetBlockSize(); float GetBlockRate(); @@ -333,17 +333,9 @@ SaiHandle::Result SaiHandle::Impl::StopDmaTransfer() return Result::OK; } -float SaiHandle::Impl::GetSampleRate() +constexpr float SaiHandle::Impl::GetSampleRate() { - switch(config_.sr) - { - case Config::SampleRate::SAI_8KHZ: return 8000.f; - case Config::SampleRate::SAI_16KHZ: return 16000.f; - case Config::SampleRate::SAI_32KHZ: return 32000.f; - case Config::SampleRate::SAI_48KHZ: return 48000.f; - case Config::SampleRate::SAI_96KHZ: return 96000.f; - default: return 48000.f; - } + return config_.sr; } size_t SaiHandle::Impl::GetBlockSize() { diff --git a/src/per/sai.h b/src/per/sai.h index 54c0e72a9..dad3753a1 100644 --- a/src/per/sai.h +++ b/src/per/sai.h @@ -54,13 +54,13 @@ class SaiHandle }; /** Rate at which samples will be streaming to/from the device. */ - enum class SampleRate + enum SampleRate : int { - SAI_8KHZ, - SAI_16KHZ, - SAI_32KHZ, - SAI_48KHZ, - SAI_96KHZ, + SAI_8KHZ = 8000, + SAI_16KHZ = 16000, + SAI_32KHZ = 32000, + SAI_48KHZ = 48000, + SAI_96KHZ = 96000, }; /** Bit Depth that the hardware expects to be transferred to/from the device. */