From be0442c6207cc10fca079a803bbdd8985959b657 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 11 Sep 2019 06:47:56 -0700 Subject: Avoid C-style casts in C++ --- alc/backends/sdl2.cpp | 2 +- alc/backends/sndio.cpp | 2 +- alc/backends/wasapi.cpp | 9 ++++++--- alc/backends/winmm.cpp | 8 +++++--- 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'alc/backends') diff --git a/alc/backends/sdl2.cpp b/alc/backends/sdl2.cpp index 29d27c05..4b3b5e63 100644 --- a/alc/backends/sdl2.cpp +++ b/alc/backends/sdl2.cpp @@ -133,7 +133,7 @@ ALCenum Sdl2Backend::open(const ALCchar *name) mDevice->FmtChans = DevFmtStereo; else { - ERR("Got unhandled SDL channel count: %d\n", (int)have.channels); + ERR("Got unhandled SDL channel count: %d\n", int{have.channels}); return ALC_INVALID_VALUE; } switch(have.format) diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp index 587f67bb..c7a86670 100644 --- a/alc/backends/sndio.cpp +++ b/alc/backends/sndio.cpp @@ -396,7 +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() != (ALsizei)par.rchan || + mDevice->channelsFromFmt() != static_cast(par.rchan) || mDevice->Frequency != par.rate) { ERR("Failed to set format %s %s %uhz, got %c%u %u-channel %uhz instead\n", diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index ec1ee936..55c95146 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -81,6 +81,9 @@ DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_GUID, 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x namespace { +inline constexpr REFERENCE_TIME operator "" _reftime(unsigned long long int n) noexcept +{ return static_cast(n); } + #define MONO SPEAKER_FRONT_CENTER #define STEREO (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT) #define QUAD (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT) @@ -90,7 +93,7 @@ namespace { #define X7DOT1 (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT) #define X7DOT1_WIDE (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_FRONT_LEFT_OF_CENTER|SPEAKER_FRONT_RIGHT_OF_CENTER) -#define REFTIME_PER_SEC ((REFERENCE_TIME)10000000) +#define REFTIME_PER_SEC 10000000_reftime #define DEVNAME_HEAD "OpenAL Soft on " @@ -1051,7 +1054,7 @@ HRESULT WasapiPlayback::resetProxy() /* Find the nearest multiple of the period size to the update size */ if(min_per < per_time) min_per *= maxi64((per_time + min_per/2) / min_per, 1); - min_len = (UINT32)ScaleCeil(min_per, mDevice->Frequency, REFTIME_PER_SEC); + min_len = static_cast(ScaleCeil(min_per, mDevice->Frequency, REFTIME_PER_SEC)); min_len = minu(min_len, buffer_len/2); mDevice->UpdateSize = min_len; @@ -1680,7 +1683,7 @@ void WasapiCapture::stopProxy() ALCuint WasapiCapture::availableSamples() -{ return (ALCuint)mRing->readSpace(); } +{ return static_cast(mRing->readSpace()); } ALCenum WasapiCapture::captureSamples(void *buffer, ALCuint samples) { diff --git a/alc/backends/winmm.cpp b/alc/backends/winmm.cpp index b6787a24..76e6fe3b 100644 --- a/alc/backends/winmm.cpp +++ b/alc/backends/winmm.cpp @@ -245,7 +245,8 @@ retry_open: mFormat.nAvgBytesPerSec = mFormat.nSamplesPerSec * mFormat.nBlockAlign; mFormat.cbSize = 0; - MMRESULT res{waveOutOpen(&mOutHdl, DeviceID, &mFormat, (DWORD_PTR)&WinMMPlayback::waveOutProcC, + MMRESULT res{waveOutOpen(&mOutHdl, DeviceID, &mFormat, + reinterpret_cast(&WinMMPlayback::waveOutProcC), reinterpret_cast(this), CALLBACK_FUNCTION)}; if(res != MMSYSERR_NOERROR) { @@ -506,7 +507,8 @@ ALCenum WinMMCapture::open(const ALCchar *name) mFormat.nAvgBytesPerSec = mFormat.nSamplesPerSec * mFormat.nBlockAlign; mFormat.cbSize = 0; - MMRESULT res{waveInOpen(&mInHdl, DeviceID, &mFormat, (DWORD_PTR)&WinMMCapture::waveInProcC, + MMRESULT res{waveInOpen(&mInHdl, DeviceID, &mFormat, + reinterpret_cast(&WinMMCapture::waveInProcC), reinterpret_cast(this), CALLBACK_FUNCTION)}; if(res != MMSYSERR_NOERROR) { @@ -590,7 +592,7 @@ ALCenum WinMMCapture::captureSamples(void *buffer, ALCuint samples) } ALCuint WinMMCapture::availableSamples() -{ return (ALCuint)mRing->readSpace(); } +{ return static_cast(mRing->readSpace()); } } // namespace -- cgit v1.2.3