From d702cb9b4920d6b1149d40e2804ef1b408746aca Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 15 Jun 2011 23:22:34 -0700 Subject: Avoid an unnecessary lock when retrieving the current context --- Alc/ALc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'Alc/ALc.c') diff --git a/Alc/ALc.c b/Alc/ALc.c index 309ad9d6..e7bb59ba 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -2283,12 +2283,20 @@ ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context) */ ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(ALCvoid) { - ALCcontext *pContext; + ALCcontext *Context; - if((pContext=GetContextSuspended()) != NULL) - ProcessContext(pContext); + LockLists(); + Context = tls_get(LocalContext); + if(Context && !IsContext(Context)) + { + tls_set(LocalContext, NULL); + Context = NULL; + } + if(!Context) + Context = GlobalContext; + UnlockLists(); - return pContext; + return Context; } /* -- cgit v1.2.3