Fix setting Ambi formats for loopback devices
[openal-soft.git] / Alc / effects / null.c
blobbff00b567de856a5ad431406b47f3bd40a377c9c
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 ALCdevice *device, const ALeffectslot *slot, const ALeffectProps *props);
20 static ALvoid ALnullState_process(ALnullState *state, ALuint samplesToDo, const ALfloatBUFFERSIZE*restrict samplesIn, ALfloatBUFFERSIZE*restrict samplesOut, ALuint NumChannels);
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 ALCdevice* UNUSED(device), 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), ALuint UNUSED(samplesToDo), const ALfloatBUFFERSIZE*restrict UNUSED(samplesIn), ALfloatBUFFERSIZE*restrict UNUSED(samplesOut), ALuint 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 ALnullStateFactory {
89 DERIVE_FROM_TYPE(ALeffectStateFactory);
90 } ALnullStateFactory;
92 /* Creates ALeffectState objects of the appropriate type. */
93 ALeffectState *ALnullStateFactory_create(ALnullStateFactory *UNUSED(factory))
95 ALnullState *state;
97 NEW_OBJ0(state, ALnullState)();
98 if(!state) return NULL;
100 return STATIC_CAST(ALeffectState, state);
103 /* Define the ALeffectStateFactory vtable for this type. */
104 DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALnullStateFactory);
106 ALeffectStateFactory *ALnullStateFactory_getFactory(void)
108 static ALnullStateFactory NullFactory = { { GET_VTABLE2(ALnullStateFactory, ALeffectStateFactory) } };
109 return STATIC_CAST(ALeffectStateFactory, &NullFactory);
113 void ALnull_setParami(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val))
115 switch(param)
117 default:
118 SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
121 void ALnull_setParamiv(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, const ALint* UNUSED(vals))
123 switch(param)
125 default:
126 SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
129 void ALnull_setParamf(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val))
131 switch(param)
133 default:
134 SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
137 void ALnull_setParamfv(ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat* UNUSED(vals))
139 switch(param)
141 default:
142 SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
146 void ALnull_getParami(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(val))
148 switch(param)
150 default:
151 SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
154 void ALnull_getParamiv(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(vals))
156 switch(param)
158 default:
159 SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
162 void ALnull_getParamf(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(val))
164 switch(param)
166 default:
167 SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
170 void ALnull_getParamfv(const ALeffect* UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(vals))
172 switch(param)
174 default:
175 SET_ERROR_AND_RETURN(context, AL_INVALID_ENUM);
179 DEFINE_ALEFFECT_VTABLE(ALnull);