diff options
author | Chris Robinson <[email protected]> | 2018-11-30 21:23:43 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-30 21:23:43 -0800 |
commit | 1e6e84374b9928b614e7f36a26499d806f3c89cc (patch) | |
tree | 07bf7ef1fb385a7b4209aa6f2b04f4837bbd7e48 /Alc | |
parent | c7569c31ad4b731f1b6c86cbc1833f8b0af4bf82 (diff) |
Use std::array for the voice's PrevSamples
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alc.cpp | 3 | ||||
-rw-r--r-- | Alc/mixvoice.cpp | 11 |
2 files changed, 8 insertions, 6 deletions
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<ALsizei>(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, |