summaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-29 13:22:07 -0700
committerChris Robinson <[email protected]>2011-08-29 13:22:07 -0700
commit72beb577b6190d9df0426825f131a5c8624aaeec (patch)
treefbc6653d88aee582cc7a5751ecc48762c82fa544 /Alc/ALc.c
parentde65ee08c9c3b2261b8329d45cb57b4b4e5cb6a1 (diff)
Lock the context as needed for the defer and process calls
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 9929ee3b..892ccc41 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1361,14 +1361,14 @@ static ALCvoid FreeContext(ALCcontext *context)
free(context);
}
-static void ALCcontext_IncRef(ALCcontext *context)
+void ALCcontext_IncRef(ALCcontext *context)
{
RefCount ref;
ref = IncrementRef(&context->ref);
TRACE("%p refcount increment to %d\n", context, ref);
}
-static void ALCcontext_DecRef(ALCcontext *context)
+void ALCcontext_DecRef(ALCcontext *context)
{
RefCount ref;
ref = DecrementRef(&context->ref);
@@ -1418,6 +1418,30 @@ ALCcontext *GetLockedContext(void)
return context;
}
+/*
+ * GetReffedContext(void)
+ *
+ * Returns the currently active Context, and add a reference to it without
+ * locking
+ */
+ALCcontext *GetReffedContext(void)
+{
+ ALCcontext *context;
+
+ context = pthread_getspecific(LocalContext);
+ if(context)
+ ALCcontext_IncRef(context);
+ else
+ {
+ LockLists();
+ context = GlobalContext;
+ if(context)
+ ALCcontext_IncRef(context);
+ UnlockLists();
+ }
+
+ return context;
+}
///////////////////////////////////////////////////////