From 1e6e84374b9928b614e7f36a26499d806f3c89cc Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 30 Nov 2018 21:23:43 -0800 Subject: Use std::array for the voice's PrevSamples --- Alc/alc.cpp | 3 ++- Alc/mixvoice.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'Alc') diff --git a/Alc/alc.cpp b/Alc/alc.cpp index b5cc5716..03cbcd53 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -2835,7 +2835,8 @@ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends) voice->Offset = old_voice->Offset; - memcpy(voice->PrevSamples, old_voice->PrevSamples, sizeof(voice->PrevSamples)); + std::copy(std::begin(old_voice->PrevSamples), std::end(old_voice->PrevSamples), + std::begin(voice->PrevSamples)); voice->ResampleState = old_voice->ResampleState; diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp index 1aa3000b..f0ee8bb6 100644 --- a/Alc/mixvoice.cpp +++ b/Alc/mixvoice.cpp @@ -356,13 +356,14 @@ ALboolean MixSource(ALvoice *voice, ALuint SourceID, ALCcontext *Context, ALsize for(ALsizei chan{0};chan < NumChannels;chan++) { - ALfloat *SrcData{Device->TempBuffer[SOURCE_DATA_BUF]}; + ALfloat (&SrcData)[BUFFERSIZE] = Device->TempBuffer[SOURCE_DATA_BUF]; /* Load the previous samples into the source data first, and clear the rest. */ - std::copy_n(voice->PrevSamples[chan], MAX_RESAMPLE_PADDING, SrcData); - std::fill_n(SrcData+MAX_RESAMPLE_PADDING, BUFFERSIZE-MAX_RESAMPLE_PADDING, 0.0f); - ALsizei FilledAmt{MAX_RESAMPLE_PADDING}; + auto srciter = std::copy(std::begin(voice->PrevSamples[chan]), + std::end(voice->PrevSamples[chan]), std::begin(SrcData)); + std::fill(srciter, std::end(SrcData), 0.0f); + auto FilledAmt = static_cast(voice->PrevSamples[chan].size()); if(isstatic) { /* TODO: For static sources, loop points are taken from the @@ -501,7 +502,7 @@ ALboolean MixSource(ALvoice *voice, ALuint SourceID, ALCcontext *Context, ALsize /* Store the last source samples used for next time. */ std::copy_n(&SrcData[(increment*DstBufferSize + DataPosFrac)>>FRACTIONBITS], - MAX_RESAMPLE_PADDING, voice->PrevSamples[chan]); + voice->PrevSamples[chan].size(), std::begin(voice->PrevSamples[chan])); /* Now resample, then filter and mix to the appropriate outputs. */ const ALfloat *ResampledData{Resample(&voice->ResampleState, -- cgit v1.2.3