diff options
author | Chris Robinson <[email protected]> | 2017-02-28 03:50:42 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-02-28 03:50:42 -0800 |
commit | 1cd6617ff6404cfdcc1ccaf1c08c9d763e27366c (patch) | |
tree | 9c7694cbe6847fcf39147c39fff27ae6e18a643f | |
parent | 52d1f7883b9ff83ff1e3b7d7109e76003361b860 (diff) |
Don't use the mutex in the base getClockLatency implementation
-rw-r--r-- | Alc/backends/base.c | 11 |
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; } |