diff options
author | Chris Robinson <[email protected]> | 2012-01-20 16:23:15 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-01-20 16:23:15 -0800 |
commit | f520257463635f1fb93d4885673714bde146cf36 (patch) | |
tree | 993802f7d6f0de90f417df84cb1d79fadf4d83bd /OpenAL32/alAuxEffectSlot.c | |
parent | 00dc3088c8eee5a1ee519f16d1ce4ca367259050 (diff) |
Avoid duplicating some initialization code
Diffstat (limited to 'OpenAL32/alAuxEffectSlot.c')
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 6c4a31f2..fdabaeb2 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -50,7 +50,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo else { ALenum err; - ALsizei i, j; + ALsizei i; err = ResizeEffectSlotArray(Context, n); if(err != AL_NO_ERROR) @@ -62,7 +62,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo for(i = 0;i < n;i++) { ALeffectslot *slot = calloc(1, sizeof(ALeffectslot)); - if(!slot || !(slot->EffectState=NoneCreate())) + if(!slot || InitEffectSlot(slot) != AL_NO_ERROR) { free(slot); // We must have run out or memory @@ -71,18 +71,6 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo break; } - slot->Gain = 1.0; - slot->AuxSendAuto = AL_TRUE; - slot->NeedsUpdate = AL_FALSE; - for(j = 0;j < BUFFERSIZE;j++) - slot->WetBuffer[j] = 0.0f; - for(j = 0;j < 1;j++) - { - slot->ClickRemoval[j] = 0.0f; - slot->PendingClicks[j] = 0.0f; - } - slot->ref = 0; - LockContext(Context); err = ResizeEffectSlotArray(Context, 1); if(err == AL_NO_ERROR) @@ -599,6 +587,28 @@ ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect } +ALenum InitEffectSlot(ALeffectslot *slot) +{ + ALint i; + + if(!(slot->EffectState=NoneCreate())) + return AL_OUT_OF_MEMORY; + + slot->Gain = 1.0; + slot->AuxSendAuto = AL_TRUE; + slot->NeedsUpdate = AL_FALSE; + for(i = 0;i < BUFFERSIZE;i++) + slot->WetBuffer[i] = 0.0f; + for(i = 0;i < 1;i++) + { + slot->ClickRemoval[i] = 0.0f; + slot->PendingClicks[i] = 0.0f; + } + slot->ref = 0; + + return AL_NO_ERROR; +} + ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context) { ALsizei pos; |