Pass the voice state as a parameter instead of reloading it

This commit is contained in:
Chris Robinson 2019-03-11 20:00:14 -07:00
parent e0daad6a16
commit 30a7c6d86f
3 changed files with 8 additions and 9 deletions

View File

@ -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);
}
);

View File

@ -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);

View File

@ -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. */