]> git.tdb.fi Git - ext/openal.git/blob - al/effects/null.cpp
Import OpenAL Soft 1.23.1 sources
[ext/openal.git] / al / effects / null.cpp
1
2 #include "config.h"
3
4 #include "AL/al.h"
5 #include "AL/efx.h"
6
7 #include "alc/effects/base.h"
8 #include "effects.h"
9
10 #ifdef ALSOFT_EAX
11 #include "al/eax/exception.h"
12 #endif // ALSOFT_EAX
13
14
15 namespace {
16
17 void Null_setParami(EffectProps* /*props*/, ALenum param, int /*val*/)
18 {
19     switch(param)
20     {
21     default:
22         throw effect_exception{AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x",
23             param};
24     }
25 }
26 void Null_setParamiv(EffectProps *props, ALenum param, const int *vals)
27 {
28     switch(param)
29     {
30     default:
31         Null_setParami(props, param, vals[0]);
32     }
33 }
34 void Null_setParamf(EffectProps* /*props*/, ALenum param, float /*val*/)
35 {
36     switch(param)
37     {
38     default:
39         throw effect_exception{AL_INVALID_ENUM, "Invalid null effect float property 0x%04x",
40             param};
41     }
42 }
43 void Null_setParamfv(EffectProps *props, ALenum param, const float *vals)
44 {
45     switch(param)
46     {
47     default:
48         Null_setParamf(props, param, vals[0]);
49     }
50 }
51
52 void Null_getParami(const EffectProps* /*props*/, ALenum param, int* /*val*/)
53 {
54     switch(param)
55     {
56     default:
57         throw effect_exception{AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x",
58             param};
59     }
60 }
61 void Null_getParamiv(const EffectProps *props, ALenum param, int *vals)
62 {
63     switch(param)
64     {
65     default:
66         Null_getParami(props, param, vals);
67     }
68 }
69 void Null_getParamf(const EffectProps* /*props*/, ALenum param, float* /*val*/)
70 {
71     switch(param)
72     {
73     default:
74         throw effect_exception{AL_INVALID_ENUM, "Invalid null effect float property 0x%04x",
75             param};
76     }
77 }
78 void Null_getParamfv(const EffectProps *props, ALenum param, float *vals)
79 {
80     switch(param)
81     {
82     default:
83         Null_getParamf(props, param, vals);
84     }
85 }
86
87 EffectProps genDefaultProps() noexcept
88 {
89     EffectProps props{};
90     return props;
91 }
92
93 } // namespace
94
95 DEFINE_ALEFFECT_VTABLE(Null);
96
97 const EffectProps NullEffectProps{genDefaultProps()};
98
99
100 #ifdef ALSOFT_EAX
101 namespace {
102
103 using NullCommitter = EaxCommitter<EaxNullCommitter>;
104
105 } // namespace
106
107 template<>
108 struct NullCommitter::Exception : public EaxException
109 {
110     explicit Exception(const char *message) : EaxException{"EAX_NULL_EFFECT", message}
111     { }
112 };
113
114 template<>
115 [[noreturn]] void NullCommitter::fail(const char *message)
116 {
117     throw Exception{message};
118 }
119
120 template<>
121 bool NullCommitter::commit(const EaxEffectProps &props)
122 {
123     const bool ret{props.mType != mEaxProps.mType};
124     mEaxProps = props;
125     return ret;
126 }
127
128 template<>
129 void NullCommitter::SetDefaults(EaxEffectProps &props)
130 {
131     props = EaxEffectProps{};
132     props.mType = EaxEffectType::None;
133 }
134
135 template<>
136 void NullCommitter::Get(const EaxCall &call, const EaxEffectProps&)
137 {
138     if(call.get_property_id() != 0)
139         fail_unknown_property_id();
140 }
141
142 template<>
143 void NullCommitter::Set(const EaxCall &call, EaxEffectProps&)
144 {
145     if(call.get_property_id() != 0)
146         fail_unknown_property_id();
147 }
148
149 #endif // ALSOFT_EAX