From 02be0149f1bd682b368663f9c6491f1b59fd4acc Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 16 Dec 2020 02:12:18 -0800 Subject: Send stop events when stopping paused voices --- alc/alu.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'alc') diff --git a/alc/alu.cpp b/alc/alu.cpp index 7b7f5006..790b8485 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -1594,14 +1594,17 @@ void ProcessVoiceChanges(ALCcontext *ctx) { voice->mCurrentBuffer.store(nullptr, std::memory_order_relaxed); voice->mLoopBuffer.store(nullptr, std::memory_order_relaxed); - voice->mSourceID.store(0u, std::memory_order_relaxed); + /* A source ID indicates the voice was playing or paused, which + * gets a reset/stop event. + */ + sendevt = voice->mSourceID.exchange(0u, std::memory_order_relaxed) != 0u; Voice::State oldvstate{Voice::Playing}; - sendevt = voice->mPlayState.compare_exchange_strong(oldvstate, Voice::Stopping, + voice->mPlayState.compare_exchange_strong(oldvstate, Voice::Stopping, std::memory_order_relaxed, std::memory_order_acquire); voice->mPendingChange.store(false, std::memory_order_release); } - /* AL_INITIAL state change events are always sent, even if the - * voice is already stopped or even if there is no voice. + /* Reset state change events are always sent, even if the voice is + * already stopped or even if there is no voice. */ sendevt |= (cur->mState == VChangeState::Reset); } @@ -1638,7 +1641,7 @@ void ProcessVoiceChanges(ALCcontext *ctx) } else if(cur->mState == VChangeState::Restart) { - /* Changing a voice offset never sends a source change event. */ + /* Restarting a voice never sends a source change event. */ Voice *oldvoice{cur->mOldVoice}; oldvoice->mCurrentBuffer.store(nullptr, std::memory_order_relaxed); oldvoice->mLoopBuffer.store(nullptr, std::memory_order_relaxed); -- cgit v1.2.3