From 629cfa04a3248bacc9923b879a9c8f0dbe965951 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 12 Apr 2019 19:19:24 -0700 Subject: Fix some integer truncation warnings in MSVC --- Alc/mixvoice.cpp | 81 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) (limited to 'Alc/mixvoice.cpp') diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp index b9e25dbb..e2e0a1e6 100644 --- a/Alc/mixvoice.cpp +++ b/Alc/mixvoice.cpp @@ -215,6 +215,42 @@ void SendSourceStoppedEvent(ALCcontext *context, ALuint id) context->EventSem.post(); } + +const ALfloat *DoFilters(BiquadFilter *lpfilter, BiquadFilter *hpfilter, + ALfloat *RESTRICT dst, const ALfloat *RESTRICT src, ALsizei numsamples, int type) +{ + switch(type) + { + case AF_None: + lpfilter->passthru(numsamples); + hpfilter->passthru(numsamples); + break; + + case AF_LowPass: + lpfilter->process(dst, src, numsamples); + hpfilter->passthru(numsamples); + return dst; + case AF_HighPass: + lpfilter->passthru(numsamples); + hpfilter->process(dst, src, numsamples); + return dst; + + case AF_BandPass: + for(ALsizei i{0};i < numsamples;) + { + ALfloat temp[256]; + ALsizei todo = mini(256, numsamples-i); + + lpfilter->process(temp, src+i, todo); + hpfilter->process(dst+i, temp, todo); + i += todo; + } + return dst; + } + return src; +} + + /* Base template left undefined. Should be marked =delete, but Clang 3.8.1 * chokes on that given the inline specializations. */ @@ -235,7 +271,8 @@ template<> inline ALfloat LoadSample(FmtTypeTraits::Type val) { return aLawDecompressionTable[val] * (1.0f/32768.0f); } template -inline void LoadSampleArray(ALfloat *RESTRICT dst, const void *src, ALint srcstep, ALsizei samples) +inline void LoadSampleArray(ALfloat *RESTRICT dst, const void *src, ALint srcstep, + const ptrdiff_t samples) { using SampleType = typename FmtTypeTraits::Type; @@ -245,10 +282,9 @@ inline void LoadSampleArray(ALfloat *RESTRICT dst, const void *src, ALint srcste } void LoadSamples(ALfloat *RESTRICT dst, const ALvoid *RESTRICT src, ALint srcstep, FmtType srctype, - ALsizei samples) + const ptrdiff_t samples) { -#define HANDLE_FMT(T) \ - case T: LoadSampleArray(dst, src, srcstep, samples); break +#define HANDLE_FMT(T) case T: LoadSampleArray(dst, src, srcstep, samples); break switch(srctype) { HANDLE_FMT(FmtUByte); @@ -261,43 +297,6 @@ void LoadSamples(ALfloat *RESTRICT dst, const ALvoid *RESTRICT src, ALint srcste #undef HANDLE_FMT } - -const ALfloat *DoFilters(BiquadFilter *lpfilter, BiquadFilter *hpfilter, - ALfloat *RESTRICT dst, const ALfloat *RESTRICT src, - ALsizei numsamples, int type) -{ - ALsizei i; - switch(type) - { - case AF_None: - lpfilter->passthru(numsamples); - hpfilter->passthru(numsamples); - break; - - case AF_LowPass: - lpfilter->process(dst, src, numsamples); - hpfilter->passthru(numsamples); - return dst; - case AF_HighPass: - lpfilter->passthru(numsamples); - hpfilter->process(dst, src, numsamples); - return dst; - - case AF_BandPass: - for(i = 0;i < numsamples;) - { - ALfloat temp[256]; - ALsizei todo = mini(256, numsamples-i); - - lpfilter->process(temp, src+i, todo); - hpfilter->process(dst+i, temp, todo); - i += todo; - } - return dst; - } - return src; -} - ALfloat *LoadBufferStatic(ALbufferlistitem *BufferListItem, ALbufferlistitem *&BufferLoopItem, const ALsizei NumChannels, const ALsizei SampleSize, const ALsizei chan, ALsizei DataPosInt, ALfloat *SrcData, const ALfloat *const SrcDataEnd) -- cgit v1.2.3