Add and use new/delete operators to ALeffectslot

This commit is contained in:
Chris Robinson
2018-11-18 02:52:46 -08:00
parent 3eededf5d6
commit 310770c531
3 changed files with 15 additions and 16 deletions
+4 -3
View File
@@ -2707,6 +2707,7 @@ static void FreeContext(ALCcontext *context)
if(context->DefaultSlot)
{
DeinitEffectSlot(context->DefaultSlot);
delete context->DefaultSlot;
context->DefaultSlot = nullptr;
}
@@ -3812,14 +3813,14 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
}
AllocateVoices(ALContext, 256, device->NumAuxSends);
// FIXME: Reenable after the default effect slot is handled again
if(0 && DefaultEffect.type != AL_EFFECT_NULL && device->Type == Playback)
if(DefaultEffect.type != AL_EFFECT_NULL && device->Type == Playback)
{
ALContext->DefaultSlot = nullptr;
ALContext->DefaultSlot = new ALeffectslot{};
if(InitEffectSlot(ALContext->DefaultSlot) == AL_NO_ERROR)
aluInitEffectPanning(ALContext->DefaultSlot);
else
{
delete ALContext->DefaultSlot;
ALContext->DefaultSlot = nullptr;
ERR("Failed to initialize the default effect slot\n");
}
+5 -2
View File
@@ -4,6 +4,7 @@
#include "alMain.h"
#include "alEffect.h"
#include "almalloc.h"
#include "atomic.h"
#ifdef __cplusplus
@@ -99,7 +100,7 @@ struct ALeffectslotProps {
};
typedef struct ALeffectslot {
struct ALeffectslot {
ALfloat Gain;
ALboolean AuxSendAuto;
@@ -148,7 +149,9 @@ typedef struct ALeffectslot {
* output (FOAOut).
*/
alignas(16) ALfloat WetBuffer[MAX_EFFECT_CHANNELS][BUFFERSIZE];
} ALeffectslot;
DEF_NEWDEL(ALeffectslot)
};
ALenum InitEffectSlot(ALeffectslot *slot);
void DeinitEffectSlot(ALeffectslot *slot);
+6 -11
View File
@@ -142,13 +142,11 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
iter = context->EffectSlotList.end() - 1;
}
ALenum err{AL_OUT_OF_MEMORY};
auto slot = static_cast<ALeffectslot*>(al_calloc(16, sizeof(ALeffectslot)));
if(slot) slot = new (slot) ALeffectslot{};
if(!slot || (err=InitEffectSlot(slot)) != AL_NO_ERROR)
auto slot = new ALeffectslot{};
ALenum err{InitEffectSlot(slot)};
if(err != AL_NO_ERROR)
{
slot->~ALeffectslot();
al_free(slot);
delete slot;
UnlockEffectSlotList(context);
alDeleteAuxiliaryEffectSlots(cur, effectslots);
@@ -201,9 +199,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *
context->EffectSlotList[effectslots[i]-1] = nullptr;
DeinitEffectSlot(slot);
slot->~ALeffectslot();
al_free(slot);
delete slot;
}
done:
@@ -793,9 +789,8 @@ ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *context)
entry = nullptr;
DeinitEffectSlot(slot);
delete slot;
slot->~ALeffectslot();
al_free(slot);
++leftover;
}
if(leftover > 0)