aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/base.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-12-03 14:18:32 -0800
committerChris Robinson <[email protected]>2023-12-03 14:23:31 -0800
commit2c27d8bc756fd4b134aa16ef9901734e1509062b (patch)
treee3d982f434cf30ef3a802424c44180ee165cb2c1 /alc/backends/base.h
parente6bb91212be93b0b7e4c99c1409f91dd8e211688 (diff)
Make the device clock members atomic
Even though they're protected by a SeqLock of sorts, it's still UB to read and write non-atomic vars from different threads. It's fine to do relaxed reads and writes given the lock though, to help alleviate the cost.
Diffstat (limited to 'alc/backends/base.h')
-rw-r--r--alc/backends/base.h10
1 files changed, 2 insertions, 8 deletions
diff --git a/alc/backends/base.h b/alc/backends/base.h
index e1f53405..f38c1d45 100644
--- a/alc/backends/base.h
+++ b/alc/backends/base.h
@@ -55,14 +55,8 @@ enum class BackendType {
/* Helper to get the current clock time from the device's ClockBase, and
* SamplesDone converted from the sample rate.
*/
-inline std::chrono::nanoseconds GetDeviceClockTime(DeviceBase *device)
-{
- using std::chrono::seconds;
- using std::chrono::nanoseconds;
-
- auto ns = nanoseconds{seconds{device->SamplesDone}} / device->Frequency;
- return device->ClockBase + ns;
-}
+inline std::chrono::nanoseconds GetDeviceClockTime(const DeviceBase *device) noexcept
+{ return device->getClockTime(); }
/* Helper to get the device latency from the backend, including any fixed
* latency from post-processing.