aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-02 02:57:21 -0700
committerChris Robinson <[email protected]>2011-09-02 02:57:21 -0700
commit9080d5fda03d16143e2a446df72fe16d94a40c59 (patch)
treeafaa5df4a41570a3bd3234b7dda0e54a04434799 /Alc/ALc.c
parent108b43458f8c011e6cb43d2b623952ae13108029 (diff)
Do an atomic compare-exchange on the global context when destroying a context
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index df2ba12c..6ce6feaa 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2147,17 +2147,14 @@ ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context)
}
UnlockDevice(Device);
+ if(CompExchangePtr((void**)&GlobalContext, context, NULL))
+ ALCcontext_DecRef(context);
+
if(Device->NumContexts == 0)
{
ALCdevice_StopPlayback(Device);
Device->Flags &= ~DEVICE_RUNNING;
}
-
- if(GlobalContext == context)
- {
- GlobalContext = NULL;
- ALCcontext_DecRef(context);
- }
UnlockLists();
ALCcontext_DecRef(context);