aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-28 23:49:50 -0700
committerChris Robinson <[email protected]>2011-08-28 23:49:50 -0700
commitaa99e1220b72863ca137917d0c45033aad7cd67d (patch)
tree61a13b6fdaa18c37c219f3f67c66050545bea9c9 /Alc/ALc.c
parent783375af5623e8290c0080859539445762cef34f (diff)
Increment the context reference count when locking
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c84
1 files changed, 38 insertions, 46 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index dd195bbe..e9c6000e 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1287,52 +1287,6 @@ ALCvoid UnlockDevice(ALCdevice *device)
LeaveCriticalSection(&device->Mutex);
}
-/*
- LockContext
-
- Thread-safe entry
-*/
-ALCvoid LockContext(ALCcontext *context)
-{
- EnterCriticalSection(&context->Device->Mutex);
-}
-
-
-/*
- UnlockContext
-
- Thread-safe exit
-*/
-ALCvoid UnlockContext(ALCcontext *context)
-{
- LeaveCriticalSection(&context->Device->Mutex);
-}
-
-
-/*
- GetLockedContext
-
- Returns the currently active Context, in a locked state
-*/
-ALCcontext *GetLockedContext(void)
-{
- ALCcontext *context = NULL;
-
- context = pthread_getspecific(LocalContext);
- if(context)
- LockContext(context);
- else
- {
- LockLists();
- context = GlobalContext;
- if(context)
- LockContext(context);
- UnlockLists();
- }
-
- return context;
-}
-
/*
InitContext
@@ -1432,6 +1386,44 @@ static void ReleaseThreadCtx(void *ptr)
ALCcontext_DecRef(ptr);
}
+
+ALCvoid LockContext(ALCcontext *context)
+{
+ ALCcontext_IncRef(context);
+ EnterCriticalSection(&context->Device->Mutex);
+}
+
+ALCvoid UnlockContext(ALCcontext *context)
+{
+ LeaveCriticalSection(&context->Device->Mutex);
+ ALCcontext_DecRef(context);
+}
+
+/*
+ * GetLockedContext
+ *
+ * Returns the currently active Context, in a locked state
+ */
+ALCcontext *GetLockedContext(void)
+{
+ ALCcontext *context = NULL;
+
+ context = pthread_getspecific(LocalContext);
+ if(context)
+ LockContext(context);
+ else
+ {
+ LockLists();
+ context = GlobalContext;
+ if(context)
+ LockContext(context);
+ UnlockLists();
+ }
+
+ return context;
+}
+
+
///////////////////////////////////////////////////////