aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
Diffstat (limited to 'alc')
-rw-r--r--alc/backends/coreaudio.cpp9
-rw-r--r--alc/backends/wasapi.cpp10
-rw-r--r--alc/converter.cpp52
-rw-r--r--alc/converter.h8
4 files changed, 38 insertions, 41 deletions
diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp
index cfa7703a..c903ff07 100644
--- a/alc/backends/coreaudio.cpp
+++ b/alc/backends/coreaudio.cpp
@@ -654,15 +654,14 @@ ALCenum CoreAudioCapture::captureSamples(void *buffer, ALCuint samples)
auto rec_vec = mRing->getReadVector();
const void *src0{rec_vec.first.buf};
- auto src0len = static_cast<ALsizei>(rec_vec.first.len);
- auto got = static_cast<ALuint>(mConverter->convert(&src0, &src0len, buffer, samples));
+ auto src0len = static_cast<ALuint>(rec_vec.first.len);
+ ALuint got{mConverter->convert(&src0, &src0len, buffer, samples)};
size_t total_read{rec_vec.first.len - src0len};
if(got < samples && !src0len && rec_vec.second.len > 0)
{
const void *src1{rec_vec.second.buf};
- auto src1len = static_cast<ALsizei>(rec_vec.second.len);
- got += static_cast<ALuint>(mConverter->convert(&src1, &src1len,
- static_cast<char*>(buffer)+got, samples-got));
+ auto src1len = static_cast<ALuint>(rec_vec.second.len);
+ got += mConverter->convert(&src1, &src1len, static_cast<char*>(buffer)+got, samples-got);
total_read += rec_vec.second.len - src1len;
}
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp
index cc53be66..dbf1208d 100644
--- a/alc/backends/wasapi.cpp
+++ b/alc/backends/wasapi.cpp
@@ -1229,10 +1229,10 @@ FORCE_ALIGN int WasapiCapture::recordProc()
if(mSampleConv)
{
const ALvoid *srcdata{rdata};
- auto srcframes = static_cast<ALsizei>(numsamples);
+ ALuint srcframes{numsamples};
dstframes = mSampleConv->convert(&srcdata, &srcframes, data.first.buf,
- static_cast<ALsizei>(minz(data.first.len, INT_MAX)));
+ static_cast<ALuint>(minz(data.first.len, INT_MAX)));
if(srcframes > 0 && dstframes == data.first.len && data.second.len > 0)
{
/* If some source samples remain, all of the first dest
@@ -1240,14 +1240,14 @@ FORCE_ALIGN int WasapiCapture::recordProc()
* dest block, do another run for the second block.
*/
dstframes += mSampleConv->convert(&srcdata, &srcframes, data.second.buf,
- static_cast<ALsizei>(minz(data.second.len, INT_MAX)));
+ static_cast<ALuint>(minz(data.second.len, INT_MAX)));
}
}
else
{
const auto framesize = static_cast<ALuint>(mDevice->frameSizeFromFmt());
- size_t len1 = minz(data.first.len, numsamples);
- size_t len2 = minz(data.second.len, numsamples-len1);
+ size_t len1{minz(data.first.len, numsamples)};
+ size_t len2{minz(data.second.len, numsamples-len1)};
memcpy(data.first.buf, rdata, len1*framesize);
if(len2 > 0)
diff --git a/alc/converter.cpp b/alc/converter.cpp
index 1fa4a5d0..e66e5929 100644
--- a/alc/converter.cpp
+++ b/alc/converter.cpp
@@ -41,17 +41,17 @@ template<> inline ALfloat LoadSample<DevFmtUInt>(DevFmtTypeTraits<DevFmtUInt>::T
template<DevFmtType T>
inline void LoadSampleArray(ALfloat *RESTRICT dst, const void *src, const size_t srcstep,
- const ALsizei samples) noexcept
+ const size_t samples) noexcept
{
using SampleType = typename DevFmtTypeTraits<T>::Type;
const SampleType *ssrc = static_cast<const SampleType*>(src);
- for(ALsizei i{0};i < samples;i++)
+ for(size_t i{0u};i < samples;i++)
dst[i] = LoadSample<T>(ssrc[i*srcstep]);
}
void LoadSamples(ALfloat *dst, const ALvoid *src, const size_t srcstep, const DevFmtType srctype,
- const ALsizei samples) noexcept
+ const size_t samples) noexcept
{
#define HANDLE_FMT(T) \
case T: LoadSampleArray<T>(dst, src, srcstep, samples); break
@@ -91,18 +91,18 @@ template<> inline ALubyte StoreSample<DevFmtUByte>(ALfloat val) noexcept
template<DevFmtType T>
inline void StoreSampleArray(void *dst, const ALfloat *RESTRICT src, const size_t dststep,
- const ALsizei samples) noexcept
+ const size_t samples) noexcept
{
using SampleType = typename DevFmtTypeTraits<T>::Type;
SampleType *sdst = static_cast<SampleType*>(dst);
- for(ALsizei i{0};i < samples;i++)
+ for(size_t i{0u};i < samples;i++)
sdst[i*dststep] = StoreSample<T>(src[i]);
}
void StoreSamples(ALvoid *dst, const ALfloat *src, const size_t dststep, const DevFmtType dsttype,
- const ALsizei samples) noexcept
+ const size_t samples) noexcept
{
#define HANDLE_FMT(T) \
case T: StoreSampleArray<T>(dst, src, dststep, samples); break
@@ -121,22 +121,22 @@ void StoreSamples(ALvoid *dst, const ALfloat *src, const size_t dststep, const D
template<DevFmtType T>
-void Mono2Stereo(ALfloat *RESTRICT dst, const void *src, const ALsizei frames) noexcept
+void Mono2Stereo(ALfloat *RESTRICT dst, const void *src, const size_t frames) noexcept
{
using SampleType = typename DevFmtTypeTraits<T>::Type;
const SampleType *ssrc = static_cast<const SampleType*>(src);
- for(ALsizei i{0};i < frames;i++)
+ for(size_t i{0u};i < frames;i++)
dst[i*2 + 1] = dst[i*2 + 0] = LoadSample<T>(ssrc[i]) * 0.707106781187f;
}
template<DevFmtType T>
-void Stereo2Mono(ALfloat *RESTRICT dst, const void *src, const ALsizei frames) noexcept
+void Stereo2Mono(ALfloat *RESTRICT dst, const void *src, const size_t frames) noexcept
{
using SampleType = typename DevFmtTypeTraits<T>::Type;
const SampleType *ssrc = static_cast<const SampleType*>(src);
- for(ALsizei i{0};i < frames;i++)
+ for(size_t i{0u};i < frames;i++)
dst[i] = (LoadSample<T>(ssrc[i*2 + 0])+LoadSample<T>(ssrc[i*2 + 1])) *
0.707106781187f;
}
@@ -178,13 +178,13 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType,
return converter;
}
-ALsizei SampleConverter::availableOut(ALsizei srcframes) const
+ALuint SampleConverter::availableOut(ALuint srcframes) const
{
ALint prepcount{mSrcPrepCount};
if(prepcount < 0)
{
/* Negative prepcount means we need to skip that many input samples. */
- if(-prepcount >= srcframes)
+ if(static_cast<ALuint>(-prepcount) >= srcframes)
return 0;
srcframes += prepcount;
prepcount = 0;
@@ -197,7 +197,7 @@ ALsizei SampleConverter::availableOut(ALsizei srcframes) const
}
if(prepcount < MAX_RESAMPLE_PADDING*2 &&
- MAX_RESAMPLE_PADDING*2 - prepcount >= srcframes)
+ static_cast<ALuint>(MAX_RESAMPLE_PADDING*2 - prepcount) >= srcframes)
{
/* Not enough input samples to generate an output sample. */
return 0;
@@ -210,26 +210,26 @@ ALsizei SampleConverter::availableOut(ALsizei srcframes) const
DataSize64 -= mFracOffset;
/* If we have a full prep, we can generate at least one sample. */
- return static_cast<ALsizei>(clampu64((DataSize64 + mIncrement-1)/mIncrement, 1, BUFFERSIZE));
+ return static_cast<ALuint>(clampu64((DataSize64 + mIncrement-1)/mIncrement, 1, BUFFERSIZE));
}
-ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid *dst, ALsizei dstframes)
+ALuint SampleConverter::convert(const ALvoid **src, ALuint *srcframes, ALvoid *dst, ALuint dstframes)
{
const ALsizei SrcFrameSize{static_cast<ALsizei>(mChan.size()) * mSrcTypeSize};
const ALsizei DstFrameSize{static_cast<ALsizei>(mChan.size()) * mDstTypeSize};
const ALsizei increment{mIncrement};
auto SamplesIn = static_cast<const al::byte*>(*src);
- ALsizei NumSrcSamples{*srcframes};
+ ALuint NumSrcSamples{*srcframes};
FPUCtl mixer_mode{};
- ALsizei pos{0};
+ ALuint pos{0};
while(pos < dstframes && NumSrcSamples > 0)
{
ALint prepcount{mSrcPrepCount};
if(prepcount < 0)
{
/* Negative prepcount means we need to skip that many input samples. */
- if(-prepcount >= NumSrcSamples)
+ if(static_cast<ALuint>(-prepcount) >= NumSrcSamples)
{
mSrcPrepCount = prepcount + NumSrcSamples;
NumSrcSamples = 0;
@@ -240,10 +240,10 @@ ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid
mSrcPrepCount = 0;
continue;
}
- ALint toread{mini(NumSrcSamples, BUFFERSIZE - MAX_RESAMPLE_PADDING*2)};
+ ALuint toread{minu(NumSrcSamples, BUFFERSIZE - MAX_RESAMPLE_PADDING*2)};
if(prepcount < MAX_RESAMPLE_PADDING*2 &&
- MAX_RESAMPLE_PADDING*2 - prepcount >= toread)
+ static_cast<ALuint>(MAX_RESAMPLE_PADDING*2 - prepcount) >= toread)
{
/* Not enough input samples to generate an output sample. Store
* what we're given for later.
@@ -267,9 +267,9 @@ ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid
DataSize64 -= DataPosFrac;
/* If we have a full prep, we can generate at least one sample. */
- auto DstSize = static_cast<ALsizei>(
+ auto DstSize = static_cast<ALuint>(
clampu64((DataSize64 + increment-1)/increment, 1, BUFFERSIZE));
- DstSize = mini(DstSize, dstframes-pos);
+ DstSize = minu(DstSize, dstframes-pos);
for(size_t chan{0u};chan < mChan.size();chan++)
{
@@ -285,13 +285,13 @@ ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid
/* Store as many prep samples for next time as possible, given the
* number of output samples being generated.
*/
- ALsizei SrcDataEnd{(DstSize*increment + DataPosFrac)>>FRACTIONBITS};
+ ALuint SrcDataEnd{(DstSize*increment + DataPosFrac)>>FRACTIONBITS};
if(SrcDataEnd >= prepcount+toread)
std::fill(std::begin(mChan[chan].PrevSamples),
std::end(mChan[chan].PrevSamples), 0.0f);
else
{
- size_t len = mini(MAX_RESAMPLE_PADDING*2, prepcount+toread-SrcDataEnd);
+ size_t len{minu(MAX_RESAMPLE_PADDING*2, prepcount+toread-SrcDataEnd)};
std::copy_n(SrcData+SrcDataEnd, len, mChan[chan].PrevSamples);
std::fill(std::begin(mChan[chan].PrevSamples)+len,
std::end(mChan[chan].PrevSamples), 0.0f);
@@ -314,7 +314,7 @@ ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid
/* Update the src and dst pointers in case there's still more to do. */
SamplesIn += SrcFrameSize*(DataPosFrac>>FRACTIONBITS);
- NumSrcSamples -= mini(NumSrcSamples, (DataPosFrac>>FRACTIONBITS));
+ NumSrcSamples -= minu(NumSrcSamples, (DataPosFrac>>FRACTIONBITS));
dst = static_cast<al::byte*>(dst) + DstFrameSize*DstSize;
pos += DstSize;
@@ -335,7 +335,7 @@ ChannelConverterPtr CreateChannelConverter(DevFmtType srcType, DevFmtChannels sr
return al::make_unique<ChannelConverter>(srcType, srcChans, dstChans);
}
-void ChannelConverter::convert(const ALvoid *src, ALfloat *dst, ALsizei frames) const
+void ChannelConverter::convert(const ALvoid *src, ALfloat *dst, ALuint frames) const
{
if(mSrcChans == DevFmtStereo && mDstChans == DevFmtMono)
{
diff --git a/alc/converter.h b/alc/converter.h
index 9a3308b5..50254213 100644
--- a/alc/converter.h
+++ b/alc/converter.h
@@ -35,11 +35,9 @@ struct SampleConverter {
al::FlexArray<ChanSamples> mChan;
SampleConverter(size_t numchans) : mChan{numchans} { }
- SampleConverter(const SampleConverter&) = delete;
- SampleConverter& operator=(const SampleConverter&) = delete;
- ALsizei convert(const ALvoid **src, ALsizei *srcframes, ALvoid *dst, ALsizei dstframes);
- ALsizei availableOut(ALsizei srcframes) const;
+ ALuint convert(const ALvoid **src, ALuint *srcframes, ALvoid *dst, ALuint dstframes);
+ ALuint availableOut(ALuint srcframes) const;
static constexpr size_t Sizeof(size_t length) noexcept
{
@@ -64,7 +62,7 @@ struct ChannelConverter {
: mSrcType(srctype), mSrcChans(srcchans), mDstChans(dstchans)
{ }
- void convert(const ALvoid *src, ALfloat *dst, ALsizei frames) const;
+ void convert(const ALvoid *src, ALfloat *dst, ALuint frames) const;
DEF_NEWDEL(ChannelConverter)
};