diff options
author | Chris Robinson <[email protected]> | 2018-12-08 21:58:44 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-08 21:58:44 -0800 |
commit | e5db9b237847db74a9228e2da925c0b6f127ab28 (patch) | |
tree | 4582f41a0ebfdf3296dbc6f6f06f36c25cfe479c /Alc/alu.cpp | |
parent | a4009c47e7086611e70bafdf36666b40209f6608 (diff) |
Avoid static global initialization functions
Diffstat (limited to 'Alc/alu.cpp')
-rw-r--r-- | Alc/alu.cpp | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp index 34634983..f7640d71 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -49,14 +49,45 @@ #include "bsinc_inc.h" +namespace { + +ALfloat InitConeScale() +{ + ALfloat ret{1.0f}; + const char *str{getenv("__ALSOFT_HALF_ANGLE_CONES")}; + if(str && (strcasecmp(str, "true") == 0 || strtol(str, nullptr, 0) == 1)) + ret *= 0.5f; + return ret; +} + +ALfloat InitZScale() +{ + ALfloat ret{1.0f}; + const char *str{getenv("__ALSOFT_REVERSE_Z")}; + if(str && (strcasecmp(str, "true") == 0 || strtol(str, nullptr, 0) == 1)) + ret *= -1.0f; + return ret; +} + +ALboolean InitReverbSOS() +{ + ALboolean ret{AL_FALSE}; + const char *str{getenv("__ALSOFT_REVERB_IGNORES_SOUND_SPEED")}; + if(str && (strcasecmp(str, "true") == 0 || strtol(str, nullptr, 0) == 1)) + ret = AL_TRUE; + return ret; +} + +} // namespace + /* Cone scalar */ -ALfloat ConeScale = 1.0f; +const ALfloat ConeScale{InitConeScale()}; /* Localized Z scalar for mono sources */ -ALfloat ZScale = 1.0f; +const ALfloat ZScale{InitZScale()}; /* Force default speed of sound for distance-related reverb decay. */ -ALboolean OverrideReverbSpeedOfSound = AL_FALSE; +const ALboolean OverrideReverbSpeedOfSound{InitReverbSOS()}; namespace { |