aboutsummaryrefslogtreecommitdiffstats
path: root/router/alc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-06-29 10:56:32 -0700
committerChris Robinson <[email protected]>2017-06-29 10:56:32 -0700
commit00694826ef5b2f410cdd9d8a2274b34ea86bffdf (patch)
tree35ec897340abc6a9f79950cf80cf9f4d55426c06 /router/alc.c
parent058d57ef0352ee0f46fc5e0ebe76479660bfc44e (diff)
Protect context switches with a lock in the router
Diffstat (limited to 'router/alc.c')
-rw-r--r--router/alc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/router/alc.c b/router/alc.c
index 0fb9cf4e..1ea9df17 100644
--- a/router/alc.c
+++ b/router/alc.c
@@ -420,16 +420,21 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
{
ALint idx = -1;
+ almtx_lock(&ContextSwitchLock);
if(context)
{
idx = LookupPtrIntMapKey(&ContextIfaceMap, context);
if(idx < 0)
{
ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_CONTEXT);
+ almtx_unlock(&ContextSwitchLock);
return ALC_FALSE;
}
if(!DriverList[idx].alcMakeContextCurrent(context))
+ {
+ almtx_unlock(&ContextSwitchLock);
return ALC_FALSE;
+ }
}
/* Unset the context from the old driver if it's different from the new
@@ -446,6 +451,7 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
if(oldiface && oldiface != &DriverList[idx])
oldiface->alcMakeContextCurrent(NULL);
}
+ almtx_unlock(&ContextSwitchLock);
return ALC_TRUE;
}