aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alc/alc.cpp6
-rw-r--r--alc/alcmain.h6
-rw-r--r--alc/backends/dsound.cpp4
-rw-r--r--alc/backends/jack.cpp12
-rw-r--r--alc/backends/oss.cpp59
-rw-r--r--alc/backends/portaudio.cpp10
-rw-r--r--alc/backends/sdl2.cpp2
-rw-r--r--alc/backends/sndio.cpp13
-rw-r--r--alc/backends/solaris.cpp8
-rw-r--r--alc/backends/wasapi.cpp5
-rw-r--r--alc/backends/wave.cpp10
-rw-r--r--alc/converter.cpp7
-rw-r--r--alc/devformat.h6
13 files changed, 67 insertions, 81 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 6d7228f5..9bb604a4 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -1272,7 +1272,7 @@ const ALCchar *DevFmtChannelsString(DevFmtChannels chans) noexcept
return "(unknown channels)";
}
-ALsizei BytesFromDevFmt(DevFmtType type) noexcept
+ALuint BytesFromDevFmt(DevFmtType type) noexcept
{
switch(type)
{
@@ -1286,7 +1286,7 @@ ALsizei BytesFromDevFmt(DevFmtType type) noexcept
}
return 0;
}
-ALsizei ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept
+ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept
{
switch(chans)
{
@@ -1297,7 +1297,7 @@ ALsizei ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept
case DevFmtX51Rear: return 6;
case DevFmtX61: return 7;
case DevFmtX71: return 8;
- case DevFmtAmbi3D: return (ambiorder+1) * (ambiorder+1);
+ case DevFmtAmbi3D: return static_cast<ALuint>((ambiorder+1) * (ambiorder+1));
}
return 0;
}
diff --git a/alc/alcmain.h b/alc/alcmain.h
index 338897ab..f7842d96 100644
--- a/alc/alcmain.h
+++ b/alc/alcmain.h
@@ -340,9 +340,9 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
ALCdevice& operator=(const ALCdevice&) = delete;
~ALCdevice();
- ALsizei bytesFromFmt() const noexcept { return BytesFromDevFmt(FmtType); }
- ALsizei channelsFromFmt() const noexcept { return ChannelsFromDevFmt(FmtChans, mAmbiOrder); }
- ALsizei frameSizeFromFmt() const noexcept { return bytesFromFmt() * channelsFromFmt(); }
+ ALuint bytesFromFmt() const noexcept { return BytesFromDevFmt(FmtType); }
+ ALuint channelsFromFmt() const noexcept { return ChannelsFromDevFmt(FmtChans, mAmbiOrder); }
+ ALuint frameSizeFromFmt() const noexcept { return bytesFromFmt() * channelsFromFmt(); }
void ProcessHrtf(const size_t SamplesToDo);
void ProcessAmbiDec(const size_t SamplesToDo);
diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp
index ad182cf7..1c44c2ec 100644
--- a/alc/backends/dsound.cpp
+++ b/alc/backends/dsound.cpp
@@ -219,7 +219,7 @@ FORCE_ALIGN int DSoundPlayback::mixerProc()
return 1;
}
- ALsizei FrameSize{mDevice->frameSizeFromFmt()};
+ ALuint FrameSize{mDevice->frameSizeFromFmt()};
DWORD FragSize{mDevice->UpdateSize * FrameSize};
bool Playing{false};
@@ -820,7 +820,7 @@ ALCuint DSoundCapture::availableSamples()
if(!mDevice->Connected.load(std::memory_order_acquire))
return static_cast<ALCuint>(mRing->readSpace());
- ALsizei FrameSize{mDevice->frameSizeFromFmt()};
+ ALuint FrameSize{mDevice->frameSizeFromFmt()};
DWORD BufferBytes{mBufferBytes};
DWORD LastCursor{mCursor};
diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp
index e688b96b..e1ae91f0 100644
--- a/alc/backends/jack.cpp
+++ b/alc/backends/jack.cpp
@@ -235,7 +235,7 @@ int JackPlayback::process(jack_nframes_t numframes)
}
auto data = mRing->getReadVector();
- jack_nframes_t todo{minu(numframes, data.first.len)};
+ jack_nframes_t todo{minu(numframes, static_cast<ALuint>(data.first.len))};
std::transform(out, out+numchans, out,
[&data,numchans,todo](ALfloat *outbuf) -> ALfloat*
{
@@ -254,7 +254,7 @@ int JackPlayback::process(jack_nframes_t numframes)
);
jack_nframes_t total{todo};
- todo = minu(numframes-total, data.second.len);
+ todo = minu(numframes-total, static_cast<ALuint>(data.second.len));
if(todo > 0)
{
std::transform(out, out+numchans, out,
@@ -315,8 +315,8 @@ int JackPlayback::mixerProc()
auto todo = static_cast<ALuint>(data.first.len + data.second.len);
todo -= todo%mDevice->UpdateSize;
- ALuint len1{minu(data.first.len, todo)};
- ALuint len2{minu(data.second.len, todo-len1)};
+ ALuint len1{minu(static_cast<ALuint>(data.first.len), todo)};
+ ALuint len2{minu(static_cast<ALuint>(data.second.len), todo-len1)};
aluMixData(mDevice, data.first.buf, len1);
if(len2 > 0)
@@ -382,8 +382,7 @@ ALCboolean JackPlayback::reset()
/* Force 32-bit float output. */
mDevice->FmtType = DevFmtFloat;
- ALsizei numchans{mDevice->channelsFromFmt()};
- auto ports_end = std::begin(mPort) + numchans;
+ auto ports_end = std::begin(mPort) + mDevice->channelsFromFmt();
auto bad_port = std::find_if_not(std::begin(mPort), ports_end,
[this](jack_port_t *&port) -> bool
{
@@ -410,7 +409,6 @@ ALCboolean JackPlayback::reset()
}
mDevice->FmtChans = DevFmtStereo;
}
- numchans = std::distance(std::begin(mPort), bad_port);
}
mRing = nullptr;
diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp
index 8cfe9e96..48794a50 100644
--- a/alc/backends/oss.cpp
+++ b/alc/backends/oss.cpp
@@ -230,10 +230,10 @@ done:
#endif
-int log2i(ALCuint x)
+ALCuint log2i(ALCuint x)
{
- int y = 0;
- while (x > 1)
+ ALCuint y{0};
+ while(x > 1)
{
x >>= 1;
y++;
@@ -276,7 +276,7 @@ int OSSPlayback::mixerProc()
SetRTPriority();
althrd_setname(MIXER_THREAD_NAME);
- const int frame_size{mDevice->frameSizeFromFmt()};
+ const ALuint frame_size{mDevice->frameSizeFromFmt()};
lock();
while(!mKillNow.load(std::memory_order_acquire) &&
@@ -319,7 +319,7 @@ int OSSPlayback::mixerProc()
break;
}
- to_write -= wrote;
+ to_write -= static_cast<size_t>(wrote);
write_ptr += wrote;
}
}
@@ -361,16 +361,7 @@ ALCenum OSSPlayback::open(const ALCchar *name)
ALCboolean OSSPlayback::reset()
{
- int numFragmentsLogSize;
- int log2FragmentSize;
- unsigned int periods;
- audio_buf_info info;
- ALuint frameSize;
- int numChannels;
- int ossFormat;
- int ossSpeed;
- const char *err;
-
+ int ossFormat{};
switch(mDevice->FmtType)
{
case DevFmtByte:
@@ -390,14 +381,16 @@ ALCboolean OSSPlayback::reset()
break;
}
- periods = mDevice->BufferSize / mDevice->UpdateSize;
- numChannels = mDevice->channelsFromFmt();
- ossSpeed = mDevice->Frequency;
- frameSize = numChannels * mDevice->bytesFromFmt();
+ ALuint periods{mDevice->BufferSize / mDevice->UpdateSize};
+ ALuint numChannels{mDevice->channelsFromFmt()};
+ ALuint ossSpeed{mDevice->Frequency};
+ ALuint frameSize{numChannels * mDevice->bytesFromFmt()};
/* According to the OSS spec, 16 bytes (log2(16)) is the minimum. */
- log2FragmentSize = maxi(log2i(mDevice->UpdateSize*frameSize), 4);
- numFragmentsLogSize = (periods << 16) | log2FragmentSize;
+ ALuint log2FragmentSize{maxu(log2i(mDevice->UpdateSize*frameSize), 4)};
+ ALuint numFragmentsLogSize{(periods << 16) | log2FragmentSize};
+ audio_buf_info info{};
+ const char *err;
#define CHECKERR(func) if((func) < 0) { \
err = #func; \
goto err; \
@@ -434,8 +427,8 @@ ALCboolean OSSPlayback::reset()
}
mDevice->Frequency = ossSpeed;
- mDevice->UpdateSize = info.fragsize / frameSize;
- mDevice->BufferSize = info.fragments * mDevice->UpdateSize;
+ mDevice->UpdateSize = static_cast<ALuint>(info.fragsize) / frameSize;
+ mDevice->BufferSize = static_cast<ALuint>(info.fragments) * mDevice->UpdateSize;
SetDefaultChannelOrder(mDevice);
@@ -505,7 +498,7 @@ int OSScapture::recordProc()
SetRTPriority();
althrd_setname(RECORD_THREAD_NAME);
- const int frame_size{mDevice->frameSizeFromFmt()};
+ const ALuint frame_size{mDevice->frameSizeFromFmt()};
while(!mKillNow.load(std::memory_order_acquire))
{
pollfd pollitem{};
@@ -592,17 +585,15 @@ ALCenum OSScapture::open(const ALCchar *name)
return ALC_INVALID_VALUE;
}
- int periods{4};
- int numChannels{mDevice->channelsFromFmt()};
- int frameSize{numChannels * mDevice->bytesFromFmt()};
- int ossSpeed{static_cast<int>(mDevice->Frequency)};
- int log2FragmentSize{log2i(mDevice->BufferSize * frameSize / periods)};
-
+ ALuint periods{4};
+ ALuint numChannels{mDevice->channelsFromFmt()};
+ ALuint frameSize{numChannels * mDevice->bytesFromFmt()};
+ ALuint ossSpeed{mDevice->Frequency};
/* according to the OSS spec, 16 bytes are the minimum */
- log2FragmentSize = std::max(log2FragmentSize, 4);
- int numFragmentsLogSize{(periods << 16) | log2FragmentSize};
+ ALuint log2FragmentSize{maxu(log2i(mDevice->BufferSize * frameSize / periods), 4)};
+ ALuint numFragmentsLogSize{(periods << 16) | log2FragmentSize};
- audio_buf_info info;
+ audio_buf_info info{};
const char *err;
#define CHECKERR(func) if((func) < 0) { \
err = #func; \
@@ -687,7 +678,7 @@ ALCenum OSScapture::captureSamples(ALCvoid *buffer, ALCuint samples)
}
ALCuint OSScapture::availableSamples()
-{ return mRing->readSpace(); }
+{ return static_cast<ALCuint>(mRing->readSpace()); }
} // namespace
diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp
index fcfd4b01..4704a806 100644
--- a/alc/backends/portaudio.cpp
+++ b/alc/backends/portaudio.cpp
@@ -114,7 +114,7 @@ int PortPlayback::writeCallback(const void*, void *outputBuffer,
const PaStreamCallbackFlags)
{
lock();
- aluMixData(mDevice, outputBuffer, framesPerBuffer);
+ aluMixData(mDevice, outputBuffer, static_cast<ALuint>(framesPerBuffer));
unlock();
return 0;
}
@@ -182,7 +182,7 @@ retry_open:
ALCboolean PortPlayback::reset()
{
const PaStreamInfo *streamInfo{Pa_GetStreamInfo(mStream)};
- mDevice->Frequency = streamInfo->sampleRate;
+ mDevice->Frequency = static_cast<ALuint>(streamInfo->sampleRate);
mDevice->UpdateSize = mUpdateSize;
if(mParams.sampleFormat == paInt8)
@@ -293,7 +293,7 @@ ALCenum PortCapture::open(const ALCchar *name)
ALuint samples{mDevice->BufferSize};
samples = maxu(samples, 100 * mDevice->Frequency / 1000);
- ALsizei frame_size{mDevice->frameSizeFromFmt()};
+ ALuint frame_size{mDevice->frameSizeFromFmt()};
mRing = CreateRingBuffer(samples, frame_size, false);
if(!mRing) return ALC_INVALID_VALUE;
@@ -326,7 +326,7 @@ ALCenum PortCapture::open(const ALCchar *name)
ERR("%s samples not supported\n", DevFmtTypeString(mDevice->FmtType));
return ALC_INVALID_VALUE;
}
- mParams.channelCount = mDevice->channelsFromFmt();
+ mParams.channelCount = static_cast<int>(mDevice->channelsFromFmt());
PaError err{Pa_OpenStream(&mStream, &mParams, nullptr, mDevice->Frequency,
paFramesPerBufferUnspecified, paNoFlag, &PortCapture::readCallbackC, this)};
@@ -361,7 +361,7 @@ void PortCapture::stop()
ALCuint PortCapture::availableSamples()
-{ return mRing->readSpace(); }
+{ return static_cast<ALCuint>(mRing->readSpace()); }
ALCenum PortCapture::captureSamples(ALCvoid *buffer, ALCuint samples)
{
diff --git a/alc/backends/sdl2.cpp b/alc/backends/sdl2.cpp
index 28d020a1..6af0ac9d 100644
--- a/alc/backends/sdl2.cpp
+++ b/alc/backends/sdl2.cpp
@@ -153,7 +153,7 @@ ALCenum Sdl2Backend::open(const ALCchar *name)
mDevice->UpdateSize = have.samples;
mDevice->BufferSize = have.samples * 2; /* SDL always (tries to) use two periods. */
- mFrameSize = static_cast<ALuint>(mDevice->frameSizeFromFmt());
+ mFrameSize = mDevice->frameSizeFromFmt();
mFrequency = mDevice->Frequency;
mFmtChans = mDevice->FmtChans;
mFmtType = mDevice->FmtType;
diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp
index c7a86670..4a470e82 100644
--- a/alc/backends/sndio.cpp
+++ b/alc/backends/sndio.cpp
@@ -76,16 +76,16 @@ int SndioPlayback::mixerProc()
SetRTPriority();
althrd_setname(MIXER_THREAD_NAME);
- const ALsizei frameSize{mDevice->frameSizeFromFmt()};
+ const ALuint frameSize{mDevice->frameSizeFromFmt()};
while(!mKillNow.load(std::memory_order_acquire) &&
mDevice->Connected.load(std::memory_order_acquire))
{
- auto WritePtr = static_cast<ALubyte*>(mBuffer.data());
+ ALubyte *WritePtr{mBuffer.data()};
size_t len{mBuffer.size()};
lock();
- aluMixData(mDevice, WritePtr, len/frameSize);
+ aluMixData(mDevice, WritePtr, static_cast<ALuint>(len/frameSize));
unlock();
while(len > 0 && !mKillNow.load(std::memory_order_acquire))
{
@@ -277,7 +277,7 @@ int SndioCapture::recordProc()
SetRTPriority();
althrd_setname(RECORD_THREAD_NAME);
- const ALsizei frameSize{mDevice->frameSizeFromFmt()};
+ const ALuint frameSize{mDevice->frameSizeFromFmt()};
while(!mKillNow.load(std::memory_order_acquire) &&
mDevice->Connected.load(std::memory_order_acquire))
@@ -396,8 +396,7 @@ ALCenum SndioCapture::open(const ALCchar *name)
(mDevice->FmtType == DevFmtUShort && par.bits == 16 && par.sig == 0) ||
(mDevice->FmtType == DevFmtInt && par.bits == 32 && par.sig != 0) ||
(mDevice->FmtType == DevFmtUInt && par.bits == 32 && par.sig == 0)) ||
- mDevice->channelsFromFmt() != static_cast<int>(par.rchan) ||
- mDevice->Frequency != par.rate)
+ mDevice->channelsFromFmt() != par.rchan || mDevice->Frequency != par.rate)
{
ERR("Failed to set format %s %s %uhz, got %c%u %u-channel %uhz instead\n",
DevFmtTypeString(mDevice->FmtType), DevFmtChannelsString(mDevice->FmtChans),
@@ -457,7 +456,7 @@ ALCenum SndioCapture::captureSamples(void *buffer, ALCuint samples)
}
ALCuint SndioCapture::availableSamples()
-{ return mRing->readSpace(); }
+{ return static_cast<ALCuint>(mRing->readSpace()); }
} // namespace
diff --git a/alc/backends/solaris.cpp b/alc/backends/solaris.cpp
index 584f6e66..2e8fe458 100644
--- a/alc/backends/solaris.cpp
+++ b/alc/backends/solaris.cpp
@@ -88,7 +88,7 @@ int SolarisBackend::mixerProc()
SetRTPriority();
althrd_setname(MIXER_THREAD_NAME);
- const int frame_size{mDevice->frameSizeFromFmt()};
+ const ALuint frame_size{mDevice->frameSizeFromFmt()};
lock();
while(!mKillNow.load(std::memory_order_acquire) &&
@@ -169,7 +169,7 @@ ALCboolean SolarisBackend::reset()
if(mDevice->FmtChans != DevFmtMono)
mDevice->FmtChans = DevFmtStereo;
- ALsizei numChannels{mDevice->channelsFromFmt()};
+ ALuint numChannels{mDevice->channelsFromFmt()};
info.play.channels = numChannels;
switch(mDevice->FmtType)
@@ -194,7 +194,7 @@ ALCboolean SolarisBackend::reset()
break;
}
- ALsizei frameSize{numChannels * mDevice->bytesFromFmt()};
+ ALuint frameSize{numChannels * mDevice->bytesFromFmt()};
info.play.buffer_size = mDevice->BufferSize * frameSize;
if(ioctl(mFd, AUDIO_SETINFO, &info) < 0)
@@ -203,7 +203,7 @@ ALCboolean SolarisBackend::reset()
return ALC_FALSE;
}
- if(mDevice->channelsFromFmt() != (ALsizei)info.play.channels)
+ if(mDevice->channelsFromFmt() != info.play.channels)
{
ERR("Failed to set %s, got %u channels instead\n", DevFmtChannelsString(mDevice->FmtChans),
info.play.channels);
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp
index 806db122..55c95146 100644
--- a/alc/backends/wasapi.cpp
+++ b/alc/backends/wasapi.cpp
@@ -1565,9 +1565,8 @@ HRESULT WasapiCapture::resetProxy()
if(mDevice->Frequency != OutputType.Format.nSamplesPerSec || mDevice->FmtType != srcType)
{
- mSampleConv = CreateSampleConverter(srcType, mDevice->FmtType,
- static_cast<ALuint>(mDevice->channelsFromFmt()), OutputType.Format.nSamplesPerSec,
- mDevice->Frequency, BSinc24Resampler);
+ mSampleConv = CreateSampleConverter(srcType, mDevice->FmtType, mDevice->channelsFromFmt(),
+ OutputType.Format.nSamplesPerSec, mDevice->Frequency, BSinc24Resampler);
if(!mSampleConv)
{
ERR("Failed to create converter for %s format, dst: %s %uhz, src: %s %luhz\n",
diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp
index 20f0d3f2..f1171747 100644
--- a/alc/backends/wave.cpp
+++ b/alc/backends/wave.cpp
@@ -125,7 +125,7 @@ int WaveBackend::mixerProc()
althrd_setname(MIXER_THREAD_NAME);
- const auto frameSize = static_cast<ALuint>(mDevice->frameSizeFromFmt());
+ const ALuint frameSize{mDevice->frameSizeFromFmt()};
int64_t done{0};
auto start = std::chrono::steady_clock::now();
@@ -151,7 +151,7 @@ int WaveBackend::mixerProc()
if(!IS_LITTLE_ENDIAN)
{
- const ALsizei bytesize{mDevice->bytesFromFmt()};
+ const ALuint bytesize{mDevice->bytesFromFmt()};
if(bytesize == 2)
{
@@ -281,8 +281,8 @@ ALCboolean WaveBackend::reset()
chanmask = 0;
break;
}
- bytes = static_cast<ALuint>(mDevice->bytesFromFmt());
- channels = static_cast<ALuint>(mDevice->channelsFromFmt());
+ bytes = mDevice->bytesFromFmt();
+ channels = mDevice->channelsFromFmt();
rewind(mFile);
@@ -330,7 +330,7 @@ ALCboolean WaveBackend::reset()
SetDefaultWFXChannelOrder(mDevice);
- const ALuint bufsize{static_cast<ALuint>(mDevice->frameSizeFromFmt())*mDevice->UpdateSize};
+ const ALuint bufsize{mDevice->frameSizeFromFmt() * mDevice->UpdateSize};
mBuffer.resize(bufsize);
return ALC_TRUE;
diff --git a/alc/converter.cpp b/alc/converter.cpp
index 87a9d275..2913f533 100644
--- a/alc/converter.cpp
+++ b/alc/converter.cpp
@@ -152,8 +152,8 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType,
SampleConverterPtr converter{new (FamCount{numchans}) SampleConverter{numchans}};
converter->mSrcType = srcType;
converter->mDstType = dstType;
- converter->mSrcTypeSize = static_cast<ALuint>(BytesFromDevFmt(srcType));
- converter->mDstTypeSize = static_cast<ALuint>(BytesFromDevFmt(dstType));
+ converter->mSrcTypeSize = BytesFromDevFmt(srcType);
+ converter->mDstTypeSize = BytesFromDevFmt(dstType);
converter->mSrcPrepCount = 0;
converter->mFracOffset = 0;
@@ -360,6 +360,5 @@ void ChannelConverter::convert(const ALvoid *src, ALfloat *dst, ALuint frames) c
}
}
else
- LoadSamples(dst, src, 1u, mSrcType,
- frames*static_cast<ALuint>(ChannelsFromDevFmt(mSrcChans, 0)));
+ LoadSamples(dst, src, 1u, mSrcType, frames * ChannelsFromDevFmt(mSrcChans, 0));
}
diff --git a/alc/devformat.h b/alc/devformat.h
index 95fe5fbd..674dd848 100644
--- a/alc/devformat.h
+++ b/alc/devformat.h
@@ -97,9 +97,9 @@ template<>
struct DevFmtTypeTraits<DevFmtFloat> { using Type = ALfloat; };
-ALsizei BytesFromDevFmt(DevFmtType type) noexcept;
-ALsizei ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept;
-inline ALsizei FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, ALsizei ambiorder) noexcept
+ALuint BytesFromDevFmt(DevFmtType type) noexcept;
+ALuint ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept;
+inline ALuint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, ALsizei ambiorder) noexcept
{ return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); }
enum class AmbiLayout {