From ef0f3351321a7488e60faa838a4628cfecf230b8 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 9 Mar 2019 16:48:07 -0800 Subject: Add a Stopping state for voices This currently doesn't do much, except have the mixer progress it to Stopped. It's valid to have without a source or buffers, and in the future will allow fading out when a source is paused or stopped. --- Alc/alc.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Alc/alc.cpp') diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 9bba1b52..9891fec5 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -2148,7 +2148,11 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) { delete voice->Update.exchange(nullptr, std::memory_order_acq_rel); - if(voice->SourceID.load(std::memory_order_acquire) == 0u) + /* Force the voice to stopped if it was stopping. */ + ALvoice::State vstate{ALvoice::Stopping}; + voice->PlayState.compare_exchange_strong(vstate, ALvoice::Stopped, + std::memory_order_acquire, std::memory_order_acquire); + if(voice->SourceID.load(std::memory_order_relaxed) == 0u) return; if(device->AvgSpeakerDist > 0.0f) @@ -2625,8 +2629,8 @@ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends) voice->SourceID.store(old_voice->SourceID.load(std::memory_order_relaxed), std::memory_order_relaxed); - voice->Playing.store(old_voice->Playing.load(std::memory_order_relaxed), - std::memory_order_relaxed); + voice->PlayState.store(old_voice->PlayState.load(std::memory_order_relaxed), + std::memory_order_relaxed); voice->Props = old_voice->Props; /* Clear extraneous property set sends. */ -- cgit v1.2.3