aboutsummaryrefslogtreecommitdiffstats
path: root/alc/converter.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-09-11 03:59:53 -0700
committerChris Robinson <[email protected]>2019-09-11 03:59:53 -0700
commit5b37e2339bc91de3424b51600c3d3b96401d0b9c (patch)
tree4f816457b227ee511563b9b6f0d3fa91bd70b814 /alc/converter.cpp
parentc6c50484160435ee96e51eece154013fe6e48237 (diff)
Simplify flexible array member usage
Diffstat (limited to 'alc/converter.cpp')
-rw-r--r--alc/converter.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/alc/converter.cpp b/alc/converter.cpp
index 7e3c17cc..58b59179 100644
--- a/alc/converter.cpp
+++ b/alc/converter.cpp
@@ -143,14 +143,13 @@ void Stereo2Mono(ALfloat *RESTRICT dst, const void *src, const size_t frames) no
} // namespace
-SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, ALsizei numchans,
- ALsizei srcRate, ALsizei dstRate, Resampler resampler)
+SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, size_t numchans,
+ ALsizei srcRate, ALsizei dstRate, Resampler resampler)
{
- if(numchans <= 0 || srcRate <= 0 || dstRate <= 0)
+ if(numchans < 1 || srcRate < 1 || dstRate < 1)
return nullptr;
- void *ptr{al_calloc(16, SampleConverter::Sizeof(numchans))};
- SampleConverterPtr converter{new (ptr) SampleConverter{static_cast<size_t>(numchans)}};
+ SampleConverterPtr converter{new (FamCount{numchans}) SampleConverter{numchans}};
converter->mSrcType = srcType;
converter->mDstType = dstType;
converter->mSrcTypeSize = BytesFromDevFmt(srcType);
@@ -162,7 +161,7 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType,
/* Have to set the mixer FPU mode since that's what the resampler code expects. */
FPUCtl mixer_mode{};
auto step = static_cast<ALsizei>(
- mind(static_cast<ALdouble>(srcRate)/dstRate*FRACTIONONE + 0.5, MAX_PITCH*FRACTIONONE));
+ mind(srcRate*ALdouble{FRACTIONONE}/dstRate + 0.5, MAX_PITCH*FRACTIONONE));
converter->mIncrement = maxi(step, 1);
if(converter->mIncrement == FRACTIONONE)
converter->mResample = Resample_<CopyTag,CTag>;