diff options
author | Chris Robinson <[email protected]> | 2009-08-16 16:02:13 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-08-16 16:02:13 -0700 |
commit | c8f700930a08c2652c2fee312f1de20a14433af1 (patch) | |
tree | 54367054115ce389f0fd1a9f2fb18139be49df4d /OpenAL32 | |
parent | decbe4df454214a9f68ad5c7a19379d9ceb80413 (diff) |
More modifications and fixes for context checks
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 68 | ||||
-rw-r--r-- | OpenAL32/alBuffer.c | 17 | ||||
-rw-r--r-- | OpenAL32/alError.c | 37 | ||||
-rw-r--r-- | OpenAL32/alExtension.c | 6 | ||||
-rw-r--r-- | OpenAL32/alListener.c | 196 |
5 files changed, 115 insertions, 209 deletions
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index e01c78d8..eac415df 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -40,15 +40,11 @@ ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) ALsizei i, j; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return; - } + if(!Context) return; if (n > 0) { - ALCdevice *Device = alcGetContextsDevice(Context); + ALCdevice *Device = Context->Device; if(Context->AuxiliaryEffectSlotCount+n <= Device->AuxiliaryEffectSlotMax) { @@ -101,11 +97,7 @@ ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) ALsizei i; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return; - } + if(!Context) return; if (n >= 0) { @@ -172,11 +164,7 @@ ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot) ALeffectslot **list; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return AL_FALSE; - } + if(!Context) return AL_FALSE; list = &Context->AuxiliaryEffectSlot; while(*list && (*list)->effectslot != effectslot) @@ -192,11 +180,7 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint ALCcontext *Context; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return; - } + if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -237,11 +221,7 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALin ALCcontext *Context; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return; - } + if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -268,11 +248,7 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALflo ALCcontext *Context; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return; - } + if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -303,11 +279,7 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfl ALCcontext *Context; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return; - } + if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -333,11 +305,7 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, AL ALCcontext *Context; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return; - } + if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -369,11 +337,7 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, A ALCcontext *Context; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return; - } + if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -400,11 +364,7 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, AL ALCcontext *Context; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return; - } + if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -432,11 +392,7 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, A ALCcontext *Context; Context = GetContextSuspended(); - if(!Context) - { - alSetError(AL_INVALID_OPERATION); - return; - } + if(!Context) return; if (alIsAuxiliaryEffectSlot(effectslot)) { diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index bb188127..09f692dc 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -80,6 +80,7 @@ ALAPI ALvoid ALAPIENTRY alGenBuffers(ALsizei n,ALuint *puiBuffers) ALsizei i=0; Context = GetContextSuspended(); + if(!Context) return; // Check that we are actually generation some Buffers if (n > 0) @@ -137,6 +138,7 @@ ALAPI ALvoid ALAPIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers) ALboolean bFailed = AL_FALSE; Context = GetContextSuspended(); + if(!Context) return; // Check we are actually Deleting some Buffers if (n >= 0) @@ -219,6 +221,7 @@ ALAPI ALboolean ALAPIENTRY alIsBuffer(ALuint uiBuffer) ALbuffer *TgtALBuf; Context = GetContextSuspended(); + if(!Context) return AL_FALSE; if (uiBuffer) { @@ -263,6 +266,7 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d ALvoid *temp; Context = GetContextSuspended(); + if(!Context) return; if (alIsBuffer(buffer) && (buffer != 0)) { @@ -430,6 +434,7 @@ ALvoid ALAPIENTRY alBufferSubDataEXT(ALuint buffer,ALenum format,const ALvoid *d ALbuffer *ALBuf; Context = GetContextSuspended(); + if(!Context) return; if(alIsBuffer(buffer) && buffer != 0) { @@ -546,6 +551,7 @@ ALAPI void ALAPIENTRY alBufferf(ALuint buffer, ALenum eParam, ALfloat flValue) (void)flValue; pContext = GetContextSuspended(); + if(!pContext) return; if (alIsBuffer(buffer) && (buffer != 0)) { @@ -574,6 +580,7 @@ ALAPI void ALAPIENTRY alBuffer3f(ALuint buffer, ALenum eParam, ALfloat flValue1, (void)flValue3; pContext = GetContextSuspended(); + if(!pContext) return; if (alIsBuffer(buffer) && (buffer != 0)) { @@ -600,6 +607,7 @@ ALAPI void ALAPIENTRY alBufferfv(ALuint buffer, ALenum eParam, const ALfloat* fl (void)flValues; pContext = GetContextSuspended(); + if(!pContext) return; if (alIsBuffer(buffer) && (buffer != 0)) { @@ -626,6 +634,7 @@ ALAPI void ALAPIENTRY alBufferi(ALuint buffer, ALenum eParam, ALint lValue) (void)lValue; pContext = GetContextSuspended(); + if(!pContext) return; if (alIsBuffer(buffer) && (buffer != 0)) { @@ -654,6 +663,7 @@ ALAPI void ALAPIENTRY alBuffer3i( ALuint buffer, ALenum eParam, ALint lValue1, A (void)lValue3; pContext = GetContextSuspended(); + if(!pContext) return; if (alIsBuffer(buffer) && (buffer != 0)) { @@ -680,6 +690,7 @@ ALAPI void ALAPIENTRY alBufferiv(ALuint buffer, ALenum eParam, const ALint* plVa (void)plValues; pContext = GetContextSuspended(); + if(!pContext) return; if (alIsBuffer(buffer) && (buffer != 0)) { @@ -704,6 +715,7 @@ ALAPI ALvoid ALAPIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pflV ALCcontext *pContext; pContext = GetContextSuspended(); + if(!pContext) return; if (pflValue) { @@ -735,6 +747,7 @@ ALAPI void ALAPIENTRY alGetBuffer3f(ALuint buffer, ALenum eParam, ALfloat* pflVa ALCcontext *pContext; pContext = GetContextSuspended(); + if(!pContext) return; if ((pflValue1) && (pflValue2) && (pflValue3)) { @@ -766,6 +779,7 @@ ALAPI void ALAPIENTRY alGetBufferfv(ALuint buffer, ALenum eParam, ALfloat* pflVa ALCcontext *pContext; pContext = GetContextSuspended(); + if(!pContext) return; if (pflValues) { @@ -798,6 +812,7 @@ ALAPI ALvoid ALAPIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plValu ALbuffer *pBuffer; pContext = GetContextSuspended(); + if(!pContext) return; if (plValue) { @@ -847,6 +862,7 @@ ALAPI void ALAPIENTRY alGetBuffer3i(ALuint buffer, ALenum eParam, ALint* plValue ALCcontext *pContext; pContext = GetContextSuspended(); + if(!pContext) return; if ((plValue1) && (plValue2) && (plValue3)) { @@ -878,6 +894,7 @@ ALAPI void ALAPIENTRY alGetBufferiv(ALuint buffer, ALenum eParam, ALint* plValue ALCcontext *pContext; pContext = GetContextSuspended(); + if(!pContext) return; if (plValues) { diff --git a/OpenAL32/alError.c b/OpenAL32/alError.c index 0ffb5e6b..f6c430a2 100644 --- a/OpenAL32/alError.c +++ b/OpenAL32/alError.c @@ -26,32 +26,29 @@ ALAPI ALenum ALAPIENTRY alGetError(ALvoid) { - ALCcontext *Context; - ALenum errorCode; + ALCcontext *Context; + ALenum errorCode; - Context = GetContextSuspended(); + Context = GetContextSuspended(); + if(!Context) return AL_INVALID_OPERATION; - if (Context) - { - errorCode = Context->LastError; - Context->LastError = AL_NO_ERROR; - } - else - errorCode = AL_INVALID_OPERATION; + errorCode = Context->LastError; + Context->LastError = AL_NO_ERROR; - ProcessContext(Context); + ProcessContext(Context); - return errorCode; + return errorCode; } ALvoid alSetError(ALenum errorCode) { - ALCcontext *Context; - - Context=GetContextSuspended(); - - if (Context && Context->LastError == AL_NO_ERROR) - Context->LastError = errorCode; - - ProcessContext(Context); + ALCcontext *Context; + + Context = GetContextSuspended(); + if(Context) + { + if(Context->LastError == AL_NO_ERROR) + Context->LastError = errorCode; + ProcessContext(Context); + } } diff --git a/OpenAL32/alExtension.c b/OpenAL32/alExtension.c index 04d705b6..427b39fe 100644 --- a/OpenAL32/alExtension.c +++ b/OpenAL32/alExtension.c @@ -353,11 +353,7 @@ ALAPI ALboolean ALAPIENTRY alIsExtensionPresent(const ALchar *extName) } pContext = GetContextSuspended(); - if(!pContext) - { - alSetError(AL_INVALID_OPERATION); - return AL_FALSE; - } + if(!pContext) return AL_FALSE; len = strlen(extName); ptr = pContext->ExtensionList; diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c index df7a51b4..cef7ae4b 100644 --- a/OpenAL32/alListener.c +++ b/OpenAL32/alListener.c @@ -30,19 +30,19 @@ ALAPI ALvoid ALAPIENTRY alListenerf(ALenum eParam, ALfloat flValue) ALCcontext *pContext; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + switch(eParam) { - switch (eParam) - { case AL_GAIN: - if (flValue >= 0.0f) + if(flValue >= 0.0f) pContext->Listener.Gain = flValue; else alSetError(AL_INVALID_VALUE); break; case AL_METERS_PER_UNIT: - if (flValue > 0.0f) + if(flValue > 0.0f) pContext->Listener.MetersPerUnit = flValue; else alSetError(AL_INVALID_VALUE); @@ -51,14 +51,9 @@ ALAPI ALvoid ALAPIENTRY alListenerf(ALenum eParam, ALfloat flValue) default: alSetError(AL_INVALID_ENUM); break; - } - - ProcessContext(pContext); } - else - alSetError(AL_INVALID_OPERATION); - return; + ProcessContext(pContext); } @@ -67,10 +62,10 @@ ALAPI ALvoid ALAPIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat fl ALCcontext *pContext; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + switch(eParam) { - switch(eParam) - { case AL_POSITION: pContext->Listener.Position[0] = flValue1; pContext->Listener.Position[1] = flValue2; @@ -86,14 +81,9 @@ ALAPI ALvoid ALAPIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat fl default: alSetError(AL_INVALID_ENUM); break; - } - - ProcessContext(pContext); } - else - alSetError(AL_INVALID_OPERATION); - return; + ProcessContext(pContext); } @@ -102,21 +92,21 @@ ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues) ALCcontext *pContext; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + if(pflValues) { - if (pflValues) + switch(eParam) { - switch (eParam) - { case AL_GAIN: - if (pflValues[0] >= 0.0f) + if(pflValues[0] >= 0.0f) pContext->Listener.Gain = pflValues[0]; else alSetError(AL_INVALID_VALUE); break; case AL_METERS_PER_UNIT: - if (pflValues[0] > 0.0f) + if(pflValues[0] > 0.0f) pContext->Listener.MetersPerUnit = pflValues[0]; else alSetError(AL_INVALID_VALUE); @@ -147,17 +137,12 @@ ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues) default: alSetError(AL_INVALID_ENUM); break; - } } - else - alSetError(AL_INVALID_VALUE); - - ProcessContext(pContext); } else - alSetError(AL_INVALID_OPERATION); + alSetError(AL_INVALID_VALUE); - return; + ProcessContext(pContext); } @@ -168,21 +153,16 @@ ALAPI ALvoid ALAPIENTRY alListeneri(ALenum eParam, ALint lValue) (void)lValue; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + switch(eParam) { - switch (eParam) - { default: alSetError(AL_INVALID_ENUM); break; - } - - ProcessContext(pContext); } - else - alSetError(AL_INVALID_OPERATION); - return; + ProcessContext(pContext); } @@ -191,10 +171,10 @@ ALAPI void ALAPIENTRY alListener3i(ALenum eParam, ALint lValue1, ALint lValue2, ALCcontext *pContext; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + switch(eParam) { - switch(eParam) - { case AL_POSITION: case AL_VELOCITY: alListener3f(eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3); @@ -203,14 +183,9 @@ ALAPI void ALAPIENTRY alListener3i(ALenum eParam, ALint lValue1, ALint lValue2, default: alSetError(AL_INVALID_ENUM); break; - } - - ProcessContext(pContext); } - else - alSetError(AL_INVALID_OPERATION); - return; + ProcessContext(pContext); } @@ -220,12 +195,12 @@ ALAPI void ALAPIENTRY alListeneriv( ALenum eParam, const ALint* plValues ) ALfloat flValues[6]; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + if(plValues) { - if (plValues) + switch(eParam) { - switch (eParam) - { case AL_POSITION: case AL_VELOCITY: flValues[0] = (ALfloat)plValues[0]; @@ -247,17 +222,12 @@ ALAPI void ALAPIENTRY alListeneriv( ALenum eParam, const ALint* plValues ) default: alSetError(AL_INVALID_ENUM); break; - } } - else - alSetError(AL_INVALID_VALUE); - - ProcessContext(pContext); } else - alSetError(AL_INVALID_OPERATION); + alSetError(AL_INVALID_VALUE); - return; + ProcessContext(pContext); } @@ -266,12 +236,12 @@ ALAPI ALvoid ALAPIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue) ALCcontext *pContext; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + if(pflValue) { - if (pflValue) + switch(eParam) { - switch (eParam) - { case AL_GAIN: *pflValue = pContext->Listener.Gain; break; @@ -283,17 +253,12 @@ ALAPI ALvoid ALAPIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue) default: alSetError(AL_INVALID_ENUM); break; - } } - else - alSetError(AL_INVALID_VALUE); - - ProcessContext(pContext); } else - alSetError(AL_INVALID_OPERATION); + alSetError(AL_INVALID_VALUE); - return; + ProcessContext(pContext); } @@ -302,12 +267,12 @@ ALAPI ALvoid ALAPIENTRY alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALflo ALCcontext *pContext; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + if(pflValue1 && pflValue2 && pflValue3) { - if ((pflValue1) && (pflValue2) && (pflValue3)) + switch(eParam) { - switch (eParam) - { case AL_POSITION: *pflValue1 = pContext->Listener.Position[0]; *pflValue2 = pContext->Listener.Position[1]; @@ -323,17 +288,12 @@ ALAPI ALvoid ALAPIENTRY alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALflo default: alSetError(AL_INVALID_ENUM); break; - } } - else - alSetError(AL_INVALID_VALUE); - - ProcessContext(pContext); } else - alSetError(AL_INVALID_OPERATION); + alSetError(AL_INVALID_VALUE); - return; + ProcessContext(pContext); } @@ -342,12 +302,12 @@ ALAPI ALvoid ALAPIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues) ALCcontext *pContext; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + if(pflValues) { - if (pflValues) + switch(eParam) { - switch (eParam) - { case AL_GAIN: pflValues[0] = pContext->Listener.Gain; break; @@ -381,17 +341,12 @@ ALAPI ALvoid ALAPIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues) default: alSetError(AL_INVALID_ENUM); break; - } } - else - alSetError(AL_INVALID_VALUE); - - ProcessContext(pContext); } else - alSetError(AL_INVALID_OPERATION); + alSetError(AL_INVALID_VALUE); - return; + ProcessContext(pContext); } @@ -400,26 +355,21 @@ ALAPI ALvoid ALAPIENTRY alGetListeneri(ALenum eParam, ALint *plValue) ALCcontext *pContext; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + if(plValue) { - if (plValue) + switch(eParam) { - switch (eParam) - { default: alSetError(AL_INVALID_ENUM); break; - } } - else - alSetError(AL_INVALID_VALUE); - - ProcessContext(pContext); } else - alSetError(AL_INVALID_OPERATION); + alSetError(AL_INVALID_VALUE); - return; + ProcessContext(pContext); } @@ -428,12 +378,12 @@ ALAPI void ALAPIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plV ALCcontext *pContext; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + if(plValue1 && plValue2 && plValue3) { - if ((plValue1) && (plValue2) && (plValue3)) + switch (eParam) { - switch (eParam) - { case AL_POSITION: *plValue1 = (ALint)pContext->Listener.Position[0]; *plValue2 = (ALint)pContext->Listener.Position[1]; @@ -449,17 +399,12 @@ ALAPI void ALAPIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plV default: alSetError(AL_INVALID_ENUM); break; - } } - else - alSetError(AL_INVALID_VALUE); - - ProcessContext(pContext); } else - alSetError(AL_INVALID_OPERATION); + alSetError(AL_INVALID_VALUE); - return; + ProcessContext(pContext); } @@ -468,12 +413,12 @@ ALAPI void ALAPIENTRY alGetListeneriv(ALenum eParam, ALint* plValues) ALCcontext *pContext; pContext = GetContextSuspended(); - if (pContext) + if(!pContext) return; + + if(plValues) { - if (plValues) + switch(eParam) { - switch (eParam) - { case AL_POSITION: plValues[0] = (ALint)pContext->Listener.Position[0]; plValues[1] = (ALint)pContext->Listener.Position[1]; @@ -499,15 +444,10 @@ ALAPI void ALAPIENTRY alGetListeneriv(ALenum eParam, ALint* plValues) default: alSetError(AL_INVALID_ENUM); break; - } } - else - alSetError(AL_INVALID_VALUE); - - ProcessContext(pContext); } else - alSetError(AL_INVALID_OPERATION); + alSetError(AL_INVALID_VALUE); - return; + ProcessContext(pContext); } |