diff options
author | Chris Robinson <[email protected]> | 2009-08-16 14:09:23 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-08-16 14:09:23 -0700 |
commit | 462f27c129454b71179e0ebce366f3b8d7956da6 (patch) | |
tree | 7d726be69bdac1c6ed6354c52057d747be9a9359 | |
parent | 2d1191697ae5a770b7e0b57a612271ef70b6b890 (diff) |
Use a function to retrieve the current context in an already-locked state
This should help prevent race-conditions with a context being destroyed between
breing retrieved and locked
-rw-r--r-- | Alc/ALc.c | 31 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 2 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 33 | ||||
-rw-r--r-- | OpenAL32/alBuffer.c | 51 | ||||
-rw-r--r-- | OpenAL32/alDatabuffer.c | 51 | ||||
-rw-r--r-- | OpenAL32/alEffect.c | 33 | ||||
-rw-r--r-- | OpenAL32/alError.c | 6 | ||||
-rw-r--r-- | OpenAL32/alExtension.c | 4 | ||||
-rw-r--r-- | OpenAL32/alFilter.c | 33 | ||||
-rw-r--r-- | OpenAL32/alListener.c | 48 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 84 | ||||
-rw-r--r-- | OpenAL32/alState.c | 62 |
12 files changed, 148 insertions, 290 deletions
@@ -454,6 +454,30 @@ ALCvoid ProcessContext(ALCcontext *pContext) /* + GetContextSuspended + + Returns the currently active Context, in a locked state +*/ +ALCcontext *GetContextSuspended(void) +{ + ALCcontext *pContext = NULL; + + SuspendContext(NULL); + + pContext = g_pContextList; + while(pContext && !pContext->InUse) + pContext = pContext->next; + + if(pContext) + SuspendContext(pContext); + + ProcessContext(NULL); + + return pContext; +} + + +/* InitContext Initialize Context variables @@ -1236,16 +1260,15 @@ ALCAPI ALCboolean ALCAPIENTRY alcMakeContextCurrent(ALCcontext *context) SuspendContext(NULL); // context must be a valid Context or NULL - if ((IsContext(context)) || (context == NULL)) + if(context == NULL || IsContext(context)) { - if ((ALContext=alcGetCurrentContext())) + if((ALContext=GetContextSuspended()) != NULL) { - SuspendContext(ALContext); ALContext->InUse=AL_FALSE; ProcessContext(ALContext); } - if ((ALContext=context) && (ALContext->Device)) + if((ALContext=context) != NULL && ALContext->Device) { SuspendContext(ALContext); ALContext->InUse=AL_TRUE; diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index a375f6d1..782252ba 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -276,6 +276,8 @@ ALCvoid ProcessContext(ALCcontext *context); ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr); ALuint StopThread(ALvoid *thread); +ALCcontext *GetContextSuspended(void); + typedef struct RingBuffer RingBuffer; RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length); void DestroyRingBuffer(RingBuffer *ring); diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 805bdb4b..e01c78d8 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -39,13 +39,12 @@ ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) ALCcontext *Context; ALsizei i, j; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } - SuspendContext(Context); if (n > 0) { @@ -101,13 +100,12 @@ ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) ALeffectslot *ALAuxiliaryEffectSlot; ALsizei i; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } - SuspendContext(Context); if (n >= 0) { @@ -173,13 +171,12 @@ ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot) ALCcontext *Context; ALeffectslot **list; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return AL_FALSE; } - SuspendContext(Context); list = &Context->AuxiliaryEffectSlot; while(*list && (*list)->effectslot != effectslot) @@ -194,13 +191,12 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint { ALCcontext *Context; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } - SuspendContext(Context); if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -240,13 +236,12 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALin { ALCcontext *Context; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } - SuspendContext(Context); if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -272,13 +267,12 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALflo { ALCcontext *Context; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } - SuspendContext(Context); if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -308,13 +302,12 @@ ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfl { ALCcontext *Context; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } - SuspendContext(Context); if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -339,13 +332,12 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, AL { ALCcontext *Context; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } - SuspendContext(Context); if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -376,13 +368,12 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, A { ALCcontext *Context; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } - SuspendContext(Context); if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -408,13 +399,12 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, AL { ALCcontext *Context; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } - SuspendContext(Context); if (alIsAuxiliaryEffectSlot(effectslot)) { @@ -441,13 +431,12 @@ ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, A { ALCcontext *Context; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) { alSetError(AL_INVALID_OPERATION); return; } - SuspendContext(Context); if (alIsAuxiliaryEffectSlot(effectslot)) { diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index ebd4cf20..bb188127 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -79,8 +79,7 @@ ALAPI ALvoid ALAPIENTRY alGenBuffers(ALsizei n,ALuint *puiBuffers) ALCcontext *Context; ALsizei i=0; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); // Check that we are actually generation some Buffers if (n > 0) @@ -137,8 +136,7 @@ ALAPI ALvoid ALAPIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers) ALsizei i; ALboolean bFailed = AL_FALSE; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); // Check we are actually Deleting some Buffers if (n >= 0) @@ -220,8 +218,7 @@ ALAPI ALboolean ALAPIENTRY alIsBuffer(ALuint uiBuffer) ALbuffer *ALBuf; ALbuffer *TgtALBuf; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (uiBuffer) { @@ -265,8 +262,7 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d ALbuffer *ALBuf; ALvoid *temp; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (alIsBuffer(buffer) && (buffer != 0)) { @@ -433,8 +429,7 @@ ALvoid ALAPIENTRY alBufferSubDataEXT(ALuint buffer,ALenum format,const ALvoid *d ALCcontext *Context; ALbuffer *ALBuf; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if(alIsBuffer(buffer) && buffer != 0) { @@ -550,8 +545,7 @@ ALAPI void ALAPIENTRY alBufferf(ALuint buffer, ALenum eParam, ALfloat flValue) (void)flValue; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if (alIsBuffer(buffer) && (buffer != 0)) { @@ -579,8 +573,7 @@ ALAPI void ALAPIENTRY alBuffer3f(ALuint buffer, ALenum eParam, ALfloat flValue1, (void)flValue2; (void)flValue3; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if (alIsBuffer(buffer) && (buffer != 0)) { @@ -606,8 +599,7 @@ ALAPI void ALAPIENTRY alBufferfv(ALuint buffer, ALenum eParam, const ALfloat* fl (void)flValues; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if (alIsBuffer(buffer) && (buffer != 0)) { @@ -633,8 +625,7 @@ ALAPI void ALAPIENTRY alBufferi(ALuint buffer, ALenum eParam, ALint lValue) (void)lValue; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if (alIsBuffer(buffer) && (buffer != 0)) { @@ -662,8 +653,7 @@ ALAPI void ALAPIENTRY alBuffer3i( ALuint buffer, ALenum eParam, ALint lValue1, A (void)lValue2; (void)lValue3; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if (alIsBuffer(buffer) && (buffer != 0)) { @@ -689,8 +679,7 @@ ALAPI void ALAPIENTRY alBufferiv(ALuint buffer, ALenum eParam, const ALint* plVa (void)plValues; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if (alIsBuffer(buffer) && (buffer != 0)) { @@ -714,8 +703,7 @@ ALAPI ALvoid ALAPIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pflV { ALCcontext *pContext; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if (pflValue) { @@ -746,8 +734,7 @@ ALAPI void ALAPIENTRY alGetBuffer3f(ALuint buffer, ALenum eParam, ALfloat* pflVa { ALCcontext *pContext; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if ((pflValue1) && (pflValue2) && (pflValue3)) { @@ -778,8 +765,7 @@ ALAPI void ALAPIENTRY alGetBufferfv(ALuint buffer, ALenum eParam, ALfloat* pflVa { ALCcontext *pContext; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if (pflValues) { @@ -811,8 +797,7 @@ ALAPI ALvoid ALAPIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plValu ALCcontext *pContext; ALbuffer *pBuffer; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if (plValue) { @@ -861,8 +846,7 @@ ALAPI void ALAPIENTRY alGetBuffer3i(ALuint buffer, ALenum eParam, ALint* plValue { ALCcontext *pContext; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if ((plValue1) && (plValue2) && (plValue3)) { @@ -893,8 +877,7 @@ ALAPI void ALAPIENTRY alGetBufferiv(ALuint buffer, ALenum eParam, ALint* plValue { ALCcontext *pContext; - pContext = alcGetCurrentContext(); - SuspendContext(pContext); + pContext = GetContextSuspended(); if (plValues) { diff --git a/OpenAL32/alDatabuffer.c b/OpenAL32/alDatabuffer.c index 2eed1d8e..df1baaf2 100644 --- a/OpenAL32/alDatabuffer.c +++ b/OpenAL32/alDatabuffer.c @@ -42,9 +42,8 @@ ALvoid ALAPIENTRY alGenDatabuffersEXT(ALsizei n,ALuint *puiBuffers) ALCcontext *Context; ALsizei i=0; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) return; - SuspendContext(Context); /* Check that we are actually generation some Databuffers */ if(n > 0) @@ -98,9 +97,8 @@ ALvoid ALAPIENTRY alDeleteDatabuffersEXT(ALsizei n, const ALuint *puiBuffers) ALsizei i; ALboolean bFailed = AL_FALSE; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) return; - SuspendContext(Context); /* Check we are actually Deleting some Databuffers */ if(n >= 0) @@ -187,9 +185,8 @@ ALboolean ALAPIENTRY alIsDatabufferEXT(ALuint uiBuffer) ALCcontext *Context; ALdatabuffer *ALBuf; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) return AL_FALSE; - SuspendContext(Context); /* Check through list of generated databuffers for uiBuffer */ ALBuf = Context->Device->Databuffers; @@ -212,9 +209,8 @@ ALvoid ALAPIENTRY alDatabufferDataEXT(ALuint buffer,const ALvoid *data,ALsizei s ALdatabuffer *ALBuf; ALvoid *temp; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if(!Context) return; - SuspendContext(Context); if(alIsDatabufferEXT(buffer) && buffer != 0) { @@ -257,9 +253,8 @@ ALvoid ALAPIENTRY alDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsizei ALCcontext *pContext; ALdatabuffer *pBuffer; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0) { @@ -286,9 +281,8 @@ ALvoid ALAPIENTRY alGetDatabufferSubDataEXT(ALuint uiBuffer, ALuint start, ALsiz ALCcontext *pContext; ALdatabuffer *pBuffer; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0) { @@ -317,9 +311,8 @@ ALvoid ALAPIENTRY alDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat flValue (void)flValue; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(alIsDatabufferEXT(buffer) && buffer != 0) { @@ -342,9 +335,8 @@ ALvoid ALAPIENTRY alDatabufferfvEXT(ALuint buffer, ALenum eParam, const ALfloat* (void)flValues; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(alIsDatabufferEXT(buffer) && buffer != 0) { @@ -368,9 +360,8 @@ ALvoid ALAPIENTRY alDatabufferiEXT(ALuint buffer, ALenum eParam, ALint lValue) (void)lValue; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(alIsDatabufferEXT(buffer) && buffer != 0) { @@ -393,9 +384,8 @@ ALvoid ALAPIENTRY alDatabufferivEXT(ALuint buffer, ALenum eParam, const ALint* p (void)plValues; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(alIsDatabufferEXT(buffer) && buffer != 0) { @@ -417,9 +407,8 @@ ALvoid ALAPIENTRY alGetDatabufferfEXT(ALuint buffer, ALenum eParam, ALfloat *pfl { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(pflValue) { @@ -445,9 +434,8 @@ ALvoid ALAPIENTRY alGetDatabufferfvEXT(ALuint buffer, ALenum eParam, ALfloat* pf { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(pflValues) { @@ -474,9 +462,8 @@ ALvoid ALAPIENTRY alGetDatabufferiEXT(ALuint buffer, ALenum eParam, ALint *plVal ALCcontext *pContext; ALdatabuffer *pBuffer; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(plValue) { @@ -508,9 +495,8 @@ ALvoid ALAPIENTRY alGetDatabufferivEXT(ALuint buffer, ALenum eParam, ALint* plVa { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(plValues) { @@ -542,9 +528,8 @@ ALvoid ALAPIENTRY alSelectDatabufferEXT(ALenum target, ALuint uiBuffer) ALCcontext *pContext; ALdatabuffer *pBuffer; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(alIsDatabufferEXT(uiBuffer)) { @@ -569,9 +554,8 @@ ALvoid* ALAPIENTRY alMapDatabufferEXT(ALuint uiBuffer, ALuint start, ALsizei len ALdatabuffer *pBuffer; ALvoid *ret = NULL; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return NULL; - SuspendContext(pContext); if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0) { @@ -609,9 +593,8 @@ ALvoid ALAPIENTRY alUnmapDatabufferEXT(ALuint uiBuffer) ALCcontext *pContext; ALdatabuffer *pBuffer; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) return; - SuspendContext(pContext); if(alIsDatabufferEXT(uiBuffer) && uiBuffer != 0) { diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c index 7bf5b5ab..0c2d129f 100644 --- a/OpenAL32/alEffect.c +++ b/OpenAL32/alEffect.c @@ -42,8 +42,7 @@ ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) ALCcontext *Context; ALsizei i; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (n > 0) { @@ -89,8 +88,7 @@ ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects) ALeffect *ALEffect; ALsizei i; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (n >= 0) { @@ -146,8 +144,7 @@ ALboolean AL_APIENTRY alIsEffect(ALuint effect) ALCcontext *Context; ALeffect *list; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); list = Context->Device->EffectList; while(list && list->effect != effect) @@ -162,8 +159,7 @@ ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (effect && alIsEffect(effect)) { @@ -237,8 +233,7 @@ ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValues) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (effect && alIsEffect(effect)) { @@ -296,8 +291,7 @@ ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (effect && alIsEffect(effect)) { @@ -633,8 +627,7 @@ ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflValues) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (effect && alIsEffect(effect)) { @@ -747,8 +740,7 @@ ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (effect && alIsEffect(effect)) { @@ -806,8 +798,7 @@ ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (effect && alIsEffect(effect)) { @@ -865,8 +856,7 @@ ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (effect && alIsEffect(effect)) { @@ -1060,8 +1050,7 @@ ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (effect && alIsEffect(effect)) { diff --git a/OpenAL32/alError.c b/OpenAL32/alError.c index a7ed84a2..0ffb5e6b 100644 --- a/OpenAL32/alError.c +++ b/OpenAL32/alError.c @@ -29,8 +29,7 @@ ALAPI ALenum ALAPIENTRY alGetError(ALvoid) ALCcontext *Context; ALenum errorCode; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (Context) { @@ -49,8 +48,7 @@ ALvoid alSetError(ALenum errorCode) { ALCcontext *Context; - Context=alcGetCurrentContext(); - SuspendContext(Context); + Context=GetContextSuspended(); if (Context && Context->LastError == AL_NO_ERROR) Context->LastError = errorCode; diff --git a/OpenAL32/alExtension.c b/OpenAL32/alExtension.c index 4c1c73b6..04d705b6 100644 --- a/OpenAL32/alExtension.c +++ b/OpenAL32/alExtension.c @@ -352,15 +352,13 @@ ALAPI ALboolean ALAPIENTRY alIsExtensionPresent(const ALchar *extName) return AL_FALSE; } - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) { alSetError(AL_INVALID_OPERATION); return AL_FALSE; } - SuspendContext(pContext); - len = strlen(extName); ptr = pContext->ExtensionList; while(ptr && *ptr) diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c index 9d32e7cf..d2b3ff62 100644 --- a/OpenAL32/alFilter.c +++ b/OpenAL32/alFilter.c @@ -38,8 +38,7 @@ ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) ALCcontext *Context; ALsizei i; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (n > 0) { @@ -85,8 +84,7 @@ ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters) ALfilter *ALFilter; ALsizei i; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (n >= 0) { @@ -142,8 +140,7 @@ ALboolean AL_APIENTRY alIsFilter(ALuint filter) ALCcontext *Context; ALfilter *list; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); list = Context->Device->FilterList; while(list && list->filter != filter) @@ -158,8 +155,7 @@ ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (filter && alIsFilter(filter)) { @@ -190,8 +186,7 @@ ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValues) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (filter && alIsFilter(filter)) { @@ -216,8 +211,7 @@ ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (filter && alIsFilter(filter)) { @@ -263,8 +257,7 @@ ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflValues) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (filter && alIsFilter(filter)) { @@ -285,8 +278,7 @@ ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (filter && alIsFilter(filter)) { @@ -313,8 +305,7 @@ ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (filter && alIsFilter(filter)) { @@ -339,8 +330,7 @@ ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue) { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (filter && alIsFilter(filter)) { @@ -380,8 +370,7 @@ ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues { ALCcontext *Context; - Context = alcGetCurrentContext(); - SuspendContext(Context); + Context = GetContextSuspended(); if (filter && alIsFilter(filter)) { diff --git a/OpenAL32/alListener.c b/OpenAL32/alListener.c index 3b888b0d..df7a51b4 100644 --- a/OpenAL32/alListener.c +++ b/OpenAL32/alListener.c @@ -29,11 +29,9 @@ ALAPI ALvoid ALAPIENTRY alListenerf(ALenum eParam, ALfloat flValue) { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - switch (eParam) { case AL_GAIN: @@ -68,11 +66,9 @@ ALAPI ALvoid ALAPIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat fl { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - switch(eParam) { case AL_POSITION: @@ -105,11 +101,9 @@ ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues) { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (pflValues) { switch (eParam) @@ -173,11 +167,9 @@ ALAPI ALvoid ALAPIENTRY alListeneri(ALenum eParam, ALint lValue) (void)lValue; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - switch (eParam) { default: @@ -198,11 +190,9 @@ ALAPI void ALAPIENTRY alListener3i(ALenum eParam, ALint lValue1, ALint lValue2, { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - switch(eParam) { case AL_POSITION: @@ -229,11 +219,9 @@ ALAPI void ALAPIENTRY alListeneriv( ALenum eParam, const ALint* plValues ) ALCcontext *pContext; ALfloat flValues[6]; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (plValues) { switch (eParam) @@ -277,11 +265,9 @@ ALAPI ALvoid ALAPIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue) { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (pflValue) { switch (eParam) @@ -315,11 +301,9 @@ ALAPI ALvoid ALAPIENTRY alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALflo { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if ((pflValue1) && (pflValue2) && (pflValue3)) { switch (eParam) @@ -357,11 +341,9 @@ ALAPI ALvoid ALAPIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues) { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (pflValues) { switch (eParam) @@ -417,11 +399,9 @@ ALAPI ALvoid ALAPIENTRY alGetListeneri(ALenum eParam, ALint *plValue) { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (plValue) { switch (eParam) @@ -447,11 +427,9 @@ ALAPI void ALAPIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plV { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if ((plValue1) && (plValue2) && (plValue3)) { switch (eParam) @@ -489,11 +467,9 @@ ALAPI void ALAPIENTRY alGetListeneriv(ALenum eParam, ALint* plValues) { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (plValues) { switch (eParam) diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 262d2786..3dc6fd87 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -43,11 +43,9 @@ ALAPI ALvoid ALAPIENTRY alGenSources(ALsizei n,ALuint *sources) ALCdevice *Device; ALsizei i=0; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (n > 0) { Device = alcGetContextsDevice(Context); @@ -126,11 +124,9 @@ ALAPI ALvoid ALAPIENTRY alDeleteSources(ALsizei n, const ALuint *sources) ALbufferlistitem *ALBufferList; ALboolean bSourcesValid = AL_TRUE; - Context = alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (n >= 0) { Device = alcGetContextsDevice(Context); @@ -224,11 +220,9 @@ ALAPI ALboolean ALAPIENTRY alIsSource(ALuint source) ALCcontext *Context; ALsource *Source; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - // To determine if this is a valid Source name, look through the list of generated Sources Source = Context->Source; while(Source) @@ -259,11 +253,9 @@ ALAPI ALvoid ALAPIENTRY alSourcef(ALuint source, ALenum eParam, ALfloat flValue) ALCcontext *pContext; ALsource *pSource; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (alIsSource(source)) { pSource = ((ALsource *)ALTHUNK_LOOKUPENTRY(source)); @@ -420,11 +412,9 @@ ALAPI ALvoid ALAPIENTRY alSource3f(ALuint source, ALenum eParam, ALfloat flValue ALCcontext *pContext; ALsource *pSource; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (alIsSource(source)) { pSource = ((ALsource *)ALTHUNK_LOOKUPENTRY(source)); @@ -471,11 +461,9 @@ ALAPI ALvoid ALAPIENTRY alSourcefv(ALuint source, ALenum eParam, const ALfloat * { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (pflValues) { if (alIsSource(source)) @@ -534,11 +522,9 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue) ALbufferlistitem *pALBufferListItem; ALuint i; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (alIsSource(source)) { pSource = ((ALsource *)ALTHUNK_LOOKUPENTRY(source)); @@ -742,11 +728,9 @@ ALAPI void ALAPIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1, AL { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (alIsSource(source)) { ALsource *pSource = ((ALsource *)ALTHUNK_LOOKUPENTRY(source)); @@ -809,11 +793,9 @@ ALAPI void ALAPIENTRY alSourceiv(ALuint source, ALenum eParam, const ALint* plVa { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (plValues) { if (alIsSource(source)) @@ -873,11 +855,9 @@ ALAPI ALvoid ALAPIENTRY alGetSourcef(ALuint source, ALenum eParam, ALfloat *pflV ALsource *pSource; ALfloat flOffset[2]; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (pflValue) { if (alIsSource(source)) @@ -988,11 +968,9 @@ ALAPI ALvoid ALAPIENTRY alGetSource3f(ALuint source, ALenum eParam, ALfloat* pfl ALCcontext *pContext; ALsource *pSource; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if ((pflValue1) && (pflValue2) && (pflValue3)) { if (alIsSource(source)) @@ -1044,11 +1022,9 @@ ALAPI ALvoid ALAPIENTRY alGetSourcefv(ALuint source, ALenum eParam, ALfloat *pfl ALCcontext *pContext; ALsource *pSource; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (pflValues) { if (alIsSource(source)) @@ -1121,11 +1097,9 @@ ALAPI ALvoid ALAPIENTRY alGetSourcei(ALuint source, ALenum eParam, ALint *plValu ALsource *pSource; ALfloat flOffset[2]; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (plValue) { if (alIsSource(source)) @@ -1259,11 +1233,9 @@ ALAPI void ALAPIENTRY alGetSource3i(ALuint source, ALenum eParam, ALint* plValue ALCcontext *pContext; ALsource *pSource; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if ((plValue1) && (plValue2) && (plValue3)) { if (alIsSource(source)) @@ -1315,11 +1287,9 @@ ALAPI void ALAPIENTRY alGetSourceiv(ALuint source, ALenum eParam, ALint* plValue ALCcontext *pContext; ALsource *pSource; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (plValues) { if (alIsSource(source)) @@ -1405,11 +1375,9 @@ ALAPI ALvoid ALAPIENTRY alSourcePlayv(ALsizei n, const ALuint *pSourceList) ALboolean bPlay; ALsizei i, j; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (pSourceList) { // Check that all the Sources are valid @@ -1528,11 +1496,9 @@ ALAPI ALvoid ALAPIENTRY alSourcePausev(ALsizei n, const ALuint *sources) ALsizei i; ALboolean bSourcesValid = AL_TRUE; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (sources) { // Check all the Sources are valid @@ -1590,11 +1556,9 @@ ALAPI ALvoid ALAPIENTRY alSourceStopv(ALsizei n, const ALuint *sources) ALbufferlistitem *ALBufferListItem; ALboolean bSourcesValid = AL_TRUE; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (sources) { // Check all the Sources are valid @@ -1660,11 +1624,9 @@ ALAPI ALvoid ALAPIENTRY alSourceRewindv(ALsizei n, const ALuint *sources) ALbufferlistitem *ALBufferListItem; ALboolean bSourcesValid = AL_TRUE; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (sources) { // Check all the Sources are valid @@ -1735,11 +1697,9 @@ ALAPI ALvoid ALAPIENTRY alSourceQueueBuffers( ALuint source, ALsizei n, const AL if (n == 0) return; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - // Check that all buffers are valid or zero and that the source is valid // Check that this is a valid source @@ -1892,11 +1852,9 @@ ALAPI ALvoid ALAPIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALuint bBuffersProcessed = AL_TRUE; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (alIsSource(source)) { ALSource = (ALsource*)ALTHUNK_LOOKUPENTRY(source); diff --git a/OpenAL32/alState.c b/OpenAL32/alState.c index ec2cdfe9..f831a93f 100644 --- a/OpenAL32/alState.c +++ b/OpenAL32/alState.c @@ -45,11 +45,9 @@ ALAPI ALvoid ALAPIENTRY alEnable(ALenum capability) { ALCcontext *Context; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - switch (capability) { default: @@ -70,11 +68,9 @@ ALAPI ALvoid ALAPIENTRY alDisable(ALenum capability) { ALCcontext *Context; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - switch (capability) { default: @@ -96,11 +92,9 @@ ALAPI ALboolean ALAPIENTRY alIsEnabled(ALenum capability) ALCcontext *Context; ALboolean value=AL_FALSE; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - switch (capability) { default: @@ -124,11 +118,9 @@ ALAPI ALboolean ALAPIENTRY alGetBoolean(ALenum pname) ALCcontext *Context; ALboolean value=AL_FALSE; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - switch (pname) { case AL_DOPPLER_FACTOR: @@ -172,11 +164,9 @@ ALAPI ALdouble ALAPIENTRY alGetDouble(ALenum pname) ALCcontext *Context; ALdouble value = 0.0; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - switch (pname) { case AL_DOPPLER_FACTOR: @@ -216,11 +206,9 @@ ALAPI ALfloat ALAPIENTRY alGetFloat(ALenum pname) ALCcontext *Context; ALfloat value = 0.0f; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - switch (pname) { case AL_DOPPLER_FACTOR: @@ -260,11 +248,9 @@ ALAPI ALint ALAPIENTRY alGetInteger(ALenum pname) ALCcontext *Context; ALint value = 0; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - switch (pname) { case AL_DOPPLER_FACTOR: @@ -317,11 +303,9 @@ ALAPI ALvoid ALAPIENTRY alGetBooleanv(ALenum pname,ALboolean *data) { ALCcontext *Context; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (data) { switch (pname) @@ -368,11 +352,9 @@ ALAPI ALvoid ALAPIENTRY alGetDoublev(ALenum pname,ALdouble *data) { ALCcontext *Context; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (data) { switch (pname) @@ -419,11 +401,9 @@ ALAPI ALvoid ALAPIENTRY alGetFloatv(ALenum pname,ALfloat *data) { ALCcontext *Context; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (data) { switch (pname) @@ -470,11 +450,9 @@ ALAPI ALvoid ALAPIENTRY alGetIntegerv(ALenum pname,ALint *data) { ALCcontext *Context; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (data) { switch (pname) @@ -536,7 +514,7 @@ ALAPI const ALchar* ALAPIENTRY alGetString(ALenum pname) const ALchar *value; ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if(!pContext) { alSetError(AL_INVALID_OPERATION); @@ -602,11 +580,9 @@ ALAPI ALvoid ALAPIENTRY alDopplerFactor(ALfloat value) { ALCcontext *Context; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (value>=0.0f) Context->DopplerFactor = value; else @@ -627,11 +603,9 @@ ALAPI ALvoid ALAPIENTRY alDopplerVelocity(ALfloat value) { ALCcontext *Context; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - if (value>0.0f) Context->DopplerVelocity=value; else @@ -652,11 +626,9 @@ ALAPI ALvoid ALAPIENTRY alSpeedOfSound(ALfloat flSpeedOfSound) { ALCcontext *pContext; - pContext = alcGetCurrentContext(); + pContext = GetContextSuspended(); if (pContext) { - SuspendContext(pContext); - if (flSpeedOfSound > 0.0f) pContext->flSpeedOfSound = flSpeedOfSound; else @@ -677,11 +649,9 @@ ALAPI ALvoid ALAPIENTRY alDistanceModel(ALenum value) ALCcontext *Context; ALsource *Source; - Context=alcGetCurrentContext(); + Context = GetContextSuspended(); if (Context) { - SuspendContext(Context); - switch (value) { case AL_NONE: |