diff options
author | Chris Robinson <[email protected]> | 2019-03-09 13:20:10 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-03-09 13:20:10 -0800 |
commit | d39cfcc7bb4f7c7ad6686bfc455785438d6b22ae (patch) | |
tree | fbf110d7fc5807df3cc94446ff804cd869439d39 | |
parent | 972a5c0f1d27a02f84823bd8afed5cac01459420 (diff) |
Clear the voice's buffer when detaching from source
-rw-r--r-- | Alc/alu.cpp | 4 | ||||
-rw-r--r-- | OpenAL32/alSource.cpp | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp index 85482084..28f6346e 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -1457,6 +1457,8 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo) 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); @@ -1816,6 +1818,8 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) 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); /* If the source's voice was playing, it's now effectively stopped diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index 30ba02f6..9b0e5672 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -530,6 +530,8 @@ void FreeSource(ALCcontext *context, ALsource *source) BackendUniqueLock backlock{*device->Backend}; if(ALvoice *voice{GetSourceVoice(source, context)}) { + 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); } @@ -2931,6 +2933,8 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources) ALvoice *voice{GetSourceVoice(source, context.get())}; if(voice != nullptr) { + 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 = nullptr; @@ -2974,6 +2978,8 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources) ALvoice *voice{GetSourceVoice(source, context.get())}; if(voice != nullptr) { + 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 = nullptr; |