12 #include "alnumeric.h"
16 ClockLatency
GetClockLatency(ALCdevice
*device
)
18 BackendBase
*backend
{device
->Backend
.get()};
19 ClockLatency ret
{backend
->getClockLatency()};
20 ret
.Latency
+= device
->FixedLatency
;
25 /* BackendBase method implementations. */
26 BackendBase::BackendBase(ALCdevice
*device
) noexcept
: mDevice
{device
}
29 BackendBase::~BackendBase() = default;
31 bool BackendBase::reset()
34 ALCenum
BackendBase::captureSamples(al::byte
*, ALCuint
)
35 { return ALC_INVALID_DEVICE
; }
37 ALCuint
BackendBase::availableSamples()
40 ClockLatency
BackendBase::getClockLatency()
46 while(((refcount
=ReadRef(mDevice
->MixCount
))&1) != 0)
47 std::this_thread::yield();
48 ret
.ClockTime
= GetDeviceClockTime(mDevice
);
49 std::atomic_thread_fence(std::memory_order_acquire
);
50 } while(refcount
!= ReadRef(mDevice
->MixCount
));
52 /* NOTE: The device will generally have about all but one periods filled at
53 * any given time during playback. Without a more accurate measurement from
54 * the output, this is an okay approximation.
56 ret
.Latency
= std::max(std::chrono::seconds
{mDevice
->BufferSize
-mDevice
->UpdateSize
},
57 std::chrono::seconds::zero());
58 ret
.Latency
/= mDevice
->Frequency
;