diff options
author | Chris Robinson <[email protected]> | 2019-06-09 18:13:54 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-06-09 18:13:54 -0700 |
commit | bc8f206ee1361ec4b6e740a458bb7985bb7d1429 (patch) | |
tree | 5705d45dbedf6af324b3430654decf8388d0bd21 /Alc/alu.cpp | |
parent | 90d25e5187ca50a6e978603fabb6395035ad0db5 (diff) |
Use a FlexArray for the context's voices
Diffstat (limited to 'Alc/alu.cpp')
-rw-r--r-- | Alc/alu.cpp | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp index e570c2ad..05a6970c 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -177,13 +177,6 @@ void aluInit(void) } -void DeinitVoice(ALvoice *voice) noexcept -{ - delete voice->mUpdate.exchange(nullptr, std::memory_order_acq_rel); - al::destroy_at(voice); -} - - void aluSelectPostProcess(ALCdevice *device) { if(device->mHrtf) @@ -1359,11 +1352,12 @@ void ProcessParamUpdates(ALCcontext *ctx, const ALeffectslotArray *slots) { return CalcEffectSlotParams(slot, ctx, cforce) | force; } ); - std::for_each(ctx->Voices, ctx->Voices+ctx->VoiceCount.load(std::memory_order_acquire), - [ctx,force](ALvoice *voice) -> void + std::for_each(ctx->Voices->begin(), + ctx->Voices->begin() + ctx->VoiceCount.load(std::memory_order_acquire), + [ctx,force](ALvoice &voice) -> void { - ALuint sid{voice->mSourceID.load(std::memory_order_acquire)}; - if(sid) CalcSourceParams(voice, ctx, force); + ALuint sid{voice.mSourceID.load(std::memory_order_acquire)}; + if(sid) CalcSourceParams(&voice, ctx, force); } ); } @@ -1389,15 +1383,16 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo) ); /* Process voices that have a playing source. */ - std::for_each(ctx->Voices, ctx->Voices+ctx->VoiceCount.load(std::memory_order_acquire), - [SamplesToDo,ctx](ALvoice *voice) -> void + std::for_each(ctx->Voices->begin(), + ctx->Voices->begin() + ctx->VoiceCount.load(std::memory_order_acquire), + [SamplesToDo,ctx](ALvoice &voice) -> void { - const ALvoice::State vstate{voice->mPlayState.load(std::memory_order_acquire)}; + 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; + const ALuint sid{voice.mSourceID.load(std::memory_order_relaxed)}; + if(voice.mStep < 1) return; - MixVoice(voice, vstate, sid, ctx, SamplesToDo); + MixVoice(&voice, vstate, sid, ctx, SamplesToDo); } ); @@ -1788,14 +1783,15 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) } } - auto stop_voice = [](ALvoice *voice) -> void + auto stop_voice = [](ALvoice &voice) -> void { - voice->mCurrentBuffer.store(nullptr, std::memory_order_relaxed); - voice->mLoopBuffer.store(nullptr, std::memory_order_relaxed); - voice->mSourceID.store(0u, std::memory_order_relaxed); - voice->mPlayState.store(ALvoice::Stopped, std::memory_order_release); + voice.mCurrentBuffer.store(nullptr, std::memory_order_relaxed); + voice.mLoopBuffer.store(nullptr, std::memory_order_relaxed); + voice.mSourceID.store(0u, std::memory_order_relaxed); + voice.mPlayState.store(ALvoice::Stopped, std::memory_order_release); }; - std::for_each(ctx->Voices, ctx->Voices+ctx->VoiceCount.load(std::memory_order_acquire), + std::for_each(ctx->Voices->begin(), + ctx->Voices->begin() + ctx->VoiceCount.load(std::memory_order_acquire), stop_voice); ctx = ctx->next.load(std::memory_order_relaxed); |