From 2c27d8bc756fd4b134aa16ef9901734e1509062b Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 3 Dec 2023 14:18:32 -0800 Subject: 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. --- alc/backends/base.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'alc/backends/base.h') 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. -- cgit v1.2.3