diff options
author | Chris Robinson <[email protected]> | 2020-11-25 13:55:29 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-11-25 13:55:29 -0800 |
commit | 32b9a46b39e3bfb3ccf1e05c520ce40232efa5d9 (patch) | |
tree | 9fbf486aca18ac198bb7827661d9ac60c394b645 /al/effects/dedicated.cpp | |
parent | 3970252da9d3148ea0b45990bb2476ee3b99fb0c (diff) |
Move AL EffectProp handling to separate sources
Diffstat (limited to 'al/effects/dedicated.cpp')
-rw-r--r-- | al/effects/dedicated.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/al/effects/dedicated.cpp b/al/effects/dedicated.cpp new file mode 100644 index 00000000..334d9e56 --- /dev/null +++ b/al/effects/dedicated.cpp @@ -0,0 +1,72 @@ + +#include "config.h" + +#include <cmath> + +#include "AL/al.h" +#include "AL/efx.h" + +#include "effects.h" +#include "effects/base.h" + + +namespace { + +void Dedicated_setParami(EffectProps*, ALenum param, int) +{ throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param}; } +void Dedicated_setParamiv(EffectProps*, ALenum param, const int*) +{ + throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x", + param}; +} +void Dedicated_setParamf(EffectProps *props, ALenum param, float val) +{ + switch(param) + { + case AL_DEDICATED_GAIN: + if(!(val >= 0.0f && std::isfinite(val))) + throw effect_exception{AL_INVALID_VALUE, "Dedicated gain out of range"}; + props->Dedicated.Gain = val; + break; + + default: + throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param}; + } +} +void Dedicated_setParamfv(EffectProps *props, ALenum param, const float *vals) +{ Dedicated_setParamf(props, param, vals[0]); } + +void Dedicated_getParami(const EffectProps*, ALenum param, int*) +{ throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param}; } +void Dedicated_getParamiv(const EffectProps*, ALenum param, int*) +{ + throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x", + param}; +} +void Dedicated_getParamf(const EffectProps *props, ALenum param, float *val) +{ + switch(param) + { + case AL_DEDICATED_GAIN: + *val = props->Dedicated.Gain; + break; + + default: + throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param}; + } +} +void Dedicated_getParamfv(const EffectProps *props, ALenum param, float *vals) +{ Dedicated_getParamf(props, param, vals); } + +EffectProps genDefaultProps() noexcept +{ + EffectProps props{}; + props.Dedicated.Gain = 1.0f; + return props; +} + +} // namespace + +DEFINE_ALEFFECT_VTABLE(Dedicated); + +const EffectProps DedicatedEffectProps{genDefaultProps()}; |