Store effect slots in the context
This commit is contained in:
parent
707e596811
commit
b95fcf5da1
@ -1013,6 +1013,8 @@ ALCAPI ALCvoid ALCAPIENTRY alcDestroyContext(ALCcontext *context)
|
||||
// Lock context
|
||||
SuspendContext(context);
|
||||
|
||||
ReleaseALAuxiliaryEffectSlots(context);
|
||||
|
||||
context->Device->Context = NULL;
|
||||
|
||||
list = &g_pContextList;
|
||||
|
@ -41,7 +41,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum p
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue);
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues);
|
||||
|
||||
ALvoid ReleaseALAuxiliaryEffectSlots(ALvoid);
|
||||
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -198,6 +198,9 @@ struct ALCcontext_struct
|
||||
struct ALsource *Source;
|
||||
ALuint SourceCount;
|
||||
|
||||
struct ALeffectslot *AuxiliaryEffectSlot;
|
||||
ALuint AuxiliaryEffectSlotCount;
|
||||
|
||||
ALenum LastError;
|
||||
ALboolean InUse;
|
||||
|
||||
|
@ -41,7 +41,6 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
ReleaseALBuffers();
|
||||
ReleaseALAuxiliaryEffectSlots();
|
||||
ReleaseALEffects();
|
||||
ReleaseALFilters();
|
||||
ReleaseALC();
|
||||
@ -62,7 +61,6 @@ static void my_deinit()
|
||||
once = AL_TRUE;
|
||||
|
||||
ReleaseALBuffers();
|
||||
ReleaseALAuxiliaryEffectSlots();
|
||||
ReleaseALEffects();
|
||||
ReleaseALFilters();
|
||||
ReleaseALC();
|
||||
|
@ -30,9 +30,6 @@
|
||||
#include "alThunk.h"
|
||||
#include "alError.h"
|
||||
|
||||
static ALeffectslot *g_AuxiliaryEffectSlotList;
|
||||
static ALuint g_AuxiliaryEffectSlotCount;
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
|
||||
{
|
||||
@ -50,12 +47,12 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
|
||||
if (n > 0)
|
||||
{
|
||||
/* NOTE: We only support one slot currently */
|
||||
if(n == 1 && g_AuxiliaryEffectSlotCount == 0)
|
||||
if(n == 1 && Context->AuxiliaryEffectSlotCount == 0)
|
||||
{
|
||||
// Check that enough memory has been allocted in the 'effectslots' array for n Effect Slots
|
||||
if (!IsBadWritePtr((void*)effectslots, n * sizeof(ALuint)))
|
||||
{
|
||||
ALeffectslot **list = &g_AuxiliaryEffectSlotList;
|
||||
ALeffectslot **list = &Context->AuxiliaryEffectSlot;
|
||||
while(*list)
|
||||
list = &(*list)->next;
|
||||
|
||||
@ -77,7 +74,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
|
||||
effectslots[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->effectslot = effectslots[i];
|
||||
|
||||
g_AuxiliaryEffectSlotCount++;
|
||||
Context->AuxiliaryEffectSlotCount++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@ -128,7 +125,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effect
|
||||
ALAuxiliaryEffectSlot = ((ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i]));
|
||||
|
||||
// Remove Source from list of Sources
|
||||
list = &g_AuxiliaryEffectSlotList;
|
||||
list = &Context->AuxiliaryEffectSlot;
|
||||
while(*list && *list != ALAuxiliaryEffectSlot)
|
||||
list = &(*list)->next;
|
||||
|
||||
@ -139,7 +136,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effect
|
||||
memset(ALAuxiliaryEffectSlot, 0, sizeof(ALeffectslot));
|
||||
free(ALAuxiliaryEffectSlot);
|
||||
|
||||
g_AuxiliaryEffectSlotCount--;
|
||||
Context->AuxiliaryEffectSlotCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,7 +160,7 @@ AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot)
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
list = &g_AuxiliaryEffectSlotList;
|
||||
list = &Context->AuxiliaryEffectSlot;
|
||||
while(*list && (*list)->effectslot != effectslot)
|
||||
list = &(*list)->next;
|
||||
|
||||
@ -457,21 +454,21 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum p
|
||||
}
|
||||
|
||||
|
||||
ALvoid ReleaseALAuxiliaryEffectSlots(ALvoid)
|
||||
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if(g_AuxiliaryEffectSlotCount > 0)
|
||||
AL_PRINT("exit() %d AuxiliaryEffectSlot(s) NOT deleted\n", g_AuxiliaryEffectSlotCount);
|
||||
if(Context->AuxiliaryEffectSlotCount > 0)
|
||||
AL_PRINT("exit() %d AuxiliaryEffectSlot(s) NOT deleted\n", Context->AuxiliaryEffectSlotCount);
|
||||
#endif
|
||||
|
||||
while(g_AuxiliaryEffectSlotList)
|
||||
while(Context->AuxiliaryEffectSlot)
|
||||
{
|
||||
ALeffectslot *temp = g_AuxiliaryEffectSlotList;
|
||||
g_AuxiliaryEffectSlotList = g_AuxiliaryEffectSlotList->next;
|
||||
ALeffectslot *temp = Context->AuxiliaryEffectSlot;
|
||||
Context->AuxiliaryEffectSlot = Context->AuxiliaryEffectSlot->next;
|
||||
|
||||
// Release effectslot structure
|
||||
memset(temp, 0, sizeof(ALeffectslot));
|
||||
free(temp);
|
||||
}
|
||||
g_AuxiliaryEffectSlotCount = 0;
|
||||
Context->AuxiliaryEffectSlotCount = 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user