diff options
author | Chris Robinson <[email protected]> | 2018-11-15 03:49:59 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-15 03:49:59 -0800 |
commit | d4f64b9e29319f56f2ecab1291918a52ec8336f1 (patch) | |
tree | 63e9dade7a1a08b2422ae3c37ee008188e20a677 | |
parent | b7daddb564cfa551c9dcc983bdc0e6bc53cc67d3 (diff) |
Use a C++ mutex with the device backend base
-rw-r--r-- | Alc/backends/base.cpp | 21 | ||||
-rw-r--r-- | Alc/backends/base.h | 14 |
2 files changed, 18 insertions, 17 deletions
diff --git a/Alc/backends/base.cpp b/Alc/backends/base.cpp index 4a20518d..340ca7ac 100644 --- a/Alc/backends/base.cpp +++ b/Alc/backends/base.cpp @@ -26,14 +26,11 @@ ClockLatency GetClockLatency(ALCdevice *device) /* Base ALCbackend method implementations. */ void ALCbackend_Construct(ALCbackend *self, ALCdevice *device) { - int ret = almtx_init(&self->mMutex, almtx_recursive); - assert(ret == althrd_success); self->mDevice = device; } -void ALCbackend_Destruct(ALCbackend *self) +void ALCbackend_Destruct(ALCbackend* UNUSED(self)) { - almtx_destroy(&self->mMutex); } ALCboolean ALCbackend_reset(ALCbackend* UNUSED(self)) @@ -76,14 +73,22 @@ ClockLatency ALCbackend_getClockLatency(ALCbackend *self) void ALCbackend_lock(ALCbackend *self) { - int ret = almtx_lock(&self->mMutex); - assert(ret == althrd_success); + try { + self->mMutex.lock(); + } + catch(...) { + std::terminate(); + } } void ALCbackend_unlock(ALCbackend *self) { - int ret = almtx_unlock(&self->mMutex); - assert(ret == althrd_success); + try { + self->mMutex.unlock(); + } + catch(...) { + std::terminate(); + } } diff --git a/Alc/backends/base.h b/Alc/backends/base.h index 75950344..f8b5f346 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -2,18 +2,16 @@ #define AL_BACKENDS_BASE_H #include "alMain.h" -#include "threads.h" #include "alstring.h" - #ifdef __cplusplus -extern "C" { -#endif -typedef struct ClockLatency { +#include <mutex> + +struct ClockLatency { ALint64 ClockTime; ALint64 Latency; -} ClockLatency; +}; /* Helper to get the current clock time from the device's ClockBase, and * SamplesDone converted from the sample rate. @@ -29,8 +27,6 @@ void ALCdevice_Unlock(ALCdevice *device); ClockLatency GetClockLatency(ALCdevice *device); -#ifdef __cplusplus -} /* extern "C" */ struct ALCbackendVtable; @@ -39,7 +35,7 @@ struct ALCbackend { ALCdevice *mDevice; - almtx_t mMutex; + std::recursive_mutex mMutex; }; void ALCbackend_Construct(ALCbackend *self, ALCdevice *device); |