]> git.tdb.fi Git - ext/openal.git/blob - al/effects/dedicated.cpp
Import OpenAL Soft 1.23.1 sources
[ext/openal.git] / al / effects / dedicated.cpp
1
2 #include "config.h"
3
4 #include <cmath>
5
6 #include "AL/al.h"
7 #include "AL/alext.h"
8
9 #include "alc/effects/base.h"
10 #include "effects.h"
11
12
13 namespace {
14
15 void Dedicated_setParami(EffectProps*, ALenum param, int)
16 { throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param}; }
17 void Dedicated_setParamiv(EffectProps*, ALenum param, const int*)
18 {
19     throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x",
20         param};
21 }
22 void Dedicated_setParamf(EffectProps *props, ALenum param, float val)
23 {
24     switch(param)
25     {
26     case AL_DEDICATED_GAIN:
27         if(!(val >= 0.0f && std::isfinite(val)))
28             throw effect_exception{AL_INVALID_VALUE, "Dedicated gain out of range"};
29         props->Dedicated.Gain = val;
30         break;
31
32     default:
33         throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param};
34     }
35 }
36 void Dedicated_setParamfv(EffectProps *props, ALenum param, const float *vals)
37 { Dedicated_setParamf(props, param, vals[0]); }
38
39 void Dedicated_getParami(const EffectProps*, ALenum param, int*)
40 { throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param}; }
41 void Dedicated_getParamiv(const EffectProps*, ALenum param, int*)
42 {
43     throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x",
44         param};
45 }
46 void Dedicated_getParamf(const EffectProps *props, ALenum param, float *val)
47 {
48     switch(param)
49     {
50     case AL_DEDICATED_GAIN:
51         *val = props->Dedicated.Gain;
52         break;
53
54     default:
55         throw effect_exception{AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param};
56     }
57 }
58 void Dedicated_getParamfv(const EffectProps *props, ALenum param, float *vals)
59 { Dedicated_getParamf(props, param, vals); }
60
61 EffectProps genDefaultProps() noexcept
62 {
63     EffectProps props{};
64     props.Dedicated.Gain = 1.0f;
65     return props;
66 }
67
68 } // namespace
69
70 DEFINE_ALEFFECT_VTABLE(Dedicated);
71
72 const EffectProps DedicatedEffectProps{genDefaultProps()};