diff options
author | Chris Robinson <[email protected]> | 2018-11-22 12:53:16 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-22 12:53:16 -0800 |
commit | 84f0f74d0794b38d1b1bb0021090d50f2648e0ce (patch) | |
tree | 689e2deb49f478901eadccd935647770c5e306cd /Alc/backends | |
parent | bb9d8db73c3536ccea5fbb928ae27810f7f63e0e (diff) |
Use standard types for the device clock times
Diffstat (limited to 'Alc/backends')
-rw-r--r-- | Alc/backends/base.cpp | 2 | ||||
-rw-r--r-- | Alc/backends/base.h | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/Alc/backends/base.cpp b/Alc/backends/base.cpp index f3a4c60e..1839d353 100644 --- a/Alc/backends/base.cpp +++ b/Alc/backends/base.cpp @@ -18,7 +18,7 @@ void ALCdevice_Unlock(ALCdevice *device) ClockLatency GetClockLatency(ALCdevice *device) { ClockLatency ret = V0(device->Backend,getClockLatency)(); - ret.Latency += device->FixedLatency; + ret.Latency += device->FixedLatency.count(); return ret; } diff --git a/Alc/backends/base.h b/Alc/backends/base.h index 61b71a47..db2127ef 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -7,6 +7,9 @@ #include <mutex> struct ClockLatency { + /* FIXME: These should be nanoseconds. Will require changing backends that + * provide this info. + */ ALint64 ClockTime; ALint64 Latency; }; @@ -16,8 +19,12 @@ struct ClockLatency { */ inline ALuint64 GetDeviceClockTime(ALCdevice *device) { - return device->ClockBase + (device->SamplesDone * DEVICE_CLOCK_RES / - device->Frequency); + using std::chrono::seconds; + using std::chrono::nanoseconds; + using std::chrono::duration_cast; + + auto ns = duration_cast<nanoseconds>(seconds{device->SamplesDone}) / device->Frequency; + return (device->ClockBase + ns).count(); } void ALCdevice_Lock(ALCdevice *device); |