diff options
author | Chris Robinson <[email protected]> | 2016-05-28 00:43:14 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-05-28 00:43:14 -0700 |
commit | 6d4380a48c28f21d271d4eb5e668443bc8a0f50e (patch) | |
tree | 1c9c9f6a7b19185cce76f75fbb6c37bff4a9fa8f /Alc/backends/base.h | |
parent | 800e38bac68315d372ca1f865c7c448356309f70 (diff) |
Change the backend getLatency method to return the clock time too
This will also allow backends to better synchronize the tracked clock time with
the device output latency, without necessarily needing to lock if the backend
API can allow for it.
Diffstat (limited to 'Alc/backends/base.h')
-rw-r--r-- | Alc/backends/base.h | 23 |
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, \ \ |