diff options
author | Chris Robinson <[email protected]> | 2019-03-11 20:00:14 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-03-11 20:00:14 -0700 |
commit | 30a7c6d86fba69130b6ed64731745135f207ba35 (patch) | |
tree | 1a44e54f07f205bb62ffd850ce925af5a228a9bd | |
parent | e0daad6a164e1a091c46be7ece905b32a20036bd (diff) |
Pass the voice state as a parameter instead of reloading it
-rw-r--r-- | Alc/alu.cpp | 8 | ||||
-rw-r--r-- | Alc/mixvoice.cpp | 7 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 2 |
3 files changed, 8 insertions, 9 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp index 30d2e73c..0ee0275a 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -1451,12 +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->mPlayState.load(std::memory_order_acquire) == ALvoice::Stopped) - return; - ALuint sid{voice->mSourceID.load(std::memory_order_relaxed)}; + const ALvoice::State vstate{voice->mPlayState.load(std::memory_order_acquire)}; + if(vstate == ALvoice::Stopped) return; + const ALuint sid{voice->mSourceID.load(std::memory_order_relaxed)}; if(voice->mStep < 1) return; - MixSource(voice, sid, ctx, SamplesToDo); + MixVoice(voice, vstate, sid, ctx, SamplesToDo); } ); diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp index c2b2791b..3e4cd1d2 100644 --- a/Alc/mixvoice.cpp +++ b/Alc/mixvoice.cpp @@ -442,14 +442,13 @@ ALsizei LoadBufferQueue(ALbufferlistitem *BufferListItem, ALbufferlistitem *Buff } // namespace -void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const ALsizei SamplesToDo) +void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCcontext *Context, const ALsizei SamplesToDo) { static constexpr ALfloat SilentTarget[MAX_OUTPUT_CHANNELS]{}; ASSUME(SamplesToDo > 0); - /* Get source info */ - ALvoice::State vstate{voice->mPlayState.load(std::memory_order_acquire)}; + /* Get voice info */ const bool isstatic{(voice->mFlags&VOICE_IS_STATIC) != 0}; ALsizei DataPosInt{static_cast<ALsizei>(voice->mPosition.load(std::memory_order_relaxed))}; ALsizei DataPosFrac{voice->mPositionFrac.load(std::memory_order_relaxed)}; @@ -822,7 +821,7 @@ void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const return; } - /* Update source info */ + /* Update voice info */ voice->mPosition.store(DataPosInt, std::memory_order_relaxed); voice->mPositionFrac.store(DataPosFrac, std::memory_order_relaxed); voice->mCurrentBuffer.store(BufferListItem, std::memory_order_relaxed); diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 1de184cb..952d1004 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -446,7 +446,7 @@ inline std::array<ALfloat,MAX_AMBI_CHANNELS> GetAmbiIdentityRow(size_t i) noexce } -void MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, const ALsizei SamplesToDo); +void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCcontext *Context, const ALsizei SamplesToDo); void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples); /* Caller must lock the device state, and the mixer must not be running. */ |