aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-09-21 12:08:45 -0700
committerChris Robinson <[email protected]>2019-09-21 12:08:45 -0700
commit28e62456acbbabc7313a7f6f04c66a63464de92b (patch)
treee3231e40de4cf234902169f5fe93774a65df07c2 /alc
parent8907a4fb04c50643f829034f711f7a96a69f57c9 (diff)
Use an array and loop instead of individual tests
Diffstat (limited to 'alc')
-rw-r--r--alc/mixvoice.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/alc/mixvoice.cpp b/alc/mixvoice.cpp
index 1d18a3a5..91a475f8 100644
--- a/alc/mixvoice.cpp
+++ b/alc/mixvoice.cpp
@@ -27,11 +27,9 @@
#include <climits>
#include <cstddef>
#include <cstdint>
-#include <cstring>
#include <iterator>
#include <memory>
#include <new>
-#include <numeric>
#include <string>
#include <utility>
@@ -180,29 +178,37 @@ void aluInitMixer()
{
if(auto resopt = ConfigValueStr(nullptr, nullptr, "resampler"))
{
+ struct ResamplerEntry {
+ const char name[12];
+ const Resampler resampler;
+ };
+ constexpr ResamplerEntry ResamplerList[]{
+ { "none", PointResampler },
+ { "point", PointResampler },
+ { "cubic", FIR4Resampler },
+ { "bsinc12", BSinc12Resampler },
+ { "bsinc24", BSinc24Resampler },
+ };
+
const char *str{resopt->c_str()};
- if(al::strcasecmp(str, "point") == 0 || al::strcasecmp(str, "none") == 0)
- ResamplerDefault = PointResampler;
- else if(al::strcasecmp(str, "linear") == 0)
- ResamplerDefault = LinearResampler;
- else if(al::strcasecmp(str, "cubic") == 0)
- ResamplerDefault = FIR4Resampler;
- else if(al::strcasecmp(str, "bsinc12") == 0)
- ResamplerDefault = BSinc12Resampler;
- else if(al::strcasecmp(str, "bsinc24") == 0)
- ResamplerDefault = BSinc24Resampler;
- else if(al::strcasecmp(str, "bsinc") == 0)
+ if(al::strcasecmp(str, "bsinc") == 0)
{
WARN("Resampler option \"%s\" is deprecated, using bsinc12\n", str);
- ResamplerDefault = BSinc12Resampler;
+ str = "bsinc12";
}
else if(al::strcasecmp(str, "sinc4") == 0 || al::strcasecmp(str, "sinc8") == 0)
{
WARN("Resampler option \"%s\" is deprecated, using cubic\n", str);
- ResamplerDefault = FIR4Resampler;
+ str = "cubic";
}
- else
+
+ auto iter = std::find_if(std::begin(ResamplerList), std::end(ResamplerList),
+ [str](const ResamplerEntry &entry) -> bool
+ { return al::strcasecmp(str, entry.name) == 0; });
+ if(iter == std::end(ResamplerList))
ERR("Invalid resampler: %s\n", str);
+ else
+ ResamplerDefault = iter->resampler;
}
MixHrtfBlendSamples = SelectHrtfBlendMixer();