diff options
author | Chris Robinson <[email protected]> | 2019-09-11 06:47:56 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-09-11 06:47:56 -0700 |
commit | be0442c6207cc10fca079a803bbdd8985959b657 (patch) | |
tree | f454f679117428575d639e5b386104495889fe85 /alc | |
parent | 388928f3aa1ecf1a4f930c27687e7d0d4a9fd824 (diff) |
Avoid C-style casts in C++
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alc.cpp | 18 | ||||
-rw-r--r-- | alc/backends/sdl2.cpp | 2 | ||||
-rw-r--r-- | alc/backends/sndio.cpp | 2 | ||||
-rw-r--r-- | alc/backends/wasapi.cpp | 9 | ||||
-rw-r--r-- | alc/backends/winmm.cpp | 8 | ||||
-rw-r--r-- | alc/helpers.cpp | 2 |
6 files changed, 22 insertions, 19 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 5f52ca26..10ab3b94 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -28,6 +28,7 @@ #include <atomic> #include <cctype> #include <chrono> +#include <cinttypes> #include <climits> #include <cmath> #include <csignal> @@ -214,7 +215,7 @@ BackendFactory *CaptureFactory{}; /************************************************ * Functions, enums, and errors ************************************************/ -#define DECL(x) { #x, (ALCvoid*)(x) } +#define DECL(x) { #x, reinterpret_cast<void*>(x) } const struct { const ALCchar *funcName; ALCvoid *address; @@ -1228,14 +1229,11 @@ BOOL APIENTRY DllMain(HINSTANCE module, DWORD reason, LPVOID /*reserved*/) { switch(reason) { - case DLL_PROCESS_ATTACH: - /* Pin the DLL so we won't get unloaded until the process terminates */ - GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - (WCHAR*)module, &module); - break; - - case DLL_PROCESS_DETACH: - break; + case DLL_PROCESS_ATTACH: + /* Pin the DLL so we won't get unloaded until the process terminates */ + GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, + reinterpret_cast<WCHAR*>(module), &module); + break; } return TRUE; } @@ -2087,7 +2085,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) TRACE("Output limiter enabled, %.4fdB limit\n", thrshld_dB); } - TRACE("Fixed device latency: %ldns\n", (long)device->FixedLatency.count()); + TRACE("Fixed device latency: %" PRId64 "ns\n", int64_t{device->FixedLatency.count()}); /* Need to delay returning failure until replacement Send arrays have been * allocated with the appropriate size. 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<int>(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<REFERENCE_TIME>(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<UINT32>(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<ALCuint>(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<DWORD_PTR>(&WinMMPlayback::waveOutProcC), reinterpret_cast<DWORD_PTR>(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<DWORD_PTR>(&WinMMCapture::waveInProcC), reinterpret_cast<DWORD_PTR>(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<ALCuint>(mRing->readSpace()); } } // namespace diff --git a/alc/helpers.cpp b/alc/helpers.cpp index ba95c0f8..84787637 100644 --- a/alc/helpers.cpp +++ b/alc/helpers.cpp @@ -255,7 +255,7 @@ auto filebuf::underflow() -> int_type { // Read in the next chunk of data, and set the pointers on success DWORD got{}; - if(ReadFile(mFile, mBuffer.data(), (DWORD)mBuffer.size(), &got, nullptr)) + if(ReadFile(mFile, mBuffer.data(), static_cast<DWORD>(mBuffer.size()), &got, nullptr)) setg(mBuffer.data(), mBuffer.data(), mBuffer.data()+got); } if(gptr() == egptr()) |