aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-28 18:17:06 -0700
committerChris Robinson <[email protected]>2011-08-28 18:17:06 -0700
commit0900c281a31df751d9a1faf832595558b74e5a92 (patch)
tree791359d2d4bfefa22606cefa7b7d77b018cb8541 /Alc/ALc.c
parentf8c4b16c30743088e0ab9fd7219432a12983fafa (diff)
Check if the context is valid only if it's replacing the current thread context
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 0bdd61f5..cd2234a4 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2236,27 +2236,26 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
{
ALboolean bReturn = AL_TRUE;
-
- LockLists();
+ ALCcontext *old;
// context must be a valid Context or NULL
- if(context == NULL || IsContext(context))
+ old = pthread_getspecific(LocalContext);
+ if(old != context)
{
- ALCcontext *old = pthread_getspecific(LocalContext);
- if(old != context)
+ LockLists();
+ if(context == NULL || IsContext(context))
{
if(context) ALCcontext_IncRef(context);
pthread_setspecific(LocalContext, context);
if(old) ALCcontext_DecRef(old);
}
+ else
+ {
+ alcSetError(NULL, ALC_INVALID_CONTEXT);
+ bReturn = AL_FALSE;
+ }
+ UnlockLists();
}
- else
- {
- alcSetError(NULL, ALC_INVALID_CONTEXT);
- bReturn = AL_FALSE;
- }
-
- UnlockLists();
return bReturn;
}