diff options
author | Chris Robinson <[email protected]> | 2010-03-16 20:23:46 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-03-16 20:23:46 -0700 |
commit | 2687155200140863232170c2c00202f27482c814 (patch) | |
tree | 3a957baba365d0172b041212091c5384b4f79eb0 /OpenAL32 | |
parent | 49321961e85b92cb04ce51baf741a6e34c6a6388 (diff) |
Get rid of more alIs* calls
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 56 | ||||
-rw-r--r-- | OpenAL32/alBuffer.c | 122 | ||||
-rw-r--r-- | OpenAL32/alDatabuffer.c | 110 |
3 files changed, 151 insertions, 137 deletions
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index d5541ed7..bc381bf6 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -34,6 +34,8 @@ static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *ALEffectSlot, ALeffect *effect); +DECL_VERIFIER(EffectSlot, ALeffectslot, effectslot) +DECL_VERIFIER(Effect, ALeffect, effect) ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { @@ -106,14 +108,13 @@ ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) // Check that all effectslots are valid for (i = 0; i < n; i++) { - if (!alIsAuxiliaryEffectSlot(effectslots[i])) + if((ALAuxiliaryEffectSlot=VerifyEffectSlot(Context->EffectSlotList, effectslots[i])) == NULL) { alSetError(Context, AL_INVALID_NAME); break; } else { - ALAuxiliaryEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i]); if(ALAuxiliaryEffectSlot->refcount > 0) { alSetError(Context, AL_INVALID_NAME); @@ -128,12 +129,10 @@ ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) for (i = 0; i < n; i++) { // Recheck that the effectslot is valid, because there could be duplicated names - if (alIsAuxiliaryEffectSlot(effectslots[i])) + if((ALAuxiliaryEffectSlot=VerifyEffectSlot(Context->EffectSlotList, effectslots[i])) != NULL) { ALeffectslot **list; - ALAuxiliaryEffectSlot = ((ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i])); - // Remove Source from list of Sources list = &Context->EffectSlotList; while(*list && *list != ALAuxiliaryEffectSlot) @@ -163,44 +162,44 @@ ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot) { ALCcontext *Context; - ALeffectslot **list; + ALboolean result; Context = GetContextSuspended(); if(!Context) return AL_FALSE; - list = &Context->EffectSlotList; - while(*list && (*list)->effectslot != effectslot) - list = &(*list)->next; + result = (VerifyEffectSlot(Context->EffectSlotList, effectslot) ? + AL_TRUE : AL_FALSE); ProcessContext(Context); - return (*list ? AL_TRUE : AL_FALSE); + return result; } ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue) { ALCcontext *Context; ALboolean updateSources = AL_FALSE; + ALeffectslot *ALEffectSlot; Context = GetContextSuspended(); if(!Context) return; - if (alIsAuxiliaryEffectSlot(effectslot)) + if((ALEffectSlot=VerifyEffectSlot(Context->EffectSlotList, effectslot)) != NULL) { - ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot); - switch(param) { - case AL_EFFECTSLOT_EFFECT: - if(alIsEffect(iValue)) + case AL_EFFECTSLOT_EFFECT: { + ALeffect *effect = NULL; + + if(iValue == 0 || + (effect=VerifyEffect(Context->Device->EffectList, iValue)) != NULL) { - ALeffect *effect = (ALeffect*)ALTHUNK_LOOKUPENTRY(iValue); InitializeEffect(Context, ALEffectSlot, effect); updateSources = AL_TRUE; } else alSetError(Context, AL_INVALID_VALUE); - break; + } break; case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: if(iValue == AL_TRUE || iValue == AL_FALSE) @@ -250,7 +249,7 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALin Context = GetContextSuspended(); if(!Context) return; - if (alIsAuxiliaryEffectSlot(effectslot)) + if(VerifyEffectSlot(Context->EffectSlotList, effectslot) != NULL) { switch(param) { @@ -273,14 +272,13 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALin ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue) { ALCcontext *Context; + ALeffectslot *ALEffectSlot; Context = GetContextSuspended(); if(!Context) return; - if (alIsAuxiliaryEffectSlot(effectslot)) + if((ALEffectSlot=VerifyEffectSlot(Context->EffectSlotList, effectslot)) != NULL) { - ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot); - switch(param) { case AL_EFFECTSLOT_GAIN: @@ -308,7 +306,7 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfl Context = GetContextSuspended(); if(!Context) return; - if (alIsAuxiliaryEffectSlot(effectslot)) + if(VerifyEffectSlot(Context->EffectSlotList, effectslot) != NULL) { switch(param) { @@ -330,14 +328,13 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfl ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue) { ALCcontext *Context; + ALeffectslot *ALEffectSlot; Context = GetContextSuspended(); if(!Context) return; - if (alIsAuxiliaryEffectSlot(effectslot)) + if((ALEffectSlot=VerifyEffectSlot(Context->EffectSlotList, effectslot)) != NULL) { - ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot); - switch(param) { case AL_EFFECTSLOT_EFFECT: @@ -366,7 +363,7 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, A Context = GetContextSuspended(); if(!Context) return; - if (alIsAuxiliaryEffectSlot(effectslot)) + if(VerifyEffectSlot(Context->EffectSlotList, effectslot) != NULL) { switch(param) { @@ -389,14 +386,13 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, A ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue) { ALCcontext *Context; + ALeffectslot *ALEffectSlot; Context = GetContextSuspended(); if(!Context) return; - if (alIsAuxiliaryEffectSlot(effectslot)) + if((ALEffectSlot=VerifyEffectSlot(Context->EffectSlotList, effectslot)) != NULL) { - ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot); - switch(param) { case AL_EFFECTSLOT_GAIN: @@ -421,7 +417,7 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, A Context = GetContextSuspended(); if(!Context) return; - if (alIsAuxiliaryEffectSlot(effectslot)) + if(VerifyEffectSlot(Context->EffectSlotList, effectslot) != NULL) { switch(param) { diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index b1c71004..b1f21b3e 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -39,6 +39,8 @@ static void ConvertDataIMA4(ALfloat *dst, const ALvoid *src, ALint origChans, AL static void ConvertDataMULaw(ALfloat *dst, const ALvoid *src, ALsizei len); static void ConvertDataMULawRear(ALfloat *dst, const ALvoid *src, ALsizei len); +DECL_VERIFIER(Buffer, ALbuffer, buffer) + /* * Global Variables */ @@ -175,19 +177,18 @@ ALAPI ALvoid ALAPIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers) // Check that all the buffers are valid and can actually be deleted for (i = 0; i < n; i++) { + if(!puiBuffers[i]) + continue; + // Check for valid Buffer ID (can be NULL buffer) - if (alIsBuffer(puiBuffers[i])) + if((ALBuf=VerifyBuffer(device->BufferList, puiBuffers[i])) != NULL) { - // If not the NULL buffer, check that the reference count is 0 - ALBuf = ((ALbuffer *)ALTHUNK_LOOKUPENTRY(puiBuffers[i])); - if (ALBuf) + if(ALBuf->refcount != 0) { - if (ALBuf->refcount != 0) - { - // Buffer still in use, cannot be deleted - alSetError(Context, AL_INVALID_OPERATION); - bFailed = AL_TRUE; - } + // Buffer still in use, cannot be deleted + alSetError(Context, AL_INVALID_OPERATION); + bFailed = AL_TRUE; + break; } } else @@ -195,6 +196,7 @@ ALAPI ALvoid ALAPIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers) // Invalid Buffer alSetError(Context, AL_INVALID_NAME); bFailed = AL_TRUE; + break; } } @@ -203,11 +205,10 @@ ALAPI ALvoid ALAPIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers) { for (i = 0; i < n; i++) { - if (puiBuffers[i] && alIsBuffer(puiBuffers[i])) + if((ALBuf=VerifyBuffer(device->BufferList, puiBuffers[i])) != NULL) { ALbuffer **list = &device->BufferList; - ALBuf=((ALbuffer *)ALTHUNK_LOOKUPENTRY(puiBuffers[i])); while(*list && *list != ALBuf) list = &(*list)->next; @@ -240,37 +241,14 @@ ALAPI ALvoid ALAPIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers) ALAPI ALboolean ALAPIENTRY alIsBuffer(ALuint uiBuffer) { ALCcontext *Context; - ALboolean result=AL_FALSE; - ALbuffer *ALBuf; - ALbuffer *TgtALBuf; + ALboolean result = AL_TRUE; Context = GetContextSuspended(); if(!Context) return AL_FALSE; - if (uiBuffer) - { - ALCdevice *device = Context->Device; - - TgtALBuf = (ALbuffer *)ALTHUNK_LOOKUPENTRY(uiBuffer); - - // Check through list of generated buffers for uiBuffer - ALBuf = device->BufferList; - while (ALBuf) - { - if (ALBuf == TgtALBuf) - { - result = AL_TRUE; - break; - } - - ALBuf = ALBuf->next; - } - } - else - { - result = AL_TRUE; - } - + if(uiBuffer) + result = (VerifyBuffer(Context->Device->BufferList, uiBuffer) ? + AL_TRUE : AL_FALSE); ProcessContext(Context); @@ -285,6 +263,7 @@ ALAPI ALboolean ALAPIENTRY alIsBuffer(ALuint uiBuffer) ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *data,ALsizei size,ALsizei freq) { ALCcontext *Context; + ALCdevice *device; ALbuffer *ALBuf; ALvoid *temp; ALenum err; @@ -292,10 +271,9 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d Context = GetContextSuspended(); if(!Context) return; - if (alIsBuffer(buffer) && (buffer != 0)) + device = Context->Device; + if((ALBuf=VerifyBuffer(device->BufferList, buffer)) != NULL) { - ALBuf=((ALbuffer *)ALTHUNK_LOOKUPENTRY(buffer)); - if(Context->SampleSource) { ALuint offset; @@ -538,15 +516,15 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d ALvoid ALAPIENTRY alBufferSubDataEXT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length) { ALCcontext *Context; - ALbuffer *ALBuf; + ALCdevice *device; + ALbuffer *ALBuf; Context = GetContextSuspended(); if(!Context) return; - if(alIsBuffer(buffer) && buffer != 0) + device = Context->Device; + if((ALBuf=VerifyBuffer(device->BufferList, buffer)) != NULL) { - ALBuf = (ALbuffer*)ALTHUNK_LOOKUPENTRY(buffer); - if(Context->SampleSource) { ALuint offset; @@ -685,13 +663,15 @@ ALvoid ALAPIENTRY alBufferSubDataEXT(ALuint buffer,ALenum format,const ALvoid *d ALAPI void ALAPIENTRY alBufferf(ALuint buffer, ALenum eParam, ALfloat flValue) { ALCcontext *pContext; + ALCdevice *device; (void)flValue; pContext = GetContextSuspended(); if(!pContext) return; - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch(eParam) { @@ -712,6 +692,7 @@ ALAPI void ALAPIENTRY alBufferf(ALuint buffer, ALenum eParam, ALfloat flValue) ALAPI void ALAPIENTRY alBuffer3f(ALuint buffer, ALenum eParam, ALfloat flValue1, ALfloat flValue2, ALfloat flValue3) { ALCcontext *pContext; + ALCdevice *device; (void)flValue1; (void)flValue2; @@ -720,7 +701,8 @@ ALAPI void ALAPIENTRY alBuffer3f(ALuint buffer, ALenum eParam, ALfloat flValue1, pContext = GetContextSuspended(); if(!pContext) return; - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch(eParam) { @@ -741,13 +723,15 @@ ALAPI void ALAPIENTRY alBuffer3f(ALuint buffer, ALenum eParam, ALfloat flValue1, ALAPI void ALAPIENTRY alBufferfv(ALuint buffer, ALenum eParam, const ALfloat* flValues) { ALCcontext *pContext; + ALCdevice *device; (void)flValues; pContext = GetContextSuspended(); if(!pContext) return; - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch(eParam) { @@ -768,13 +752,15 @@ ALAPI void ALAPIENTRY alBufferfv(ALuint buffer, ALenum eParam, const ALfloat* fl ALAPI void ALAPIENTRY alBufferi(ALuint buffer, ALenum eParam, ALint lValue) { ALCcontext *pContext; + ALCdevice *device; (void)lValue; pContext = GetContextSuspended(); if(!pContext) return; - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch(eParam) { @@ -795,6 +781,7 @@ ALAPI void ALAPIENTRY alBufferi(ALuint buffer, ALenum eParam, ALint lValue) ALAPI void ALAPIENTRY alBuffer3i( ALuint buffer, ALenum eParam, ALint lValue1, ALint lValue2, ALint lValue3) { ALCcontext *pContext; + ALCdevice *device; (void)lValue1; (void)lValue2; @@ -803,7 +790,8 @@ ALAPI void ALAPIENTRY alBuffer3i( ALuint buffer, ALenum eParam, ALint lValue1, A pContext = GetContextSuspended(); if(!pContext) return; - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch(eParam) { @@ -824,13 +812,15 @@ ALAPI void ALAPIENTRY alBuffer3i( ALuint buffer, ALenum eParam, ALint lValue1, A ALAPI void ALAPIENTRY alBufferiv(ALuint buffer, ALenum eParam, const ALint* plValues) { ALCcontext *pContext; + ALCdevice *device; (void)plValues; pContext = GetContextSuspended(); if(!pContext) return; - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch(eParam) { @@ -851,13 +841,15 @@ ALAPI void ALAPIENTRY alBufferiv(ALuint buffer, ALenum eParam, const ALint* plVa ALAPI ALvoid ALAPIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pflValue) { ALCcontext *pContext; + ALCdevice *device; pContext = GetContextSuspended(); if(!pContext) return; if (pflValue) { - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch(eParam) { @@ -883,13 +875,15 @@ ALAPI ALvoid ALAPIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pflV ALAPI void ALAPIENTRY alGetBuffer3f(ALuint buffer, ALenum eParam, ALfloat* pflValue1, ALfloat* pflValue2, ALfloat* pflValue3) { ALCcontext *pContext; + ALCdevice *device; pContext = GetContextSuspended(); if(!pContext) return; if ((pflValue1) && (pflValue2) && (pflValue3)) { - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch(eParam) { @@ -915,13 +909,15 @@ ALAPI void ALAPIENTRY alGetBuffer3f(ALuint buffer, ALenum eParam, ALfloat* pflVa ALAPI void ALAPIENTRY alGetBufferfv(ALuint buffer, ALenum eParam, ALfloat* pflValues) { ALCcontext *pContext; + ALCdevice *device; pContext = GetContextSuspended(); if(!pContext) return; if (pflValues) { - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch(eParam) { @@ -947,17 +943,17 @@ ALAPI void ALAPIENTRY alGetBufferfv(ALuint buffer, ALenum eParam, ALfloat* pflVa ALAPI ALvoid ALAPIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plValue) { ALCcontext *pContext; - ALbuffer *pBuffer; + ALbuffer *pBuffer; + ALCdevice *device; pContext = GetContextSuspended(); if(!pContext) return; if (plValue) { - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if((pBuffer=VerifyBuffer(device->BufferList, buffer)) != NULL) { - pBuffer = ((ALbuffer *)ALTHUNK_LOOKUPENTRY(buffer)); - switch (eParam) { case AL_FREQUENCY: @@ -998,13 +994,15 @@ ALAPI ALvoid ALAPIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plValu ALAPI void ALAPIENTRY alGetBuffer3i(ALuint buffer, ALenum eParam, ALint* plValue1, ALint* plValue2, ALint* plValue3) { ALCcontext *pContext; + ALCdevice *device; pContext = GetContextSuspended(); if(!pContext) return; if ((plValue1) && (plValue2) && (plValue3)) { - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch(eParam) { @@ -1030,13 +1028,15 @@ ALAPI void ALAPIENTRY alGetBuffer3i(ALuint buffer, ALenum eParam, ALint* plValue ALAPI void ALAPIENTRY alGetBufferiv(ALuint buffer, ALenum eParam, ALint* plValues) { ALCcontext *pContext; + ALCdevice *device; pContext = GetContextSuspended(); if(!pContext) return; if (plValues) { - if (alIsBuffer(buffer) && (buffer != 0)) + device = pContext->Device; + if(VerifyBuffer(device->BufferList, buffer) != NULL) { switch (eParam) { diff --git a/OpenAL32/alDatabuffer.c b/OpenAL32/alDatabuffer.c index c3a39c76..29c13ebb 100644 --- a/OpenAL32/alDatabuffer.c +++ b/OpenAL32/alDatabuffer.c @@ -32,6 +32,8 @@ #include "alThunk.h" +DECL_VERIFIER(Databuffer, ALdatabuffer, databuffer) + /* * alGenDatabuffersEXT(ALsizei n, ALuint *puiBuffers) * @@ -109,19 +111,18 @@ ALvoid ALAPIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers) * deleted */ for(i = 0;i < n;i++) { - /* Check for valid Buffer ID (can be NULL buffer) */ - if(alIsDatabufferEXT(puiBuffers[i])) + if(!puiBuffers[i]) + continue; + + /* Check for valid Buffer ID */ + if((ALBuf=VerifyDatabuffer(device->DatabufferList, puiBuffers[i])) != NULL) { - /* If not the NULL buffer, check that it's unmapped */ - ALBuf = ((ALdatabuffer *)ALTHUNK_LOOKUPENTRY(puiBuffers[i])); - if(ALBuf) + if(ALBuf->state != UNMAPPED) { - if(ALBuf->state != UNMAPPED) - { - /* Databuffer still in use, cannot be deleted */ - alSetError(Context, AL_INVALID_OPERATION); - bFailed = AL_TRUE; - } + /* Databuffer still in use, cannot be deleted */ + alSetError(Context, AL_INVALID_OPERATION); + bFailed = AL_TRUE; + break; } } else @@ -129,6 +130,7 @@ ALvoid ALAPIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers) /* Invalid Databuffer */ alSetError(Context, AL_INVALID_NAME); bFailed = AL_TRUE; + break; } } @@ -138,11 +140,10 @@ ALvoid ALAPIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers) { for(i = 0;i < n;i++) { - if(puiBuffers[i] && alIsDatabufferEXT(puiBuffers[i])) + if((ALBuf=VerifyDatabuffer(device->DatabufferList, puiBuffers[i])) != NULL) { ALdatabuffer **list = &device->DatabufferList; - ALBuf = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(puiBuffers[i]); while(*list && *list != ALBuf) list = &(*list)->next; @@ -180,19 +181,20 @@ ALvoid ALAPIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers) ALboolean ALAPIENTRY alIsDatabufferEXT(ALuint uiBuffer) { ALCcontext *Context; - ALdatabuffer *ALBuf; + ALboolean result = AL_TRUE; + ALCdevice *device; Context = GetContextSuspended(); if(!Context) return AL_FALSE; - /* Check through list of generated databuffers for uiBuffer */ - ALBuf = Context->Device->DatabufferList; - while(ALBuf && ALBuf->databuffer != uiBuffer) - ALBuf = ALBuf->next; + device = Context->Device; + if(uiBuffer) + result = (VerifyDatabuffer(device->DatabufferList, uiBuffer) ? + AL_TRUE : AL_FALSE); ProcessContext(Context); - return ((ALBuf || !uiBuffer) ? AL_TRUE : AL_FALSE); + return result; } /* @@ -204,14 +206,15 @@ ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizei s { ALCcontext *Context; ALdatabuffer *ALBuf; + ALCdevice *Device; ALvoid *temp; Context = GetContextSuspended(); if(!Context) return; - if(alIsDatabufferEXT(buffer) && buffer != 0) + Device = Context->Device; + if((ALBuf=VerifyDatabuffer(Device->DatabufferList, buffer)) != NULL) { - ALBuf = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(buffer); if(ALBuf->state == UNMAPPED) { if(usage == AL_STREAM_WRITE_EXT || usage == AL_STREAM_READ_EXT || @@ -249,14 +252,14 @@ ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsizei { ALCcontext *pContext; ALdatabuffer *pBuffer; + ALCdevice *Device; pContext = GetContextSuspended(); if(!pContext) return; - if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0) + Device = pContext->Device; + if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL) { - pBuffer = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(uiBuffer); - if(length >= 0 && start+length <= pBuffer->size) { if(pBuffer->state == UNMAPPED) @@ -277,14 +280,14 @@ ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsiz { ALCcontext *pContext; ALdatabuffer *pBuffer; + ALCdevice *Device; pContext = GetContextSuspended(); if(!pContext) return; - if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0) + Device = pContext->Device; + if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL) { - pBuffer = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(uiBuffer); - if(length >= 0 && start+length <= pBuffer->size) { if(pBuffer->state == UNMAPPED) @@ -305,13 +308,15 @@ ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsiz ALvoid ALAPIENTRY alDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat flValue) { ALCcontext *pContext; + ALCdevice *Device; (void)flValue; pContext = GetContextSuspended(); if(!pContext) return; - if(alIsDatabufferEXT(buffer) && buffer != 0) + Device = pContext->Device; + if(VerifyDatabuffer(Device->DatabufferList, buffer) != NULL) { switch(eParam) { @@ -329,13 +334,15 @@ ALvoid ALAPIENTRY alDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat flValue ALvoid ALAPIENTRY alDatabufferfvEXT(ALuint buffer, ALenum eParam, const ALfloat* flValues) { ALCcontext *pContext; + ALCdevice *Device; (void)flValues; pContext = GetContextSuspended(); if(!pContext) return; - if(alIsDatabufferEXT(buffer) && buffer != 0) + Device = pContext->Device; + if(VerifyDatabuffer(Device->DatabufferList, buffer) != NULL) { switch(eParam) { @@ -354,13 +361,15 @@ ALvoid ALAPIENTRY alDatabufferfvEXT(ALuint buffer, ALenum eParam, const ALfloat* ALvoid ALAPIENTRY alDatabufferiEXT(ALuint buffer, ALenum eParam, ALint lValue) { ALCcontext *pContext; + ALCdevice *Device; (void)lValue; pContext = GetContextSuspended(); if(!pContext) return; - if(alIsDatabufferEXT(buffer) && buffer != 0) + Device = pContext->Device; + if(VerifyDatabuffer(Device->DatabufferList, buffer) != NULL) { switch(eParam) { @@ -378,13 +387,15 @@ ALvoid ALAPIENTRY alDatabufferiEXT(ALuint buffer, ALenum eParam, ALint lValue) ALvoid ALAPIENTRY alDatabufferivEXT(ALuint buffer, ALenum eParam, const ALint* plValues) { ALCcontext *pContext; + ALCdevice *Device; (void)plValues; pContext = GetContextSuspended(); if(!pContext) return; - if(alIsDatabufferEXT(buffer) && buffer != 0) + Device = pContext->Device; + if(VerifyDatabuffer(Device->DatabufferList, buffer) != NULL) { switch(eParam) { @@ -403,13 +414,15 @@ ALvoid ALAPIENTRY alDatabufferivEXT(ALuint buffer, ALenum eParam, const ALint* p ALvoid ALAPIENTRY alGetDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat *pflValue) { ALCcontext *pContext; + ALCdevice *Device; pContext = GetContextSuspended(); if(!pContext) return; if(pflValue) { - if(alIsDatabufferEXT(buffer) && buffer != 0) + Device = pContext->Device; + if(VerifyDatabuffer(Device->DatabufferList, buffer) != NULL) { switch(eParam) { @@ -430,13 +443,15 @@ ALvoid ALAPIENTRY alGetDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat *pfl ALvoid ALAPIENTRY alGetDatabufferfvEXT(ALuint buffer, ALenum eParam, ALfloat* pflValues) { ALCcontext *pContext; + ALCdevice *Device; pContext = GetContextSuspended(); if(!pContext) return; if(pflValues) { - if(alIsDatabufferEXT(buffer) && buffer != 0) + Device = pContext->Device; + if(VerifyDatabuffer(Device->DatabufferList, buffer) != NULL) { switch(eParam) { @@ -458,16 +473,16 @@ ALvoid ALAPIENTRY alGetDatabufferiEXT(ALuint buffer, ALenum eParam, ALint *plVal { ALCcontext *pContext; ALdatabuffer *pBuffer; + ALCdevice *Device; pContext = GetContextSuspended(); if(!pContext) return; if(plValue) { - if(alIsDatabufferEXT(buffer) && buffer != 0) + Device = pContext->Device; + if((pBuffer=VerifyDatabuffer(Device->DatabufferList, buffer)) != NULL) { - pBuffer = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(buffer); - switch(eParam) { case AL_SIZE: @@ -491,13 +506,15 @@ ALvoid ALAPIENTRY alGetDatabufferiEXT(ALuint buffer, ALenum eParam, ALint *plVal ALvoid ALAPIENTRY alGetDatabufferivEXT(ALuint buffer, ALenum eParam, ALint* plValues) { ALCcontext *pContext; + ALCdevice *Device; pContext = GetContextSuspended(); if(!pContext) return; if(plValues) { - if(alIsDatabufferEXT(buffer) && buffer != 0) + Device = pContext->Device; + if(VerifyDatabuffer(Device->DatabufferList, buffer) != NULL) { switch (eParam) { @@ -523,14 +540,15 @@ ALvoid ALAPIENTRY alGetDatabufferivEXT(ALuint buffer, ALenum eParam, ALint* plVa ALvoid ALAPIENTRY alSelectDatabufferEXT(ALenum target, ALuint uiBuffer) { ALCcontext *pContext; - ALdatabuffer *pBuffer; + ALdatabuffer *pBuffer = NULL; + ALCdevice *Device; pContext = GetContextSuspended(); if(!pContext) return; - if(alIsDatabufferEXT(uiBuffer)) + Device = pContext->Device; + if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL) { - pBuffer = (ALdatabuffer*)(uiBuffer ? ALTHUNK_LOOKUPENTRY(uiBuffer) : NULL); if(target == AL_SAMPLE_SOURCE_EXT) pContext->SampleSource = pBuffer; else if(target == AL_SAMPLE_SINK_EXT) @@ -550,14 +568,14 @@ ALvoid* ALAPIENTRY alMapDatabufferEXT(ALuint uiBuffer, ALuint start, ALsizei len ALCcontext *pContext; ALdatabuffer *pBuffer; ALvoid *ret = NULL; + ALCdevice *Device; pContext = GetContextSuspended(); if(!pContext) return NULL; - if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0) + Device = pContext->Device; + if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL) { - pBuffer = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(uiBuffer); - if(length >= 0 && start+length <= pBuffer->size) { if(access == AL_READ_ONLY_EXT || access == AL_WRITE_ONLY_EXT || @@ -589,14 +607,14 @@ ALvoid ALAPIENTRY alUnmapDatabufferEXT(ALuint uiBuffer) { ALCcontext *pContext; ALdatabuffer *pBuffer; + ALCdevice *Device; pContext = GetContextSuspended(); if(!pContext) return; - if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0) + Device = pContext->Device; + if((pBuffer=VerifyDatabuffer(Device->DatabufferList, uiBuffer)) != NULL) { - pBuffer = (ALdatabuffer*)ALTHUNK_LOOKUPENTRY(uiBuffer); - if(pBuffer->state == MAPPED) pBuffer->state = UNMAPPED; else |