aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c16
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h4
-rw-r--r--OpenAL32/Include/alEffect.h4
-rw-r--r--OpenAL32/alAuxEffectSlot.c38
-rw-r--r--OpenAL32/alEffect.c10
5 files changed, 40 insertions, 32 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 6ce5efaf..d3eacd89 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -722,6 +722,7 @@ static void alc_initconfig(void)
} while(next++);
}
+ InitEffect(&ForcedEffect);
str = getenv("__ALSOFT_DEFAULT_REVERB");
if(str && str[0])
GetReverbEffect(str, &ForcedEffect);
@@ -2428,7 +2429,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
const ALCchar *fmt;
ALCdevice *device;
ALCenum err;
- ALCint i;
DO_INITCONFIG();
@@ -2507,18 +2507,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources;
device->DefaultSlot = (ALeffectslot*)(device+1);
- device->DefaultSlot->EffectState = NoneCreate();
- device->DefaultSlot->Gain = 1.0;
- device->DefaultSlot->AuxSendAuto = AL_TRUE;
- device->DefaultSlot->NeedsUpdate = AL_FALSE;
- for(i = 0;i < BUFFERSIZE;i++)
- device->DefaultSlot->WetBuffer[i] = 0.0f;
- for(i = 0;i < 1;i++)
- {
- device->DefaultSlot->ClickRemoval[i] = 0.0f;
- device->DefaultSlot->PendingClicks[i] = 0.0f;
- }
- device->DefaultSlot->ref = 0;
+ if(InitEffectSlot(device->DefaultSlot) != AL_NO_ERROR)
+ device->DefaultSlot = NULL;
// Find a playback device to open
LockLists();
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 1646031c..6323f6f5 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -35,10 +35,9 @@ typedef struct ALeffectslot
} ALeffectslot;
-ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect);
+ALenum InitEffectSlot(ALeffectslot *slot);
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
-
struct ALeffectState {
ALvoid (*Destroy)(ALeffectState *State);
ALboolean (*DeviceUpdate)(ALeffectState *State, ALCdevice *Device);
@@ -57,6 +56,7 @@ ALeffectState *DedicatedCreate(void);
#define ALeffectState_Update(a,b,c) ((a)->Update((a),(b),(c)))
#define ALeffectState_Process(a,b,c,d) ((a)->Process((a),(b),(c),(d)))
+ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect);
#ifdef __cplusplus
}
diff --git a/OpenAL32/Include/alEffect.h b/OpenAL32/Include/alEffect.h
index 97def48a..a52eee23 100644
--- a/OpenAL32/Include/alEffect.h
+++ b/OpenAL32/Include/alEffect.h
@@ -102,9 +102,11 @@ typedef struct ALeffect
static __inline ALboolean IsReverbEffect(ALenum type)
{ return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; }
-ALvoid GetReverbEffect(const char *name, ALeffect *effect);
+ALenum InitEffect(ALeffect *effect);
ALvoid ReleaseALEffects(ALCdevice *device);
+ALvoid GetReverbEffect(const char *name, ALeffect *effect);
+
#ifdef __cplusplus
}
#endif
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;
diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c
index 3446fbd7..ff7195aa 100644
--- a/OpenAL32/alEffect.c
+++ b/OpenAL32/alEffect.c
@@ -55,13 +55,13 @@ AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
for(i = 0;i < n;i++)
{
ALeffect *effect = calloc(1, sizeof(ALeffect));
- if(!effect)
+ if(!effect || InitEffect(effect) != AL_NO_ERROR)
{
+ free(effect);
alSetError(Context, AL_OUT_OF_MEMORY);
alDeleteEffects(i, effects);
break;
}
- InitEffectParams(effect, AL_EFFECT_NULL);
err = NewThunkEntry(&effect->effect);
if(err == AL_NO_ERROR)
@@ -1173,6 +1173,12 @@ static void null_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param,
{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
+ALenum InitEffect(ALeffect *effect)
+{
+ InitEffectParams(effect, AL_EFFECT_NULL);
+ return AL_NO_ERROR;
+}
+
ALvoid ReleaseALEffects(ALCdevice *device)
{
ALsizei i;