diff options
author | Chris Robinson <[email protected]> | 2011-06-15 23:22:34 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-06-15 23:22:34 -0700 |
commit | d702cb9b4920d6b1149d40e2804ef1b408746aca (patch) | |
tree | f2e068a86cc3922a34077b7e8c3338e8a2442e7b | |
parent | 20812280556a8c039b36327d5ded99b455e8dc4e (diff) |
Avoid an unnecessary lock when retrieving the current context
-rw-r--r-- | Alc/ALc.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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; } /* |