Keep track of references to effect slots, so they aren't deleted while in use
This commit is contained in:
@@ -21,6 +21,8 @@ typedef struct ALeffectslot
|
||||
ALfloat Gain;
|
||||
ALboolean AuxSendAuto;
|
||||
|
||||
ALuint refcount;
|
||||
|
||||
// Index to itself
|
||||
ALuint effectslot;
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
|
||||
|
||||
(*list)->Gain = 1.0;
|
||||
(*list)->AuxSendAuto = AL_TRUE;
|
||||
(*list)->refcount = 0;
|
||||
|
||||
effectslots[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->effectslot = effectslots[i];
|
||||
@@ -112,6 +113,15 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effect
|
||||
alSetError(AL_INVALID_NAME);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ALAuxiliaryEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i]);
|
||||
if(ALAuxiliaryEffectSlot->refcount > 0)
|
||||
{
|
||||
alSetError(AL_INVALID_NAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == n)
|
||||
|
||||
@@ -745,7 +745,13 @@ ALAPI void ALAPIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1, AL
|
||||
ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(lValue1);
|
||||
ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(lValue3);
|
||||
|
||||
/* Release refcount on the previous slot, and add one for
|
||||
* the new slot */
|
||||
if(pSource->Send[lValue2].Slot)
|
||||
pSource->Send[lValue2].Slot->refcount--;
|
||||
pSource->Send[lValue2].Slot = ALEffectSlot;
|
||||
if(pSource->Send[lValue2].Slot)
|
||||
pSource->Send[lValue2].Slot->refcount++;
|
||||
|
||||
if(!ALFilter)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user