aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-09-13 12:51:16 -0700
committerChris Robinson <[email protected]>2019-09-13 12:51:16 -0700
commitfcd3bed0c0923ca2eff463e0e6cffc60e00f4a7d (patch)
tree25ddbf3ce4bd3a4097c890aa21c137d683f893f5
parentf09734b707c3036345d602cc187cc21248a54abd (diff)
Clean up more implicit conversions
-rw-r--r--alc/backends/base.cpp3
-rw-r--r--alc/backends/sdl2.cpp16
-rw-r--r--alc/backends/wave.cpp30
-rw-r--r--alc/helpers.cpp6
4 files changed, 29 insertions, 26 deletions
diff --git a/alc/backends/base.cpp b/alc/backends/base.cpp
index 095990b7..c4c6052b 100644
--- a/alc/backends/base.cpp
+++ b/alc/backends/base.cpp
@@ -53,7 +53,8 @@ ClockLatency BackendBase::getClockLatency()
* any given time during playback. Without a more accurate measurement from
* the output, this is an okay approximation.
*/
- ret.Latency = std::chrono::seconds{maxi(mDevice->BufferSize-mDevice->UpdateSize, 0)};
+ ret.Latency = std::max(std::chrono::seconds{mDevice->BufferSize-mDevice->UpdateSize},
+ std::chrono::seconds::zero());
ret.Latency /= mDevice->Frequency;
return ret;
diff --git a/alc/backends/sdl2.cpp b/alc/backends/sdl2.cpp
index 4b3b5e63..28d020a1 100644
--- a/alc/backends/sdl2.cpp
+++ b/alc/backends/sdl2.cpp
@@ -62,7 +62,7 @@ struct Sdl2Backend final : public BackendBase {
void unlock() override;
SDL_AudioDeviceID mDeviceID{0u};
- ALsizei mFrameSize{0};
+ ALuint mFrameSize{0};
ALuint mFrequency{0u};
DevFmtChannels mFmtChans{};
@@ -84,14 +84,16 @@ void Sdl2Backend::audioCallbackC(void *ptr, Uint8 *stream, int len)
void Sdl2Backend::audioCallback(Uint8 *stream, int len)
{
- assert((len % mFrameSize) == 0);
- aluMixData(mDevice, stream, len / mFrameSize);
+ const auto ulen = static_cast<unsigned int>(len);
+ assert((ulen % mFrameSize) == 0);
+ aluMixData(mDevice, stream, ulen / mFrameSize);
}
ALCenum Sdl2Backend::open(const ALCchar *name)
{
SDL_AudioSpec want{}, have{};
- want.freq = mDevice->Frequency;
+
+ want.freq = static_cast<int>(mDevice->Frequency);
switch(mDevice->FmtType)
{
case DevFmtUByte: want.format = AUDIO_U8; break;
@@ -103,7 +105,7 @@ ALCenum Sdl2Backend::open(const ALCchar *name)
case DevFmtFloat: want.format = AUDIO_F32; break;
}
want.channels = (mDevice->FmtChans == DevFmtMono) ? 1 : 2;
- want.samples = mDevice->UpdateSize;
+ want.samples = static_cast<Uint16>(mDevice->UpdateSize);
want.callback = &Sdl2Backend::audioCallbackC;
want.userdata = this;
@@ -126,7 +128,7 @@ ALCenum Sdl2Backend::open(const ALCchar *name)
if(mDeviceID == 0)
return ALC_INVALID_VALUE;
- mDevice->Frequency = have.freq;
+ mDevice->Frequency = static_cast<ALuint>(have.freq);
if(have.channels == 1)
mDevice->FmtChans = DevFmtMono;
else if(have.channels == 2)
@@ -151,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 = mDevice->frameSizeFromFmt();
+ mFrameSize = static_cast<ALuint>(mDevice->frameSizeFromFmt());
mFrequency = mDevice->Frequency;
mFmtChans = mDevice->FmtChans;
mFmtType = mDevice->FmtType;
diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp
index b16f711b..20f0d3f2 100644
--- a/alc/backends/wave.cpp
+++ b/alc/backends/wave.cpp
@@ -125,7 +125,7 @@ int WaveBackend::mixerProc()
althrd_setname(MIXER_THREAD_NAME);
- const ALsizei frameSize{mDevice->frameSizeFromFmt()};
+ const auto frameSize = static_cast<ALuint>(mDevice->frameSizeFromFmt());
int64_t done{0};
auto start = std::chrono::steady_clock::now();
@@ -159,8 +159,8 @@ int WaveBackend::mixerProc()
const size_t len{mBuffer.size() / 2};
for(size_t i{0};i < len;i++)
{
- ALushort samp = samples[i];
- samples[i] = (samp>>8) | (samp<<8);
+ const ALushort samp{samples[i]};
+ samples[i] = static_cast<ALushort>((samp>>8) | (samp<<8));
}
}
else if(bytesize == 4)
@@ -169,7 +169,7 @@ int WaveBackend::mixerProc()
const size_t len{mBuffer.size() / 4};
for(size_t i{0};i < len;i++)
{
- ALuint samp = samples[i];
+ const ALuint samp{samples[i]};
samples[i] = (samp>>24) | ((samp>>8)&0x0000ff00) |
((samp<<8)&0x00ff0000) | (samp<<24);
}
@@ -281,8 +281,8 @@ ALCboolean WaveBackend::reset()
chanmask = 0;
break;
}
- bytes = mDevice->bytesFromFmt();
- channels = mDevice->channelsFromFmt();
+ bytes = static_cast<ALuint>(mDevice->bytesFromFmt());
+ channels = static_cast<ALuint>(mDevice->channelsFromFmt());
rewind(mFile);
@@ -297,25 +297,25 @@ ALCboolean WaveBackend::reset()
// 16-bit val, format type id (extensible: 0xFFFE)
fwrite16le(0xFFFE, mFile);
// 16-bit val, channel count
- fwrite16le(channels, mFile);
+ fwrite16le(static_cast<ALushort>(channels), mFile);
// 32-bit val, frequency
fwrite32le(mDevice->Frequency, mFile);
// 32-bit val, bytes per second
fwrite32le(mDevice->Frequency * channels * bytes, mFile);
// 16-bit val, frame size
- fwrite16le(channels * bytes, mFile);
+ fwrite16le(static_cast<ALushort>(channels * bytes), mFile);
// 16-bit val, bits per sample
- fwrite16le(bytes * 8, mFile);
+ fwrite16le(static_cast<ALushort>(bytes * 8), mFile);
// 16-bit val, extra byte count
fwrite16le(22, mFile);
// 16-bit val, valid bits per sample
- fwrite16le(bytes * 8, mFile);
+ fwrite16le(static_cast<ALushort>(bytes * 8), mFile);
// 32-bit val, channel mask
fwrite32le(chanmask, mFile);
// 16 byte GUID, sub-type format
val = fwrite((mDevice->FmtType == DevFmtFloat) ?
- (isbformat ? SUBTYPE_BFORMAT_FLOAT : SUBTYPE_FLOAT) :
- (isbformat ? SUBTYPE_BFORMAT_PCM : SUBTYPE_PCM), 1, 16, mFile);
+ (isbformat ? SUBTYPE_BFORMAT_FLOAT : SUBTYPE_FLOAT) :
+ (isbformat ? SUBTYPE_BFORMAT_PCM : SUBTYPE_PCM), 1, 16, mFile);
(void)val;
fputs("data", mFile);
@@ -330,7 +330,7 @@ ALCboolean WaveBackend::reset()
SetDefaultWFXChannelOrder(mDevice);
- const ALuint bufsize{mDevice->frameSizeFromFmt() * mDevice->UpdateSize};
+ const ALuint bufsize{static_cast<ALuint>(mDevice->frameSizeFromFmt())*mDevice->UpdateSize};
mBuffer.resize(bufsize);
return ALC_TRUE;
@@ -362,9 +362,9 @@ void WaveBackend::stop()
{
long dataLen{size - mDataStart};
if(fseek(mFile, mDataStart-4, SEEK_SET) == 0)
- fwrite32le(dataLen, mFile); // 'data' header len
+ fwrite32le(static_cast<ALuint>(dataLen), mFile); // 'data' header len
if(fseek(mFile, 4, SEEK_SET) == 0)
- fwrite32le(size-8, mFile); // 'WAVE' header len
+ fwrite32le(static_cast<ALuint>(size-8), mFile); // 'WAVE' header len
}
}
diff --git a/alc/helpers.cpp b/alc/helpers.cpp
index 46be5a3b..77f96fb8 100644
--- a/alc/helpers.cpp
+++ b/alc/helpers.cpp
@@ -81,13 +81,13 @@
#if defined(HAVE_GCC_GET_CPUID) && (defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64))
using reg_type = unsigned int;
-static inline void get_cpuid(int f, reg_type *regs)
+static inline void get_cpuid(unsigned int f, reg_type *regs)
{ __get_cpuid(f, &regs[0], &regs[1], &regs[2], &regs[3]); }
#define CAN_GET_CPUID
#elif defined(HAVE_CPUID_INTRINSIC) && (defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64))
using reg_type = int;
-static inline void get_cpuid(int f, reg_type *regs)
+static inline void get_cpuid(unsigned int f, reg_type *regs)
{ (__cpuid)(regs, f); }
#define CAN_GET_CPUID
#endif
@@ -104,7 +104,7 @@ void FillCPUCaps(int capfilter)
union {
reg_type regs[4];
char str[sizeof(reg_type[4])];
- } cpuinf[3] = {{ { 0, 0, 0, 0 } }};
+ } cpuinf[3]{};
get_cpuid(0, cpuinf[0].regs);
if(cpuinf[0].regs[0] == 0)