diff options
author | Chris Robinson <[email protected]> | 2018-11-28 14:38:26 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-28 14:38:26 -0800 |
commit | 14d746e7c2614d17c5c00bf3ec8433bda1501638 (patch) | |
tree | 60984c76908fc6ef2a71d7920133fb1cda6e7cd1 /Alc/alu.cpp | |
parent | 598851fed7dfdd787de3487002afb13ed6e9dc82 (diff) |
Don't sever a paused source from its voice on disconnect
Diffstat (limited to 'Alc/alu.cpp')
-rw-r--r-- | Alc/alu.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp index edf3249d..ecf5f024 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -1862,16 +1862,17 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) std::for_each(ctx->Voices, ctx->Voices+ctx->VoiceCount.load(std::memory_order_acquire), [ctx](ALvoice *voice) -> void { - ALsource *source{voice->Source.exchange(nullptr, std::memory_order_relaxed)}; - if(source && voice->Playing.load(std::memory_order_relaxed)) - { - /* If the source's voice was playing, it's now effectively - * stopped (the source state will be updated the next time - * it's checked). - */ - SendSourceStoppedEvent(ctx, source->id); - } + ALsource *source{voice->Source.load(std::memory_order_relaxed)}; + if(!source || !voice->Playing.load(std::memory_order_relaxed)) + return; + + voice->Source.store(nullptr, std::memory_order_relaxed); voice->Playing.store(false, std::memory_order_release); + /* If the source's voice was playing, it's now effectively + * stopped (the source state will be updated the next time it's + * checked). + */ + SendSourceStoppedEvent(ctx, source->id); } ); |