diff options
author | Chris Robinson <[email protected]> | 2020-02-24 11:01:45 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-02-24 11:01:45 -0800 |
commit | 52d86ad51f5425f995597df746fed7a28c8b55af (patch) | |
tree | 98207caa2f631ad996f24dbc2aec17d79eca9324 /al | |
parent | 90d45984dcaeb0232862cf6fb81af186cd328a63 (diff) |
Ignore VoiceChange objects while disconnected
And try to improve ALvoice/VoiceChange handling when attempting to recover a
lost device.
Diffstat (limited to 'al')
-rw-r--r-- | al/source.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/al/source.cpp b/al/source.cpp index dd79a1b6..229a6d66 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -510,9 +510,18 @@ void SendVoiceChanges(ALCcontext *ctx, VoiceChange *tail) oldhead = next; oldhead->mNext.store(tail, std::memory_order_release); + const bool connected{device->Connected.load(std::memory_order_acquire)}; ALuint refcount; while(((refcount=device->MixCount.load(std::memory_order_acquire))&1)) std::this_thread::yield(); + if UNLIKELY(!connected) + { + /* If the device is disconnected, just ignore all pending changes. */ + VoiceChange *cur{ctx->mCurrentVoiceChange.load(std::memory_order_acquire)}; + while(VoiceChange *next{cur->mNext.load(std::memory_order_acquire)}) + cur = next; + ctx->mCurrentVoiceChange.store(cur, std::memory_order_release); + } } |