Allow building alffplay without experimental extensions
[openal-soft.git] / Alc / effects / null.c
blobe57359e39e0bc1a53742235e6a8b7518a96f268e
1 #include "config.h"
3 #include <stdlib.h>
5 #include "AL/al.h"
6 #include "AL/alc.h"
7 #include "alMain.h"
8 #include "alAuxEffectSlot.h"
9 #include "alError.h"
12 typedef struct ALnullState {
13 DERIVE_FROM_TYPE(ALeffectState);
14 } ALnullState;
16 /* Forward-declare "virtual" functions to define the vtable with. */
17 static ALvoid ALnullState_Destruct(ALnullState *state);
18 static ALboolean ALnullState_deviceUpdate(ALnullState *state, ALCdevice *device);
19 static ALvoid ALnullState_update(ALnullState *state, const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props);
20 static ALvoid ALnullState_process(ALnullState *state, ALsizei samplesToDo, const ALfloat (*restrict samplesIn)[BUFFERSIZE], ALfloat (*restrict samplesOut)[BUFFERSIZE], ALsizei mumChannels);
21 static void *ALnullState_New(size_t size);
22 static void ALnullState_Delete(void *ptr);
24 /* Define the ALeffectState vtable for this type. */
25 DEFINE_ALEFFECTSTATE_VTABLE(ALnullState);
28 /* This constructs the effect state. It's called when the object is first
29 * created. Make sure to call the parent Construct function first, and set the
30 * vtable!
32 static void ALnullState_Construct(ALnullState *state)
34 ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
35 SET_VTABLE2(ALnullState, ALeffectState, state);
38 /* This destructs (not free!) the effect state. It's called only when the
39 * effect slot is no longer used. Make sure to call the parent Destruct
40 * function before returning!
42 static ALvoid ALnullState_Destruct(ALnullState *state)
44 ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
47 /* This updates the device-dependant effect state. This is called on
48 * initialization and any time the device parameters (eg. playback frequency,
49 * format) have been changed.
51 static ALboolean ALnullState_deviceUpdate(ALnullState* UNUSED(state), ALCdevice* UNUSED(device))
53 return AL_TRUE;
56 /* This updates the effect state. This is called any time the effect is
57 * (re)loaded into a slot.
59 static ALvoid ALnullState_update(ALnullState* UNUSED(state), const ALCcontext* UNUSED(context), const ALeffectslot* UNUSED(slot), const ALeffectProps* UNUSED(props))
63 /* This processes the effect state, for the given number of samples from the
64 * input to the output buffer. The result should be added to the output buffer,
65 * not replace it.
67 static ALvoid ALnullState_process(ALnullState* UNUSED(state), ALsizei UNUSED(samplesToDo), const ALfloatBUFFERSIZE*restrict UNUSED(samplesIn), ALfloatBUFFERSIZE*restrict UNUSED(samplesOut), ALsizei UNUSED(numChannels))
71 /* This allocates memory to store the object, before it gets constructed.
72 * DECLARE_DEFAULT_ALLOCATORS can be used to declare a default method.
74 static void *ALnullState_New(size_t size)
76 return al_malloc(16, size);
79 /* This frees the memory used by the object, after it has been destructed.
80 * DECLARE_DEFAULT_ALLOCATORS can be used to declare a default method.
82 static void ALnullState_Delete(void *ptr)
84 al_free(ptr);
88 typedef struct NullStateFactory {
89 DERIVE_FROM_TYPE(EffectStateFactory);
90 } NullStateFactory;
92 /* Creates ALeffectState objects of the appropriate type. */
93 ALeffectState *NullStateFactory_create(NullStateFactory *UNUSED(factory))
95 ALnullState *state;
97 NEW_OBJ0(state, ALnullState)();
98 if(!state) return NULL;
100 return STATIC_CAST(ALeffectState, state);
103 /* Define the EffectStateFactory vtable for this type. */
104 DEFINE_EFFECTSTATEFACTORY_VTABLE(NullStateFactory);
106 EffectStateFactory *NullStateFactory_getFactory(void)
108 static NullStateFactory NullFactory = { { GET_VTABLE2(NullStateFactory, EffectStateFactory) } };
109 return STATIC_CAST(EffectStateFactory, &NullFactory);
113 void ALnull_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val))
115 switch(param)
117 default:
118 alSetError(context, AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x", param);
121 void ALnull_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint* UNUSED(vals))
123 switch(param)
125 default:
126 alSetError(context, AL_INVALID_ENUM, "Invalid null effect integer-vector property 0x%04x", param);
129 void ALnull_setParamf(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val))
131 switch(param)
133 default:
134 alSetError(context, AL_INVALID_ENUM, "Invalid null effect float property 0x%04x", param);
137 void ALnull_setParamfv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat* UNUSED(vals))
139 switch(param)
141 default:
142 alSetError(context, AL_INVALID_ENUM, "Invalid null effect float-vector property 0x%04x", param);
146 void ALnull_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(val))
148 switch(param)
150 default:
151 alSetError(context, AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x", param);
154 void ALnull_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(vals))
156 switch(param)
158 default:
159 alSetError(context, AL_INVALID_ENUM, "Invalid null effect integer-vector property 0x%04x", param);
162 void ALnull_getParamf(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(val))
164 switch(param)
166 default:
167 alSetError(context, AL_INVALID_ENUM, "Invalid null effect float property 0x%04x", param);
170 void ALnull_getParamfv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(vals))
172 switch(param)
174 default:
175 alSetError(context, AL_INVALID_ENUM, "Invalid null effect float-vector property 0x%04x", param);
179 DEFINE_ALEFFECT_VTABLE(ALnull);