diff options
author | Chris Robinson <[email protected]> | 2010-03-23 21:05:29 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-03-23 21:05:29 -0700 |
commit | 702c62c9a241e5103e4e60fb451a1ed2fefe14f8 (patch) | |
tree | 8a63d4672398d074de6befe18d79458135921d11 /Alc | |
parent | 661059bf0f6fb03eed305207d935cb5bcbdfab27 (diff) |
Use a global handle to store the process-wide context
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 34 |
1 files changed, 8 insertions, 26 deletions
@@ -209,6 +209,8 @@ static ALCuint g_ulContextCount = 0; // Thread-local current context static tls_type LocalContext; +// Process-wide current context +static ALCcontext *GlobalContext; // Context Error static ALCenum g_eLastContextError = ALC_NO_ERROR; @@ -597,11 +599,8 @@ ALCcontext *GetContextSuspended(void) pContext = NULL; } if(!pContext) - { - pContext = g_pContextList; - while(pContext && !pContext->InUse) - pContext = pContext->next; - } + pContext = GlobalContext; + if(pContext) SuspendContext(pContext); @@ -636,7 +635,6 @@ static ALvoid InitContext(ALCcontext *pContext) //Validate pContext pContext->LastError = AL_NO_ERROR; - pContext->InUse = AL_FALSE; pContext->Suspended = AL_FALSE; //Set globals @@ -659,7 +657,6 @@ static ALCvoid ExitContext(ALCcontext *pContext) { //Invalidate context pContext->LastError = AL_NO_ERROR; - pContext->InUse = AL_FALSE; } /////////////////////////////////////////////////////// @@ -1399,6 +1396,9 @@ ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context) SuspendContext(NULL); + if(context == GlobalContext) + GlobalContext = NULL; + for(i = 0;i < Device->NumContexts-1;i++) { if(Device->Contexts[i] == context) @@ -1512,7 +1512,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *pContext) */ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) { - ALCcontext *ALContext; ALboolean bReturn = AL_TRUE; SuspendContext(NULL); @@ -1520,24 +1519,7 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) // context must be a valid Context or NULL if(context == NULL || IsContext(context)) { - ALContext = g_pContextList; - while(ALContext && !ALContext->InUse) - ALContext = ALContext->next; - - if(ALContext != NULL) - { - SuspendContext(ALContext); - ALContext->InUse=AL_FALSE; - ProcessContext(ALContext); - } - - if((ALContext=context) != NULL && ALContext->Device) - { - SuspendContext(ALContext); - ALContext->InUse=AL_TRUE; - ProcessContext(ALContext); - } - + GlobalContext = context; tls_set(LocalContext, NULL); } else |