11 #include "backends/base.h"
14 void ALCdevice_Lock(ALCdevice
*device
)
15 { V0(device
->Backend
,lock
)(); }
17 void ALCdevice_Unlock(ALCdevice
*device
)
18 { V0(device
->Backend
,unlock
)(); }
20 ClockLatency
GetClockLatency(ALCdevice
*device
)
22 ClockLatency ret
= V0(device
->Backend
,getClockLatency
)();
23 ret
.Latency
+= device
->FixedLatency
;
28 /* Base ALCbackend method implementations. */
29 void ALCbackend_Construct(ALCbackend
*self
, ALCdevice
*device
)
31 self
->mDevice
= device
;
34 void ALCbackend_Destruct(ALCbackend
* UNUSED(self
))
38 ALCboolean
ALCbackend_reset(ALCbackend
* UNUSED(self
))
43 ALCenum
ALCbackend_captureSamples(ALCbackend
* UNUSED(self
), void* UNUSED(buffer
), ALCuint
UNUSED(samples
))
45 return ALC_INVALID_DEVICE
;
48 ALCuint
ALCbackend_availableSamples(ALCbackend
* UNUSED(self
))
53 ClockLatency
ALCbackend_getClockLatency(ALCbackend
*self
)
55 ALCdevice
*device
= self
->mDevice
;
60 while(((refcount
=device
->MixCount
.load(std::memory_order_acquire
))&1))
61 std::this_thread::yield();
62 ret
.ClockTime
= GetDeviceClockTime(device
);
63 std::atomic_thread_fence(std::memory_order_acquire
);
64 } while(refcount
!= device
->MixCount
.load(std::memory_order_relaxed
));
66 /* NOTE: The device will generally have about all but one periods filled at
67 * any given time during playback. Without a more accurate measurement from
68 * the output, this is an okay approximation.
70 ret
.Latency
= std::chrono::seconds
{device
->UpdateSize
*maxi(device
->NumUpdates
-1, 0)};
71 ret
.Latency
/= device
->Frequency
;
76 void ALCbackend_lock(ALCbackend
*self
)
86 void ALCbackend_unlock(ALCbackend
*self
)
89 self
->mMutex
.unlock();