diff options
author | Chris Robinson <[email protected]> | 2018-11-24 19:16:21 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-24 19:16:21 -0800 |
commit | 377325e794c77f5372a8fc7991eac85809e60e64 (patch) | |
tree | 4227e5185ba3dfb12567f1ecb03745cbdb786c35 | |
parent | 9e10f632c7a5d66b0f896753e197970eec3ab7cf (diff) |
Use C++ methods a bit more
-rw-r--r-- | Alc/alc.cpp | 14 | ||||
-rw-r--r-- | Alc/mixvoice.cpp | 21 |
2 files changed, 14 insertions, 21 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 434e4660..ec7af970 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -3535,11 +3535,10 @@ ALC_API ALCvoid* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar } else { - size_t i = 0; - for(i = 0;i < COUNTOF(alcFunctions);i++) + for(const auto &func : alcFunctions) { - if(strcmp(alcFunctions[i].funcName, funcName) == 0) - return alcFunctions[i].address; + if(strcmp(func.funcName, funcName) == 0) + return func.address; } } @@ -3560,11 +3559,10 @@ ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *e } else { - size_t i = 0; - for(i = 0;i < COUNTOF(alcEnumerations);i++) + for(const auto &enm : alcEnumerations) { - if(strcmp(alcEnumerations[i].enumName, enumName) == 0) - return alcEnumerations[i].value; + if(strcmp(enm.enumName, enumName) == 0) + return enm.value; } } diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp index c902c66a..6cd170f9 100644 --- a/Alc/mixvoice.cpp +++ b/Alc/mixvoice.cpp @@ -367,15 +367,12 @@ ALboolean MixSource(ALvoice *voice, ALuint SourceID, ALCcontext *Context, ALsize for(chan = 0;chan < NumChannels;chan++) { - const ALfloat *ResampledData; - ALfloat *SrcData = Device->TempBuffer[SOURCE_DATA_BUF]; - ALsizei FilledAmt; + ALfloat *SrcData{Device->TempBuffer[SOURCE_DATA_BUF]}; /* Load the previous samples into the source data first, and clear the rest. */ - memcpy(SrcData, voice->PrevSamples[chan], MAX_RESAMPLE_PADDING*sizeof(ALfloat)); - memset(SrcData+MAX_RESAMPLE_PADDING, 0, (BUFFERSIZE-MAX_RESAMPLE_PADDING)* - sizeof(ALfloat)); - FilledAmt = MAX_RESAMPLE_PADDING; + 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}; if(isstatic) { @@ -513,16 +510,14 @@ ALboolean MixSource(ALvoice *voice, ALuint SourceID, ALCcontext *Context, ALsize } /* Store the last source samples used for next time. */ - memcpy(voice->PrevSamples[chan], - &SrcData[(increment*DstBufferSize + DataPosFrac)>>FRACTIONBITS], - MAX_RESAMPLE_PADDING*sizeof(ALfloat) - ); + std::copy_n(&SrcData[(increment*DstBufferSize + DataPosFrac)>>FRACTIONBITS], + MAX_RESAMPLE_PADDING, voice->PrevSamples[chan]); /* Now resample, then filter and mix to the appropriate outputs. */ - ResampledData = Resample(&voice->ResampleState, + const ALfloat *ResampledData{Resample(&voice->ResampleState, &SrcData[MAX_RESAMPLE_PADDING], DataPosFrac, increment, Device->TempBuffer[RESAMPLED_BUF], DstBufferSize - ); + )}; { DirectParams *parms = &voice->Direct.Params[chan]; const ALfloat *samples; |