diff options
author | Chris Robinson <[email protected]> | 2014-04-16 01:39:11 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-16 01:39:11 -0700 |
commit | 29cb5058c0b05cca8ebeb40d84aba8a8d2e11075 (patch) | |
tree | 749d963f365901b22eabd8eaf164f38f2efb8789 /Alc/backends | |
parent | 9c70ca9da6479595946def59cd616e6823c86d78 (diff) |
Use a C11-like mutex wrapper instead of CRITICAL_SECTIONs
Diffstat (limited to 'Alc/backends')
-rw-r--r-- | Alc/backends/base.c | 12 | ||||
-rw-r--r-- | Alc/backends/base.h | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/Alc/backends/base.c b/Alc/backends/base.c index 8e59abdf..37e4ccc9 100644 --- a/Alc/backends/base.c +++ b/Alc/backends/base.c @@ -11,13 +11,15 @@ /* Base ALCbackend method implementations. */ void ALCbackend_Construct(ALCbackend *self, ALCdevice *device) { + int ret; self->mDevice = device; - InitializeCriticalSection(&self->mMutex); + ret = almtx_init(&self->mMutex, almtx_recursive); + assert(ret == althrd_success); } void ALCbackend_Destruct(ALCbackend *self) { - DeleteCriticalSection(&self->mMutex); + almtx_destroy(&self->mMutex); } ALCboolean ALCbackend_reset(ALCbackend* UNUSED(self)) @@ -42,12 +44,14 @@ ALint64 ALCbackend_getLatency(ALCbackend* UNUSED(self)) void ALCbackend_lock(ALCbackend *self) { - EnterCriticalSection(&self->mMutex); + int ret = almtx_lock(&self->mMutex); + assert(ret == althrd_success); } void ALCbackend_unlock(ALCbackend *self) { - LeaveCriticalSection(&self->mMutex); + int ret = almtx_unlock(&self->mMutex); + assert(ret == althrd_success); } diff --git a/Alc/backends/base.h b/Alc/backends/base.h index de5809ca..905c3ea4 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -2,7 +2,7 @@ #define AL_BACKENDS_BASE_H #include "alMain.h" -#include "compat.h" +#include "threads.h" struct ALCbackendVtable; @@ -12,7 +12,7 @@ typedef struct ALCbackend { ALCdevice *mDevice; - CRITICAL_SECTION mMutex; + almtx_t mMutex; } ALCbackend; void ALCbackend_Construct(ALCbackend *self, ALCdevice *device); |