aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/base.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-13 01:39:42 -0800
committerChris Robinson <[email protected]>2018-11-13 01:39:42 -0800
commit09ea1d58f63ad3fe248b1e59c0a3634447ce672d (patch)
tree279fab7458858cec3371ca349aa35a503e1535d6 /Alc/backends/base.cpp
parent74d1337cc74c3fab3622188e55c9234257511ac3 (diff)
Convert the backend base to C++
Diffstat (limited to 'Alc/backends/base.cpp')
-rw-r--r--Alc/backends/base.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/Alc/backends/base.cpp b/Alc/backends/base.cpp
new file mode 100644
index 00000000..8173f554
--- /dev/null
+++ b/Alc/backends/base.cpp
@@ -0,0 +1,79 @@
+
+#include "config.h"
+
+#include <stdlib.h>
+
+#include "alMain.h"
+#include "alu.h"
+
+#include "backends/base.h"
+
+
+/* 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)
+{
+ almtx_destroy(&self->mMutex);
+}
+
+ALCboolean ALCbackend_reset(ALCbackend* UNUSED(self))
+{
+ return ALC_FALSE;
+}
+
+ALCenum ALCbackend_captureSamples(ALCbackend* UNUSED(self), void* UNUSED(buffer), ALCuint UNUSED(samples))
+{
+ return ALC_INVALID_DEVICE;
+}
+
+ALCuint ALCbackend_availableSamples(ALCbackend* UNUSED(self))
+{
+ return 0;
+}
+
+ClockLatency ALCbackend_getClockLatency(ALCbackend *self)
+{
+ ALCdevice *device = self->mDevice;
+ ALuint refcount;
+ ClockLatency ret;
+
+ do {
+ while(((refcount=ATOMIC_LOAD(&device->MixCount, almemory_order_acquire))&1))
+ althrd_yield();
+ ret.ClockTime = GetDeviceClockTime(device);
+ ATOMIC_THREAD_FENCE(almemory_order_acquire);
+ } while(refcount != ATOMIC_LOAD(&device->MixCount, almemory_order_relaxed));
+
+ /* NOTE: The device will generally have about all but one periods filled at
+ * any given time during playback. Without a more accurate measurement from
+ * the output, this is an okay approximation.
+ */
+ ret.Latency = device->UpdateSize * DEVICE_CLOCK_RES / device->Frequency *
+ maxu(device->NumUpdates-1, 1);
+
+ return ret;
+}
+
+void ALCbackend_lock(ALCbackend *self)
+{
+ int ret = almtx_lock(&self->mMutex);
+ assert(ret == althrd_success);
+}
+
+void ALCbackend_unlock(ALCbackend *self)
+{
+ int ret = almtx_unlock(&self->mMutex);
+ assert(ret == althrd_success);
+}
+
+
+/* Base ALCbackendFactory method implementations. */
+void ALCbackendFactory_deinit(ALCbackendFactory* UNUSED(self))
+{
+}