diff options
author | Chris Robinson <[email protected]> | 2011-08-28 23:49:50 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-08-28 23:49:50 -0700 |
commit | aa99e1220b72863ca137917d0c45033aad7cd67d (patch) | |
tree | 61a13b6fdaa18c37c219f3f67c66050545bea9c9 /Alc/ALc.c | |
parent | 783375af5623e8290c0080859539445762cef34f (diff) |
Increment the context reference count when locking
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 84 |
1 files changed, 38 insertions, 46 deletions
@@ -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; +} + + /////////////////////////////////////////////////////// |