aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/base.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-02-28 03:50:42 -0800
committerChris Robinson <[email protected]>2017-02-28 03:50:42 -0800
commit1cd6617ff6404cfdcc1ccaf1c08c9d763e27366c (patch)
tree9c7694cbe6847fcf39147c39fff27ae6e18a643f /Alc/backends/base.c
parent52d1f7883b9ff83ff1e3b7d7109e76003361b860 (diff)
Don't use the mutex in the base getClockLatency implementation
Diffstat (limited to 'Alc/backends/base.c')
-rw-r--r--Alc/backends/base.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Alc/backends/base.c b/Alc/backends/base.c
index e4305653..902c4310 100644
--- a/Alc/backends/base.c
+++ b/Alc/backends/base.c
@@ -42,17 +42,22 @@ ALCuint ALCbackend_availableSamples(ALCbackend* UNUSED(self))
ClockLatency ALCbackend_getClockLatency(ALCbackend *self)
{
ALCdevice *device = self->mDevice;
+ ALuint refcount;
ClockLatency ret;
- almtx_lock(&self->mMutex);
- ret.ClockTime = GetDeviceClockTime(device);
+ do {
+ while(((refcount=ATOMIC_LOAD(&device->MixCount, almemory_order_acquire))&1))
+ althrd_yield();
+ ret.ClockTime = GetDeviceClockTime(device);
+ ATOMIC_THREAD_FENCE(almemory_order_acquire);
+ } while(refcount != ATOMIC_LOAD(&device->MixCount, almemory_order_relaxed));
+
/* NOTE: The device will generally have about all but one periods filled at
* any given time during playback. Without a more accurate measurement from
* the output, this is an okay approximation.
*/
ret.Latency = device->UpdateSize * DEVICE_CLOCK_RES / device->Frequency *
maxu(device->NumUpdates-1, 1);
- almtx_unlock(&self->mMutex);
return ret;
}