9 #include "backends/base.h"
12 void ALCdevice_Lock(ALCdevice
*device
)
13 { V0(device
->Backend
,lock
)(); }
15 void ALCdevice_Unlock(ALCdevice
*device
)
16 { V0(device
->Backend
,unlock
)(); }
18 ClockLatency
GetClockLatency(ALCdevice
*device
)
20 ClockLatency ret
= V0(device
->Backend
,getClockLatency
)();
21 ret
.Latency
+= device
->FixedLatency
;
26 /* Base ALCbackend method implementations. */
27 void ALCbackend_Construct(ALCbackend
*self
, ALCdevice
*device
)
29 self
->mDevice
= device
;
32 void ALCbackend_Destruct(ALCbackend
* UNUSED(self
))
36 ALCboolean
ALCbackend_reset(ALCbackend
* UNUSED(self
))
41 ALCenum
ALCbackend_captureSamples(ALCbackend
* UNUSED(self
), void* UNUSED(buffer
), ALCuint
UNUSED(samples
))
43 return ALC_INVALID_DEVICE
;
46 ALCuint
ALCbackend_availableSamples(ALCbackend
* UNUSED(self
))
51 ClockLatency
ALCbackend_getClockLatency(ALCbackend
*self
)
53 ALCdevice
*device
= self
->mDevice
;
58 while(((refcount
=device
->MixCount
.load(std::memory_order_acquire
))&1))
60 ret
.ClockTime
= GetDeviceClockTime(device
);
61 std::atomic_thread_fence(std::memory_order_acquire
);
62 } while(refcount
!= device
->MixCount
.load(std::memory_order_relaxed
));
64 /* NOTE: The device will generally have about all but one periods filled at
65 * any given time during playback. Without a more accurate measurement from
66 * the output, this is an okay approximation.
68 ret
.Latency
= std::chrono::seconds
{device
->UpdateSize
*maxi(device
->NumUpdates
-1, 0)};
69 ret
.Latency
/= device
->Frequency
;
74 void ALCbackend_lock(ALCbackend
*self
)
84 void ALCbackend_unlock(ALCbackend
*self
)
87 self
->mMutex
.unlock();