Store the max number of auxiliary slots in the device

This commit is contained in:
Chris Robinson 2009-06-07 14:53:22 -07:00
parent f3a3358e63
commit 0fac1e9115
3 changed files with 9 additions and 4 deletions

View File

@ -482,7 +482,6 @@ static ALvoid InitContext(ALCcontext *pContext)
pContext->lNumStereoSources = 1;
pContext->lNumMonoSources = pContext->Device->MaxNoOfSources - pContext->lNumStereoSources;
pContext->AuxiliaryEffectSlotMax = GetConfigValueInt(NULL, "slots", 4);
pContext->NumSends = GetConfigValueInt(NULL, "sends", MAX_SENDS);
if(pContext->NumSends > MAX_SENDS)
pContext->NumSends = MAX_SENDS;
@ -1288,6 +1287,10 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
if((ALint)device->MaxNoOfSources <= 0)
device->MaxNoOfSources = 256;
device->AuxiliaryEffectSlotMax = GetConfigValueInt(NULL, "slots", 4);
if((ALint)device->AuxiliaryEffectSlotMax <= 0)
device->AuxiliaryEffectSlotMax = 4;
// Find a playback device to open
SuspendContext(NULL);
for(i = 0;BackendList[i].Init;i++)

View File

@ -167,6 +167,8 @@ struct ALCdevice_struct
// Maximum number of sources that can be created
ALuint MaxNoOfSources;
// Maximum number of slots that can be created
ALuint AuxiliaryEffectSlotMax;
// Context created on this device
ALCcontext *Context;
@ -195,8 +197,6 @@ struct ALCcontext_struct
struct ALeffectslot *AuxiliaryEffectSlot;
ALuint AuxiliaryEffectSlotCount;
// Maximum number of slots that can be created
ALuint AuxiliaryEffectSlotMax;
ALenum LastError;
ALboolean InUse;

View File

@ -49,7 +49,9 @@ ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
if (n > 0)
{
if(Context->AuxiliaryEffectSlotCount+n <= Context->AuxiliaryEffectSlotMax)
ALCdevice *Device = alcGetContextsDevice(Context);
if(Context->AuxiliaryEffectSlotCount+n <= Device->AuxiliaryEffectSlotMax)
{
// Check that enough memory has been allocted in the 'effectslots' array for n Effect Slots
if (!IsBadWritePtr((void*)effectslots, n * sizeof(ALuint)))