aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alu.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-03-09 16:48:07 -0800
committerChris Robinson <[email protected]>2019-03-09 16:48:07 -0800
commitef0f3351321a7488e60faa838a4628cfecf230b8 (patch)
treea28d31d1eb4fdf785a6f2fceeaa7cface4a02973 /Alc/alu.cpp
parentcde4500e24a8f5067d87711bf778cde99f26d990 (diff)
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.
Diffstat (limited to 'Alc/alu.cpp')
-rw-r--r--Alc/alu.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index 28f6346e..bf401638 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -1451,18 +1451,12 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
std::for_each(ctx->Voices, ctx->Voices+ctx->VoiceCount.load(std::memory_order_acquire),
[SamplesToDo,ctx](ALvoice *voice) -> void
{
- if(!voice->Playing.load(std::memory_order_acquire)) return;
+ if(voice->PlayState.load(std::memory_order_acquire) == ALvoice::Stopped)
+ return;
ALuint sid{voice->SourceID.load(std::memory_order_relaxed)};
- if(!sid || voice->Step < 1) return;
+ if(voice->Step < 1) return;
- if(!MixSource(voice, sid, ctx, SamplesToDo))
- {
- voice->current_buffer.store(nullptr, std::memory_order_relaxed);
- voice->loop_buffer.store(nullptr, std::memory_order_relaxed);
- voice->SourceID.store(0u, std::memory_order_relaxed);
- voice->Playing.store(false, std::memory_order_release);
- SendSourceStoppedEvent(ctx, sid);
- }
+ MixSource(voice, sid, ctx, SamplesToDo);
}
);
@@ -1814,14 +1808,15 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...)
auto stop_voice = [ctx](ALvoice *voice) -> void
{
- if(!voice->Playing.load(std::memory_order_acquire)) return;
+ if(voice->PlayState.load(std::memory_order_acquire) == ALvoice::Playing)
+ return;
ALuint sid{voice->SourceID.load(std::memory_order_relaxed)};
if(!sid) return;
voice->current_buffer.store(nullptr, std::memory_order_relaxed);
voice->loop_buffer.store(nullptr, std::memory_order_relaxed);
voice->SourceID.store(0u, std::memory_order_relaxed);
- voice->Playing.store(false, std::memory_order_release);
+ voice->PlayState.store(ALvoice::Stopped, 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).
*/