Update the Null effect so it can act as a guide to new effects

This commit is contained in:
Chris Robinson
2013-05-25 17:42:34 -07:00
parent e157238ce7
commit 2da6caeaa6
2 changed files with 101 additions and 22 deletions
+100 -11
View File
@@ -13,29 +13,45 @@ typedef struct ALnullStateFactory {
DERIVE_FROM_TYPE(ALeffectStateFactory);
} ALnullStateFactory;
static ALnullStateFactory NullFactory;
typedef struct ALnullState {
DERIVE_FROM_TYPE(ALeffectState);
} ALnullState;
static ALnullStateFactory NullFactory;
/* This destructs (not free!) the effect state. It's called only when the
* effect slot is no longer used.
*/
static ALvoid ALnullState_Destruct(ALnullState *state)
{
(void)state;
}
/* This updates the device-dependant effect state. This is called on
* initialization and any time the device parameters (eg. playback frequency,
* format) have been changed.
*/
static ALboolean ALnullState_DeviceUpdate(ALnullState *state, ALCdevice *device)
{
return AL_TRUE;
(void)state;
(void)device;
}
/* This updates the effect state. This is called any time the effect is
* (re)loaded into a slot.
*/
static ALvoid ALnullState_Update(ALnullState *state, ALCdevice *device, const ALeffectslot *slot)
{
(void)state;
(void)device;
(void)slot;
}
/* This processes the effect state, for the given number of samples from the
* input to the output buffer. The result should be added to the output buffer,
* not replace it.
*/
static ALvoid ALnullState_Process(ALnullState *state, ALuint samplesToDo, const ALfloat *restrict samplesIn, ALfloat (*restrict samplesOut)[BUFFERSIZE])
{
(void)state;
@@ -43,25 +59,33 @@ static ALvoid ALnullState_Process(ALnullState *state, ALuint samplesToDo, const
(void)samplesIn;
(void)samplesOut;
}
/* This returns the ALeffectStateFactory that creates these ALeffectState
* object types.
*/
static ALeffectStateFactory *ALnullState_getCreator(void)
{
return STATIC_CAST(ALeffectStateFactory, &NullFactory);
}
/* Define the forwards and the ALeffectState vtable for this type. */
DEFINE_ALEFFECTSTATE_VTABLE(ALnullState);
/* Creates ALeffectState objects of the appropriate type. */
ALeffectState *ALnullStateFactory_create(void)
{
ALnullState *state;
state = calloc(1, sizeof(*state));
if(!state) return NULL;
/* Set vtables for inherited types. */
SET_VTABLE2(ALnullState, ALeffectState, state);
return STATIC_CAST(ALeffectState, state);
}
/* Destroys (destructs and frees) the ALeffectState. */
static ALvoid ALnullStateFactory_destroy(ALeffectState *effect)
{
ALnullState *state = STATIC_UPCAST(ALnullState, ALeffectState, effect);
@@ -69,6 +93,7 @@ static ALvoid ALnullStateFactory_destroy(ALeffectState *effect)
free(state);
}
/* Define the ALeffectStateFactory vtable for this type. */
DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALnullStateFactory);
@@ -86,21 +111,85 @@ ALeffectStateFactory *ALnullStateFactory_getFactory(void)
void ALnull_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val)
{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
{
switch(param)
{
default:
alSetError(context, AL_INVALID_ENUM);
}
(void)effect;
(void)val;
}
void ALnull_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals)
{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
{
switch(param)
{
default:
alSetError(context, AL_INVALID_ENUM);
}
(void)effect;
(void)vals;
}
void ALnull_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val)
{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
{
switch(param)
{
default:
alSetError(context, AL_INVALID_ENUM);
}
(void)effect;
(void)val;
}
void ALnull_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals)
{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
{
switch(param)
{
default:
alSetError(context, AL_INVALID_ENUM);
}
(void)effect;
(void)vals;
}
void ALnull_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val)
{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
{
switch(param)
{
default:
alSetError(context, AL_INVALID_ENUM);
}
(void)effect;
(void)val;
}
void ALnull_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals)
{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
{
switch(param)
{
default:
alSetError(context, AL_INVALID_ENUM);
}
(void)effect;
(void)vals;
}
void ALnull_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val)
{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
{
switch(param)
{
default:
alSetError(context, AL_INVALID_ENUM);
}
(void)effect;
(void)val;
}
void ALnull_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals)
{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
{
switch(param)
{
default:
alSetError(context, AL_INVALID_ENUM);
}
(void)effect;
(void)vals;
}
DEFINE_ALEFFECT_VTABLE(ALnull);
+1 -11
View File
@@ -561,8 +561,6 @@ static __inline ALvoid EAXVerbPass(ALreverbState *State, ALfloat in, ALfloat *re
State->Offset++;
}
// This processes the standard reverb state, given the input samples and an
// output buffer.
static ALvoid ALreverbState_ProcessStandard(ALreverbState *State, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE])
{
ALfloat (*restrict out)[4] = State->ReverbSamples;
@@ -583,8 +581,6 @@ static ALvoid ALreverbState_ProcessStandard(ALreverbState *State, ALuint Samples
}
}
// This processes the EAX reverb state, given the input samples and an output
// buffer.
static ALvoid ALreverbState_ProcessEax(ALreverbState *State, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE])
{
ALfloat (*restrict early)[4] = State->EarlySamples;
@@ -735,9 +731,6 @@ static ALboolean AllocLines(ALuint frequency, ALreverbState *State)
return AL_TRUE;
}
// This updates the device-dependant EAX reverb state. This is called on
// initialization and any time the device parameters (eg. playback frequency,
// format) have been changed.
static ALboolean ALreverbState_DeviceUpdate(ALreverbState *State, ALCdevice *Device)
{
ALuint frequency = Device->Frequency, index;
@@ -1087,8 +1080,6 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection
lerp(ambientGain, 1.0f, dirGain) * Gain, State->Late.PanGain);
}
// This updates the EAX reverb state. This is called any time the EAX reverb
// effect is loaded into a slot.
static ALvoid ALreverbState_Update(ALreverbState *State, ALCdevice *Device, const ALeffectslot *Slot)
{
ALuint frequency = Device->Frequency;
@@ -1176,8 +1167,7 @@ static ALvoid ALreverbState_Update(ALreverbState *State, ALCdevice *Device, cons
}
}
// This destroys the reverb state. It should be called only when the effect
// slot has a different (or no) effect loaded over the reverb effect.
static ALvoid ALreverbState_Destruct(ALreverbState *State)
{
free(State->SampleBuffer);