aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-09-24 13:51:40 -0700
committerChris Robinson <[email protected]>2019-09-24 13:51:40 -0700
commit6963712d46f1c6897dc887d8a7e3e8b734466589 (patch)
treee5c7dbc9c118db97147e2f899aa72158b15f5f39 /alc
parent96865d6b992d1f0d004ed49918a545306d10427e (diff)
Use an array to match the HRTF rendering method
Diffstat (limited to 'alc')
-rw-r--r--alc/panning.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/alc/panning.cpp b/alc/panning.cpp
index 7e2408da..cdec7759 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -586,6 +586,18 @@ void InitHrtfPanning(ALCdevice *device)
ALuint ambi_order{1};
if(auto modeopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf-mode"))
{
+ struct HrtfModeEntry {
+ char name[8];
+ RenderMode mode;
+ ALuint order;
+ };
+ static constexpr HrtfModeEntry hrtf_modes[]{
+ { "full", HrtfRender, 1 },
+ { "ambi1", NormalRender, 1 },
+ { "ambi2", NormalRender, 2 },
+ { "ambi3", NormalRender, 3 },
+ };
+
const char *mode{modeopt->c_str()};
if(al::strcasecmp(mode, "basic") == 0)
{
@@ -593,25 +605,16 @@ void InitHrtfPanning(ALCdevice *device)
mode = "ambi2";
}
- if(al::strcasecmp(mode, "full") == 0)
- device->mRenderMode = HrtfRender;
- else if(al::strcasecmp(mode, "ambi1") == 0)
- {
- device->mRenderMode = NormalRender;
- ambi_order = 1;
- }
- else if(al::strcasecmp(mode, "ambi2") == 0)
- {
- device->mRenderMode = NormalRender;
- ambi_order = 2;
- }
- else if(al::strcasecmp(mode, "ambi3") == 0)
+ auto match_entry = [mode](const HrtfModeEntry &entry) -> bool
+ { return al::strcasecmp(mode, entry.name) == 0; };
+ auto iter = std::find_if(std::begin(hrtf_modes), std::end(hrtf_modes), match_entry);
+ if(iter == std::end(hrtf_modes))
+ ERR("Unexpected hrtf-mode: %s\n", mode);
+ else
{
- device->mRenderMode = NormalRender;
- ambi_order = 3;
+ device->mRenderMode = iter->mode;
+ ambi_order = iter->order;
}
- else
- ERR("Unexpected hrtf-mode: %s\n", mode);
}
TRACE("%s HRTF rendering enabled, using \"%s\"\n",
(device->mRenderMode == HrtfRender) ? "Full" :