summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-11-05 20:50:56 -0800
committerChris Robinson <[email protected]>2009-11-05 20:50:56 -0800
commitc1b161b44bbf60420de2e1ba886e957d9fcd495e (patch)
tree9c480fcc6d21953c7f7bde7f325c8b91589135fa
parentaa84b2e3284f06f3e16de4ec12b8d2e3a11d64a0 (diff)
Handle NULL effect objects as AL_EFFECT_NULL effects
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h1
-rw-r--r--OpenAL32/alAuxEffectSlot.c38
2 files changed, 19 insertions, 20 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 14e3b2f9..76a0f537 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -60,6 +60,7 @@ struct ALeffectState {
ALvoid (*Process)(ALeffectState *State, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS]);
};
+ALeffectState *NoneCreate(void);
ALeffectState *EAXVerbCreate(void);
ALeffectState *VerbCreate(void);
ALeffectState *EchoCreate(void);
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index a0bea3a3..700b9d28 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -59,9 +59,10 @@ ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
while(i < n)
{
*list = calloc(1, sizeof(ALeffectslot));
- if(!(*list))
+ if(!(*list) || !((*list)->EffectState=NoneCreate()))
{
// We must have run out or memory
+ free(*list); *list = NULL;
alDeleteAuxiliaryEffectSlots(i, effectslots);
alSetError(AL_OUT_OF_MEMORY);
break;
@@ -436,7 +437,7 @@ static ALvoid NoneProcess(ALeffectState *State, const ALeffectslot *Slot, ALuint
(void)SamplesIn;
(void)SamplesOut;
}
-static ALeffectState *NoneCreate(void)
+ALeffectState *NoneCreate(void)
{
ALeffectState *state;
@@ -457,27 +458,24 @@ static ALeffectState *NoneCreate(void)
static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *ALEffectSlot, ALeffect *effect)
{
- if((!effect) || (effect->type != ALEffectSlot->effect.type))
+ if(ALEffectSlot->effect.type != (effect?effect->type:AL_EFFECT_NULL))
{
ALeffectState *NewState = NULL;
- if(effect)
+ if(!effect || effect->type == AL_EFFECT_NULL)
+ NewState = NoneCreate();
+ else if(effect->type == AL_EFFECT_EAXREVERB)
+ NewState = EAXVerbCreate();
+ else if(effect->type == AL_EFFECT_REVERB)
+ NewState = VerbCreate();
+ else if(effect->type == AL_EFFECT_ECHO)
+ NewState = EchoCreate();
+ /* No new state? An error occured.. */
+ if(NewState == NULL ||
+ ALEffect_DeviceUpdate(NewState, Context->Device) == AL_FALSE)
{
- if(effect->type == AL_EFFECT_EAXREVERB)
- NewState = EAXVerbCreate();
- else if(effect->type == AL_EFFECT_REVERB)
- NewState = VerbCreate();
- else if(effect->type == AL_EFFECT_ECHO)
- NewState = EchoCreate();
- else if(effect->type == AL_EFFECT_NULL)
- NewState = NoneCreate();
- /* No new state? An error occured.. */
- if(NewState == NULL ||
- ALEffect_DeviceUpdate(NewState, Context->Device) == AL_FALSE)
- {
- if(NewState)
- ALEffect_Destroy(NewState);
- return;
- }
+ if(NewState)
+ ALEffect_Destroy(NewState);
+ return;
}
if(ALEffectSlot->EffectState)
ALEffect_Destroy(ALEffectSlot->EffectState);