aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/base.h
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/backends/base.h')
-rw-r--r--Alc/backends/base.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/Alc/backends/base.h b/Alc/backends/base.h
index f6b4b80a..04795b36 100644
--- a/Alc/backends/base.h
+++ b/Alc/backends/base.h
@@ -5,6 +5,21 @@
#include "threads.h"
+typedef 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.
+ */
+inline ALuint64 GetDeviceClockTime(ALCdevice *device)
+{
+ return device->ClockBase + (device->SamplesDone * DEVICE_CLOCK_RES /
+ device->Frequency);
+}
+
+
struct ALCbackendVtable;
typedef struct ALCbackend {
@@ -20,7 +35,7 @@ void ALCbackend_Destruct(ALCbackend *self);
ALCboolean ALCbackend_reset(ALCbackend *self);
ALCenum ALCbackend_captureSamples(ALCbackend *self, void *buffer, ALCuint samples);
ALCuint ALCbackend_availableSamples(ALCbackend *self);
-ALint64 ALCbackend_getLatency(ALCbackend *self);
+ClockLatency ALCbackend_getClockLatency(ALCbackend *self);
void ALCbackend_lock(ALCbackend *self);
void ALCbackend_unlock(ALCbackend *self);
@@ -37,7 +52,7 @@ struct ALCbackendVtable {
ALCenum (*const captureSamples)(ALCbackend*, void*, ALCuint);
ALCuint (*const availableSamples)(ALCbackend*);
- ALint64 (*const getLatency)(ALCbackend*);
+ ClockLatency (*const getClockLatency)(ALCbackend*);
void (*const lock)(ALCbackend*);
void (*const unlock)(ALCbackend*);
@@ -54,7 +69,7 @@ DECLARE_THUNK(T, ALCbackend, ALCboolean, start) \
DECLARE_THUNK(T, ALCbackend, void, stop) \
DECLARE_THUNK2(T, ALCbackend, ALCenum, captureSamples, void*, ALCuint) \
DECLARE_THUNK(T, ALCbackend, ALCuint, availableSamples) \
-DECLARE_THUNK(T, ALCbackend, ALint64, getLatency) \
+DECLARE_THUNK(T, ALCbackend, ClockLatency, getClockLatency) \
DECLARE_THUNK(T, ALCbackend, void, lock) \
DECLARE_THUNK(T, ALCbackend, void, unlock) \
static void T##_ALCbackend_Delete(void *ptr) \
@@ -70,7 +85,7 @@ static const struct ALCbackendVtable T##_ALCbackend_vtable = { \
T##_ALCbackend_stop, \
T##_ALCbackend_captureSamples, \
T##_ALCbackend_availableSamples, \
- T##_ALCbackend_getLatency, \
+ T##_ALCbackend_getClockLatency, \
T##_ALCbackend_lock, \
T##_ALCbackend_unlock, \
\