aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-01-16 13:20:09 -0800
committerChris Robinson <[email protected]>2008-01-16 13:20:09 -0800
commitbb7b18d4e10b1f1e4d76847f58e0bf778584dc9e (patch)
tree52dbc231ca022d217acab62ec408fdfec36ea4f0 /OpenAL32
parent4742dedb4504f1d9925101a3aa7e5db27fc8370f (diff)
Keep track of references to effect slots, so they aren't deleted while in use
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h2
-rw-r--r--OpenAL32/alAuxEffectSlot.c10
-rw-r--r--OpenAL32/alSource.c6
3 files changed, 18 insertions, 0 deletions
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index dba2c207..66b3ba20 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -21,6 +21,8 @@ typedef struct ALeffectslot
ALfloat Gain;
ALboolean AuxSendAuto;
+ ALuint refcount;
+
// Index to itself
ALuint effectslot;
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index 7eae3476..f39659e9 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -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)
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 69da0df4..f0ac5847 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -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)
{