From d82d30cce98194a98a3eb32b60b49a1ae57ae5ef Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 29 Mar 2023 00:28:31 -0700 Subject: Make sure delayed-start voices are properly stopped --- core/voice.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'core/voice.cpp') diff --git a/core/voice.cpp b/core/voice.cpp index ee5f6ae6..e8fbcccd 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -732,8 +732,17 @@ void Voice::mix(const State vstate, ContextBase *Context, const nanoseconds devi uint OutPos{0u}; /* Check if we're doing a delayed start, and we start in this update. */ - if(mStartTime > deviceTime) + if(mStartTime > deviceTime) UNLIKELY { + /* If the voice is supposed to be stopping but hasn't actually started + * yet, make sure its stopped. + */ + if(vstate == Stopping) + { + mPlayState.store(Stopped, std::memory_order_release); + return; + } + /* If the start time is too far ahead, don't bother. */ auto diff = mStartTime - deviceTime; if(diff >= seconds{1}) -- cgit v1.2.3