diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alc.cpp | 22 | ||||
-rw-r--r-- | Alc/alconfig.cpp | 4 | ||||
-rw-r--r-- | Alc/alu.cpp | 18 | ||||
-rw-r--r-- | Alc/backends/alsa.cpp | 16 | ||||
-rw-r--r-- | Alc/backends/portaudio.cpp | 2 | ||||
-rw-r--r-- | Alc/backends/pulseaudio.cpp | 6 | ||||
-rw-r--r-- | Alc/bformatdec.cpp | 2 | ||||
-rw-r--r-- | Alc/converter.cpp | 8 | ||||
-rw-r--r-- | Alc/effects/chorus.cpp | 6 | ||||
-rw-r--r-- | Alc/effects/compressor.cpp | 4 | ||||
-rw-r--r-- | Alc/effects/equalizer.cpp | 2 | ||||
-rw-r--r-- | Alc/effects/fshifter.cpp | 4 | ||||
-rw-r--r-- | Alc/effects/modulator.cpp | 16 | ||||
-rw-r--r-- | Alc/effects/pshifter.cpp | 12 | ||||
-rw-r--r-- | Alc/effects/reverb.cpp | 6 | ||||
-rw-r--r-- | Alc/helpers.cpp | 2 | ||||
-rw-r--r-- | Alc/hrtf.cpp | 10 | ||||
-rw-r--r-- | Alc/mastering.cpp | 6 | ||||
-rw-r--r-- | Alc/mixer/mixer_c.cpp | 4 | ||||
-rw-r--r-- | Alc/mixer/mixer_sse.cpp | 18 | ||||
-rw-r--r-- | Alc/mixvoice.cpp | 12 | ||||
-rw-r--r-- | Alc/panning.cpp | 8 |
22 files changed, 94 insertions, 94 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index e44b42c8..9b56ea8d 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -985,7 +985,7 @@ static void alc_initconfig(void) if(!str[0] || str[0] == ',') continue; - size_t len{next ? (size_t)(next-str) : strlen(str)}; + size_t len{next ? static_cast<size_t>(next-str) : strlen(str)}; while(len > 0 && isspace(str[len-1])) len--; if(len == 3 && strncasecmp(str, "sse", len) == 0) @@ -1062,7 +1062,7 @@ static void alc_initconfig(void) } endlist = 1; - len = (next ? ((size_t)(next-devs)) : strlen(devs)); + len = (next ? (static_cast<size_t>(next-devs)) : strlen(devs)); while(len > 0 && isspace(devs[len-1])) len--; #ifdef HAVE_WASAPI @@ -1147,7 +1147,7 @@ static void alc_initconfig(void) if(!str[0] || next == str) continue; - size_t len{next ? (size_t)(next-str) : strlen(str)}; + size_t len{next ? static_cast<size_t>(next-str) : strlen(str)}; for(size_t n{0u};n < countof(gEffectList);n++) { if(len == strlen(gEffectList[n].name) && @@ -1858,7 +1858,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->HrtfList = EnumerateHrtf(device->DeviceName.c_str()); if(!device->HrtfList.empty()) { - if(hrtf_id >= 0 && (size_t)hrtf_id < device->HrtfList.size()) + if(hrtf_id >= 0 && static_cast<size_t>(hrtf_id) < device->HrtfList.size()) hrtf = GetLoadedHrtf(device->HrtfList[hrtf_id].hrtf); else hrtf = GetLoadedHrtf(device->HrtfList.front().hrtf); @@ -1989,7 +1989,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(depth > 0) { depth = clampi(depth, 2, 24); - device->DitherDepth = std::pow(2.0f, (ALfloat)(depth-1)); + device->DitherDepth = std::pow(2.0f, static_cast<ALfloat>(depth-1)); } } if(!(device->DitherDepth > 0.0f)) @@ -2608,7 +2608,7 @@ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends) const size_t size{sizeof(ALvoice*) + sizeof_voice}; auto voices = static_cast<ALvoice**>(al_calloc(16, RoundUp(size*num_voices, 16))); - auto voice = reinterpret_cast<ALvoice*>((char*)voices + RoundUp(num_voices*sizeof(ALvoice*), 16)); + auto voice = reinterpret_cast<ALvoice*>(reinterpret_cast<char*>(voices) + RoundUp(num_voices*sizeof(ALvoice*), 16)); auto viter = voices; if(context->Voices) @@ -2670,7 +2670,7 @@ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends) /* Set this voice's reference. */ ALvoice *ret = voice; /* Increment pointer to the next storage space. */ - voice = reinterpret_cast<ALvoice*>((char*)voice + sizeof_voice); + voice = reinterpret_cast<ALvoice*>(reinterpret_cast<char*>(voice) + sizeof_voice); return ret; }; viter = std::transform(context->Voices, context->Voices+v_count, viter, copy_voice); @@ -2683,7 +2683,7 @@ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends) auto init_voice = [&voice,sizeof_voice]() -> ALvoice* { ALvoice *ret = new (voice) ALvoice{}; - voice = reinterpret_cast<ALvoice*>((char*)voice + sizeof_voice); + voice = reinterpret_cast<ALvoice*>(reinterpret_cast<char*>(voice) + sizeof_voice); return ret; }; std::generate(viter, voices+num_voices, init_voice); @@ -3156,7 +3156,7 @@ static ALCsizei GetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALC { std::lock_guard<std::mutex> _{device->StateLock}; device->HrtfList.clear(); device->HrtfList = EnumerateHrtf(device->DeviceName.c_str()); - values[0] = (ALCint)device->HrtfList.size(); + values[0] = static_cast<ALCint>(device->HrtfList.size()); } return 1; @@ -4022,7 +4022,7 @@ ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCenum err{ALC_INVALID_VALUE}; { std::lock_guard<std::mutex> _{dev->StateLock}; BackendBase *backend{dev->Backend.get()}; - if(samples >= 0 && backend->availableSamples() >= (ALCuint)samples) + if(samples >= 0 && backend->availableSamples() >= static_cast<ALCuint>(samples)) err = backend->captureSamples(buffer, samples); } if(err != ALC_NO_ERROR) @@ -4210,7 +4210,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum else switch(paramName) { case ALC_HRTF_SPECIFIER_SOFT: - if(index >= 0 && (size_t)index < dev->HrtfList.size()) + if(index >= 0 && static_cast<size_t>(index) < dev->HrtfList.size()) return dev->HrtfList[index].name.c_str(); alcSetError(dev.get(), ALC_INVALID_VALUE); break; diff --git a/Alc/alconfig.cpp b/Alc/alconfig.cpp index eecaf6fc..c4fde638 100644 --- a/Alc/alconfig.cpp +++ b/Alc/alconfig.cpp @@ -93,7 +93,7 @@ std:: string expdup(const char *str) { const char *next = std::strchr(str, '$'); addstr = str; - addstrlen = next ? (size_t)(next-str) : std::strlen(str); + addstrlen = next ? static_cast<size_t>(next-str) : std::strlen(str); str += addstrlen; } @@ -104,7 +104,7 @@ std:: string expdup(const char *str) { const char *next = std::strchr(str+1, '$'); addstr = str; - addstrlen = next ? (size_t)(next-str) : std::strlen(str); + addstrlen = next ? static_cast<size_t>(next-str) : std::strlen(str); str += addstrlen; } diff --git a/Alc/alu.cpp b/Alc/alu.cpp index 77505a0c..42e31b88 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -227,7 +227,7 @@ void BsincPrepare(const ALuint increment, BsincState *state, const BSincTable *t if(increment > FRACTIONONE) { - sf = (ALfloat)FRACTIONONE / increment; + sf = static_cast<ALfloat>FRACTIONONE / increment; sf = maxf(0.0f, (BSINC_SCALE_COUNT-1) * (sf-table->scaleBase) * table->scaleRange); si = float2int(sf); /* The interpolation factor is fit to this diagonally-symmetric curve @@ -620,7 +620,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev const ALfloat mdist{maxf(Distance*Listener.Params.MetersPerUnit, Device->AvgSpeakerDist/4.0f)}; const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / - (mdist * (ALfloat)Device->Frequency)}; + (mdist * static_cast<ALfloat>(Device->Frequency))}; /* Only need to adjust the first channel of a B-Format source. */ voice->Direct.Params[0].NFCtrlFilter.adjust(w0); @@ -849,7 +849,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev const ALfloat mdist{maxf(Distance*Listener.Params.MetersPerUnit, Device->AvgSpeakerDist/4.0f)}; const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / - (mdist * (ALfloat)Device->Frequency)}; + (mdist * static_cast<ALfloat>(Device->Frequency))}; /* Adjust NFC filters. */ for(ALsizei c{0};c < num_channels;c++) @@ -908,7 +908,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev * source moves away from the listener. */ const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / - (Device->AvgSpeakerDist * (ALfloat)Device->Frequency)}; + (Device->AvgSpeakerDist * static_cast<ALfloat>(Device->Frequency))}; for(ALsizei c{0};c < num_channels;c++) voice->Direct.Params[c].NFCtrlFilter.adjust(w0); @@ -1026,7 +1026,7 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons /* Calculate the stepping value */ const auto Pitch = static_cast<ALfloat>(ALBuffer->Frequency) / static_cast<ALfloat>(Device->Frequency) * props->Pitch; - if(Pitch > (ALfloat)MAX_PITCH) + if(Pitch > static_cast<ALfloat>(MAX_PITCH)) voice->Step = MAX_PITCH<<FRACTIONBITS; else voice->Step = maxi(fastf2i(Pitch * FRACTIONONE), 1); @@ -1363,8 +1363,8 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A /* Adjust pitch based on the buffer and output frequencies, and calculate * fixed-point stepping value. */ - Pitch *= (ALfloat)ALBuffer->Frequency/(ALfloat)Device->Frequency; - if(Pitch > (ALfloat)MAX_PITCH) + Pitch *= static_cast<ALfloat>(ALBuffer->Frequency)/static_cast<ALfloat>(Device->Frequency); + if(Pitch > static_cast<ALfloat>(MAX_PITCH)) voice->Step = MAX_PITCH<<FRACTIONBITS; else voice->Step = maxi(fastf2i(Pitch * FRACTIONONE), 1); @@ -1648,7 +1648,7 @@ void ApplyDither(ALfloat (*Samples)[BUFFERSIZE], ALuint *dither_seed, const ALfl ALfloat val = sample * quant_scale; ALuint rng0 = dither_rng(&seed); ALuint rng1 = dither_rng(&seed); - val += (ALfloat)(rng0*(1.0/UINT_MAX) - rng1*(1.0/UINT_MAX)); + val += static_cast<ALfloat>(rng0*(1.0/UINT_MAX) - rng1*(1.0/UINT_MAX)); return fast_roundf(val) * invscale; } ); @@ -1828,7 +1828,7 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) int msglen{vsnprintf(evt.u.user.msg, sizeof(evt.u.user.msg), msg, args)}; va_end(args); - if(msglen < 0 || (size_t)msglen >= sizeof(evt.u.user.msg)) + if(msglen < 0 || static_cast<size_t>(msglen) >= sizeof(evt.u.user.msg)) evt.u.user.msg[sizeof(evt.u.user.msg)-1] = 0; ALCcontext *ctx{device->ContextList.load()}; diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp index 33b3ae49..5fe8ef96 100644 --- a/Alc/backends/alsa.cpp +++ b/Alc/backends/alsa.cpp @@ -480,7 +480,7 @@ int AlsaPlayback::mixerProc() continue; } - if((snd_pcm_uframes_t)avail > update_size*(num_updates+1)) + if(static_cast<snd_pcm_uframes_t>(avail) > update_size*(num_updates+1)) { WARN("available samples exceeds the buffer size\n"); snd_pcm_reset(mPcmHandle); @@ -488,7 +488,7 @@ int AlsaPlayback::mixerProc() } // make sure there's frames to process - if((snd_pcm_uframes_t)avail < update_size) + if(static_cast<snd_pcm_uframes_t>(avail) < update_size) { if(state != SND_PCM_STATE_RUNNING) { @@ -520,7 +520,7 @@ int AlsaPlayback::mixerProc() break; } - char *WritePtr{(char*)areas->addr + (offset * areas->step / 8)}; + char *WritePtr{static_cast<char*>(areas->addr) + (offset * areas->step / 8)}; aluMixData(mDevice, WritePtr, frames); snd_pcm_sframes_t commitres{snd_pcm_mmap_commit(mPcmHandle, offset, frames)}; @@ -563,14 +563,14 @@ int AlsaPlayback::mixerNoMMapProc() continue; } - if((snd_pcm_uframes_t)avail > update_size*num_updates) + if(static_cast<snd_pcm_uframes_t>(avail) > update_size*num_updates) { WARN("available samples exceeds the buffer size\n"); snd_pcm_reset(mPcmHandle); continue; } - if((snd_pcm_uframes_t)avail < update_size) + if(static_cast<snd_pcm_uframes_t>(avail) < update_size) { if(state != SND_PCM_STATE_RUNNING) { @@ -1112,7 +1112,7 @@ ALCenum AlsaCapture::captureSamples(ALCvoid *buffer, ALCuint samples) { /* First get any data stored from the last stop */ amt = snd_pcm_bytes_to_frames(mPcmHandle, mBuffer.size()); - if((snd_pcm_uframes_t)amt > samples) amt = samples; + if(static_cast<snd_pcm_uframes_t>(amt) > samples) amt = samples; amt = snd_pcm_frames_to_bytes(mPcmHandle, amt); memcpy(buffer, mBuffer.data(), amt); @@ -1142,12 +1142,12 @@ ALCenum AlsaCapture::captureSamples(ALCvoid *buffer, ALCuint samples) } /* If the amount available is less than what's asked, we lost it * during recovery. So just give silence instead. */ - if((snd_pcm_uframes_t)amt < samples) + if(static_cast<snd_pcm_uframes_t>(amt) < samples) break; continue; } - buffer = (ALbyte*)buffer + amt; + buffer = static_cast<ALbyte*>(buffer) + amt; samples -= amt; } if(samples > 0) diff --git a/Alc/backends/portaudio.cpp b/Alc/backends/portaudio.cpp index 258f981e..074508b2 100644 --- a/Alc/backends/portaudio.cpp +++ b/Alc/backends/portaudio.cpp @@ -194,7 +194,7 @@ ALCenum PortPlayback::open(const ALCchar *name) if(!ConfigValueInt(nullptr, "port", "device", &mParams.device) || mParams.device < 0) mParams.device = Pa_GetDefaultOutputDevice(); mParams.suggestedLatency = (mDevice->UpdateSize*mDevice->NumUpdates) / - (float)mDevice->Frequency; + static_cast<float>(mDevice->Frequency); mParams.hostApiSpecificStreamInfo = nullptr; mParams.channelCount = ((mDevice->FmtChans == DevFmtMono) ? 1 : 2); diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp index 34c5fbfe..b717d67a 100644 --- a/Alc/backends/pulseaudio.cpp +++ b/Alc/backends/pulseaudio.cpp @@ -1131,7 +1131,7 @@ ALCboolean PulsePlayback::reset() /* Server updated our playback rate, so modify the buffer attribs * accordingly. */ mDevice->NumUpdates = static_cast<ALuint>(clampd( - (ALdouble)mSpec.rate/mDevice->Frequency*mDevice->NumUpdates + 0.5, 2.0, 16.0)); + static_cast<ALdouble>(mSpec.rate)/mDevice->Frequency*mDevice->NumUpdates + 0.5, 2.0, 16.0)); period_size = mDevice->UpdateSize * mFrameSize; mAttr.maxlength = -1; @@ -1511,10 +1511,10 @@ ALCenum PulseCapture::captureSamples(ALCvoid *buffer, ALCuint samples) memcpy(buffer, mCapStore, rem); - buffer = (ALbyte*)buffer + rem; + buffer = static_cast<ALbyte*>(buffer) + rem; todo -= rem; - mCapStore = (ALbyte*)mCapStore + rem; + mCapStore = reinterpret_cast<const ALbyte*>(mCapStore) + rem; mCapRemain -= rem; if(mCapRemain == 0) { diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp index b5dcfd89..a80ded30 100644 --- a/Alc/bformatdec.cpp +++ b/Alc/bformatdec.cpp @@ -75,7 +75,7 @@ void BFormatDec::reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans { return mask | (1 << chan); } ); - const ALfloat xover_norm{conf->XOverFreq / (float)srate}; + const ALfloat xover_norm{conf->XOverFreq / static_cast<float>(srate)}; const ALsizei out_order{ (conf->ChanMask > AMBI_3ORDER_MASK) ? 4 : diff --git a/Alc/converter.cpp b/Alc/converter.cpp index 22a01552..49c5cb3b 100644 --- a/Alc/converter.cpp +++ b/Alc/converter.cpp @@ -155,7 +155,7 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, /* Have to set the mixer FPU mode since that's what the resampler code expects. */ FPUCtl mixer_mode{}; auto step = static_cast<ALsizei>( - mind((ALdouble)srcRate/dstRate*FRACTIONONE + 0.5, MAX_PITCH*FRACTIONONE)); + mind(static_cast<ALdouble>(srcRate)/dstRate*FRACTIONONE + 0.5, MAX_PITCH*FRACTIONONE)); converter->mIncrement = maxi(step, 1); if(converter->mIncrement == FRACTIONONE) converter->mResample = Resample_copy_C; @@ -203,7 +203,7 @@ ALsizei SampleConverter::availableOut(ALsizei srcframes) const DataSize64 -= mFracOffset; /* If we have a full prep, we can generate at least one sample. */ - return (ALsizei)clampu64((DataSize64 + mIncrement-1)/mIncrement, 1, BUFFERSIZE); + return static_cast<ALsizei>(clampu64((DataSize64 + mIncrement-1)/mIncrement, 1, BUFFERSIZE)); } ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid *dst, ALsizei dstframes) @@ -267,7 +267,7 @@ ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid for(ALsizei chan{0};chan < mNumChannels;chan++) { const ALbyte *SrcSamples = SamplesIn + mSrcTypeSize*chan; - ALbyte *DstSamples = (ALbyte*)dst + mDstTypeSize*chan; + ALbyte *DstSamples = static_cast<ALbyte*>(dst) + mDstTypeSize*chan; /* Load the previous samples into the source data first, then the * new samples from the input buffer. @@ -309,7 +309,7 @@ ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid SamplesIn += SrcFrameSize*(DataPosFrac>>FRACTIONBITS); NumSrcSamples -= mini(NumSrcSamples, (DataPosFrac>>FRACTIONBITS)); - dst = (ALbyte*)dst + DstFrameSize*DstSize; + dst = static_cast<ALbyte*>(dst) + DstFrameSize*DstSize; pos += DstSize; } diff --git a/Alc/effects/chorus.cpp b/Alc/effects/chorus.cpp index 1132a33a..990b3cc4 100644 --- a/Alc/effects/chorus.cpp +++ b/Alc/effects/chorus.cpp @@ -141,7 +141,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co const ALCdevice *device{Context->Device}; auto frequency = static_cast<ALfloat>(device->Frequency); mDelay = maxi(float2int(props->Chorus.Delay*frequency*FRACTIONONE + 0.5f), mindelay); - mDepth = minf(props->Chorus.Depth * mDelay, (ALfloat)(mDelay - mindelay)); + mDepth = minf(props->Chorus.Depth * mDelay, static_cast<ALfloat>(mDelay - mindelay)); mFeedback = props->Chorus.Feedback; @@ -168,9 +168,9 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co /* Calculate LFO coefficient (number of samples per cycle). Limit the * max range to avoid overflow when calculating the displacement. */ - ALsizei lfo_range = float2int(minf(frequency/rate + 0.5f, (ALfloat)(INT_MAX/360 - 180))); + ALsizei lfo_range = float2int(minf(frequency/rate + 0.5f, static_cast<ALfloat>(INT_MAX/360 - 180))); - mLfoOffset = float2int((ALfloat)mLfoOffset/mLfoRange*lfo_range + 0.5f) % lfo_range; + mLfoOffset = float2int(static_cast<ALfloat>(mLfoOffset)/mLfoRange*lfo_range + 0.5f) % lfo_range; mLfoRange = lfo_range; switch(mWaveform) { diff --git a/Alc/effects/compressor.cpp b/Alc/effects/compressor.cpp index ddf104f4..1b840c44 100644 --- a/Alc/effects/compressor.cpp +++ b/Alc/effects/compressor.cpp @@ -60,8 +60,8 @@ ALboolean ALcompressorState::deviceUpdate(const ALCdevice *device) /* Number of samples to do a full attack and release (non-integer sample * counts are okay). */ - const ALfloat attackCount = (ALfloat)device->Frequency * ATTACK_TIME; - const ALfloat releaseCount = (ALfloat)device->Frequency * RELEASE_TIME; + const ALfloat attackCount = static_cast<ALfloat>(device->Frequency) * ATTACK_TIME; + const ALfloat releaseCount = static_cast<ALfloat>(device->Frequency) * RELEASE_TIME; /* Calculate per-sample multipliers to attack and release at the desired * rates. diff --git a/Alc/effects/equalizer.cpp b/Alc/effects/equalizer.cpp index 94c760ea..defe1485 100644 --- a/Alc/effects/equalizer.cpp +++ b/Alc/effects/equalizer.cpp @@ -113,7 +113,7 @@ ALboolean ALequalizerState::deviceUpdate(const ALCdevice *UNUSED(device)) void ALequalizerState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { const ALCdevice *device = context->Device; - ALfloat frequency = (ALfloat)device->Frequency; + ALfloat frequency = static_cast<ALfloat>(device->Frequency); ALfloat gain, f0norm; ALuint i; diff --git a/Alc/effects/fshifter.cpp b/Alc/effects/fshifter.cpp index c444872c..994dd90c 100644 --- a/Alc/effects/fshifter.cpp +++ b/Alc/effects/fshifter.cpp @@ -111,7 +111,7 @@ void ALfshifterState::update(const ALCcontext *context, const ALeffectslot *slot { const ALCdevice *device{context->Device}; - ALfloat step{props->Fshifter.Frequency / (ALfloat)device->Frequency}; + ALfloat step{props->Fshifter.Frequency / static_cast<ALfloat>(device->Frequency)}; mPhaseStep = fastf2i(minf(step, 0.5f) * FRACTIONONE); switch(props->Fshifter.LeftDirection) @@ -190,7 +190,7 @@ void ALfshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp for(k = 0;k < SamplesToDo;k++) { double phase = mPhase * ((1.0/FRACTIONONE) * al::MathDefs<double>::Tau()); - BufferOut[k] = (float)(mOutdata[k].real()*std::cos(phase) + + BufferOut[k] = static_cast<float>(mOutdata[k].real()*std::cos(phase) + mOutdata[k].imag()*std::sin(phase)*mLdSign); mPhase += mPhaseStep; diff --git a/Alc/effects/modulator.cpp b/Alc/effects/modulator.cpp index 3544188b..9549740e 100644 --- a/Alc/effects/modulator.cpp +++ b/Alc/effects/modulator.cpp @@ -43,17 +43,17 @@ static inline ALfloat Sin(ALsizei index) { - return std::sin((ALfloat)index * (al::MathDefs<float>::Tau() / (ALfloat)WAVEFORM_FRACONE)); + return std::sin(static_cast<ALfloat>(index) * (al::MathDefs<float>::Tau() / static_cast<ALfloat>WAVEFORM_FRACONE)); } static inline ALfloat Saw(ALsizei index) { - return (ALfloat)index*(2.0f/WAVEFORM_FRACONE) - 1.0f; + return static_cast<ALfloat>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f; } static inline ALfloat Square(ALsizei index) { - return (ALfloat)(((index>>(WAVEFORM_FRACBITS-2))&2) - 1); + return static_cast<ALfloat>(((index>>(WAVEFORM_FRACBITS-2))&2) - 1); } static inline ALfloat One(ALsizei UNUSED(index)) @@ -111,7 +111,7 @@ void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slo ALfloat f0norm; ALsizei i; - mStep = fastf2i(props->Modulator.Frequency / (ALfloat)device->Frequency * WAVEFORM_FRACONE); + mStep = fastf2i(props->Modulator.Frequency / static_cast<ALfloat>(device->Frequency) * WAVEFORM_FRACONE); mStep = clampi(mStep, 0, WAVEFORM_FRACONE-1); if(mStep == 0) @@ -123,7 +123,7 @@ void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slo else /*if(Slot->Params.EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)*/ mGetSamples = Modulate<Square>; - f0norm = props->Modulator.HighPassCutoff / (ALfloat)device->Frequency; + f0norm = props->Modulator.HighPassCutoff / static_cast<ALfloat>(device->Frequency); f0norm = clampf(f0norm, 1.0f/512.0f, 0.49f); /* Bandwidth value is constant in octaves. */ mChans[0].Filter.setParams(BiquadType::HighPass, 1.0f, f0norm, @@ -214,7 +214,7 @@ void ALmodulator_setParami(ALeffect *effect, ALCcontext *context, ALenum param, { case AL_RING_MODULATOR_FREQUENCY: case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - ALmodulator_setParamf(effect, context, param, (ALfloat)val); + ALmodulator_setParamf(effect, context, param, static_cast<ALfloat>(val)); break; case AL_RING_MODULATOR_WAVEFORM: @@ -236,10 +236,10 @@ void ALmodulator_getParami(const ALeffect *effect, ALCcontext *context, ALenum p switch(param) { case AL_RING_MODULATOR_FREQUENCY: - *val = (ALint)props->Modulator.Frequency; + *val = static_cast<ALint>(props->Modulator.Frequency); break; case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - *val = (ALint)props->Modulator.HighPassCutoff; + *val = static_cast<ALint>(props->Modulator.HighPassCutoff); break; case AL_RING_MODULATOR_WAVEFORM: *val = props->Modulator.Waveform; diff --git a/Alc/effects/pshifter.cpp b/Alc/effects/pshifter.cpp index 7c6fb51e..f0b9de1c 100644 --- a/Alc/effects/pshifter.cpp +++ b/Alc/effects/pshifter.cpp @@ -72,7 +72,7 @@ inline int double2int(double d) #else - return (ALint)d; + return static_cast<ALint>(d); #endif } @@ -156,7 +156,7 @@ ALboolean ALpshifterState::deviceUpdate(const ALCdevice *device) mCount = FIFO_LATENCY; mPitchShiftI = FRACTIONONE; mPitchShift = 1.0f; - mFreqPerBin = device->Frequency / (ALfloat)STFT_SIZE; + mFreqPerBin = device->Frequency / static_cast<ALfloat>(STFT_SIZE); std::fill(std::begin(mInFIFO), std::end(mInFIFO), 0.0f); std::fill(std::begin(mOutFIFO), std::end(mOutFIFO), 0.0f); @@ -176,7 +176,7 @@ ALboolean ALpshifterState::deviceUpdate(const ALCdevice *device) void ALpshifterState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { const float pitch{std::pow(2.0f, - (ALfloat)(props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune) / 1200.0f + static_cast<ALfloat>(props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune) / 1200.0f )}; mPitchShiftI = fastf2i(pitch*FRACTIONONE); mPitchShift = mPitchShiftI * (1.0f/FRACTIONONE); @@ -304,7 +304,7 @@ void ALpshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp /* Shift accumulator, input & output FIFO */ ALsizei j, k; - for(k = 0;k < STFT_STEP;k++) mOutFIFO[k] = (ALfloat)mOutputAccum[k]; + for(k = 0;k < STFT_STEP;k++) mOutFIFO[k] = static_cast<ALfloat>(mOutputAccum[k]); for(j = 0;k < STFT_SIZE;k++,j++) mOutputAccum[j] = mOutputAccum[k]; for(;j < STFT_SIZE;j++) mOutputAccum[j] = 0.0; for(k = 0;k < FIFO_LATENCY;k++) @@ -375,10 +375,10 @@ void ALpshifter_getParami(const ALeffect *effect, ALCcontext *context, ALenum pa switch(param) { case AL_PITCH_SHIFTER_COARSE_TUNE: - *val = (ALint)props->Pshifter.CoarseTune; + *val = props->Pshifter.CoarseTune; break; case AL_PITCH_SHIFTER_FINE_TUNE: - *val = (ALint)props->Pshifter.FineTune; + *val = props->Pshifter.FineTune; break; default: diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp index 6f1b1bb1..a63cc4c3 100644 --- a/Alc/effects/reverb.cpp +++ b/Alc/effects/reverb.cpp @@ -359,7 +359,7 @@ inline ALvoid RealizeLineOffset(ALfloat *sampleBuffer, DelayLineI *Delay) ALfloat *f; ALfloat (*f4)[NUM_LINES]; } u; - u.f = &sampleBuffer[(ptrdiff_t)Delay->Line * NUM_LINES]; + u.f = &sampleBuffer[reinterpret_cast<ptrdiff_t>(Delay->Line) * NUM_LINES]; Delay->Line = u.f4; } @@ -377,7 +377,7 @@ ALuint CalcLineLength(const ALfloat length, const ptrdiff_t offset, const ALuint /* All lines share a single sample buffer. */ Delay->Mask = samples - 1; - Delay->Line = (ALfloat(*)[NUM_LINES])offset; + Delay->Line = reinterpret_cast<ALfloat(*)[NUM_LINES]>(offset); /* Return the sample count for accumulation. */ return samples; @@ -658,7 +658,7 @@ ALvoid UpdateLateLines(const ALfloat density, const ALfloat diffusion, const ALf /* Scaling factor to convert the normalized reference frequencies from * representing 0...freq to 0...max_reference. */ - const ALfloat norm_weight_factor = (ALfloat)frequency / AL_EAXREVERB_MAX_HFREFERENCE; + const ALfloat norm_weight_factor = static_cast<ALfloat>(frequency) / AL_EAXREVERB_MAX_HFREFERENCE; /* To compensate for changes in modal density and decay time of the late * reverb signal, the input is attenuated based on the maximal energy of diff --git a/Alc/helpers.cpp b/Alc/helpers.cpp index 4a80c7e5..88c222bf 100644 --- a/Alc/helpers.cpp +++ b/Alc/helpers.cpp @@ -531,7 +531,7 @@ const PathNamePair &GetProcBinary() len = readlink(selfname, pathname.data(), pathname.size()); } - while(len > 0 && (size_t)len == pathname.size()) + while(len > 0 && static_cast<size_t>(len) == pathname.size()) { pathname.resize(pathname.size() << 1); len = readlink(selfname, pathname.data(), pathname.size()); diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp index 070de55f..4d1c27ee 100644 --- a/Alc/hrtf.cpp +++ b/Alc/hrtf.cpp @@ -329,7 +329,7 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz { for(ALsizei i{0};i < NumChannels;++i) { - const ALdouble mult{(ALdouble)AmbiOrderHFGain[OrderFromChan[i]] * AmbiMatrix[c][i]}; + const ALdouble mult{static_cast<ALdouble>(AmbiOrderHFGain[OrderFromChan[i]]) * AmbiMatrix[c][i]}; const ALsizei numirs{mini(Hrtf->irSize, HRIR_LENGTH-maxi(ldelay, rdelay))}; ALsizei lidx{ldelay}, ridx{rdelay}; for(ALsizei j{0};j < numirs;++j) @@ -384,8 +384,8 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz { for(ALsizei idx{0};idx < HRIR_LENGTH;idx++) { - state->Chan[i].Coeffs[idx][0] = (ALfloat)tmpres[i][idx][0]; - state->Chan[i].Coeffs[idx][1] = (ALfloat)tmpres[i][idx][1]; + state->Chan[i].Coeffs[idx][0] = static_cast<ALfloat>(tmpres[i][idx][0]); + state->Chan[i].Coeffs[idx][1] = static_cast<ALfloat>(tmpres[i][idx][1]); } } tmpres.clear(); @@ -435,7 +435,7 @@ HrtfEntry *CreateHrtfStore(ALuint rate, ALsizei irSize, ALfloat distance, ALsize else { uintptr_t offset = sizeof(HrtfEntry); - char *base = (char*)Hrtf; + char *base = reinterpret_cast<char*>(Hrtf); ALushort *_evOffset; ALubyte *_azCount; ALubyte (*_delays)[2]; @@ -941,7 +941,7 @@ HrtfEntry *LoadHrtf02(std::istream &data, const char *filename) } return CreateHrtfStore(rate, irSize, - (ALfloat)distance / 1000.0f, evCount, irCount, azCount.data(), evOffset.data(), + static_cast<ALfloat>(distance) / 1000.0f, evCount, irCount, azCount.data(), evOffset.data(), &reinterpret_cast<ALfloat(&)[2]>(coeffs[0]), &reinterpret_cast<ALubyte(&)[2]>(delays[0]), filename ); diff --git a/Alc/mastering.cpp b/Alc/mastering.cpp index dcc5cf40..c71b3cc9 100644 --- a/Alc/mastering.cpp +++ b/Alc/mastering.cpp @@ -398,15 +398,15 @@ std::unique_ptr<Compressor> CompressorInit(const ALsizei NumChans, const ALuint { if(hold > 1) { - Comp->mHold = new ((void*)(Comp.get() + 1)) SlidingHold{}; + Comp->mHold = new (reinterpret_cast<void*>(Comp.get() + 1)) SlidingHold{}; Comp->mHold->mValues[0] = -std::numeric_limits<float>::infinity(); Comp->mHold->mExpiries[0] = hold; Comp->mHold->mLength = hold; - Comp->mDelay = (ALfloat(*)[BUFFERSIZE])(Comp->mHold + 1); + Comp->mDelay = reinterpret_cast<ALfloat(*)[BUFFERSIZE]>(Comp->mHold + 1); } else { - Comp->mDelay = (ALfloat(*)[BUFFERSIZE])(Comp.get() + 1); + Comp->mDelay = reinterpret_cast<ALfloat(*)[BUFFERSIZE]>(Comp.get() + 1); } } diff --git a/Alc/mixer/mixer_c.cpp b/Alc/mixer/mixer_c.cpp index 31a5cee4..1b16b733 100644 --- a/Alc/mixer/mixer_c.cpp +++ b/Alc/mixer/mixer_c.cpp @@ -46,7 +46,7 @@ const ALfloat *Resample_copy_C(const InterpState* UNUSED(state), ASSUME(numsamples > 0); #if defined(HAVE_SSE) || defined(HAVE_NEON) /* Avoid copying the source data if it's aligned like the destination. */ - if((((intptr_t)src)&15) == (((intptr_t)dst)&15)) + if((reinterpret_cast<intptr_t>(src)&15) == (reinterpret_cast<intptr_t>(dst)&15)) return src; #endif std::copy_n(src, numsamples, dst); @@ -137,7 +137,7 @@ void Mix_C(const ALfloat *data, ALsizei OutChans, ALfloat (*RESTRICT OutBuffer)[ ASSUME(OutChans > 0); ASSUME(BufferSize > 0); - const ALfloat delta{(Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f}; + const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f}; for(ALsizei c{0};c < OutChans;c++) { ALsizei pos{0}; diff --git a/Alc/mixer/mixer_sse.cpp b/Alc/mixer/mixer_sse.cpp index df5270e7..9eadfd9e 100644 --- a/Alc/mixer/mixer_sse.cpp +++ b/Alc/mixer/mixer_sse.cpp @@ -37,10 +37,10 @@ const ALfloat *Resample_bsinc_SSE(const InterpState *state, const ALfloat *RESTR #undef FRAC_PHASE_BITDIFF ALsizei offset{m*pi*4}; - const __m128 *fil{(const __m128*)(filter + offset)}; offset += m; - const __m128 *scd{(const __m128*)(filter + offset)}; offset += m; - const __m128 *phd{(const __m128*)(filter + offset)}; offset += m; - const __m128 *spd{(const __m128*)(filter + offset)}; + const __m128 *fil{reinterpret_cast<const __m128*>(filter + offset)}; offset += m; + const __m128 *scd{reinterpret_cast<const __m128*>(filter + offset)}; offset += m; + const __m128 *phd{reinterpret_cast<const __m128*>(filter + offset)}; offset += m; + const __m128 *spd{reinterpret_cast<const __m128*>(filter + offset)}; // Apply the scale and phase interpolated filter. __m128 r4{_mm_setzero_ps()}; @@ -92,10 +92,10 @@ static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2] __m128 imp0, imp1; __m128 coeffs{_mm_load_ps(&Coeffs[0][0])}; - __m128 vals{_mm_loadl_pi(_mm_setzero_ps(), (__m64*)&Values[Offset][0])}; + __m128 vals{_mm_loadl_pi(_mm_setzero_ps(), reinterpret_cast<__m64*>(&Values[Offset][0]))}; imp0 = _mm_mul_ps(lrlr, coeffs); vals = _mm_add_ps(imp0, vals); - _mm_storel_pi((__m64*)&Values[Offset][0], vals); + _mm_storel_pi(reinterpret_cast<__m64*>(&Values[Offset][0]), vals); ++Offset; for(ALsizei i{1};;) { @@ -115,10 +115,10 @@ static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2] break; count = IrSize-1; } - vals = _mm_loadl_pi(vals, (__m64*)&Values[Offset][0]); + vals = _mm_loadl_pi(vals, reinterpret_cast<__m64*>(&Values[Offset][0])); imp0 = _mm_movehl_ps(imp0, imp0); vals = _mm_add_ps(imp0, vals); - _mm_storel_pi((__m64*)&Values[Offset][0], vals); + _mm_storel_pi(reinterpret_cast<__m64*>(&Values[Offset][0]), vals); } else { @@ -156,7 +156,7 @@ void Mix_SSE(const ALfloat *data, ALsizei OutChans, ALfloat (*RESTRICT OutBuffer ASSUME(OutChans > 0); ASSUME(BufferSize > 0); - const ALfloat delta{(Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f}; + const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f}; for(ALsizei c{0};c < OutChans;c++) { ALsizei pos{0}; diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp index eb219bad..e52b330d 100644 --- a/Alc/mixvoice.cpp +++ b/Alc/mixvoice.cpp @@ -211,7 +211,7 @@ template<> inline ALfloat LoadSample<FmtShort>(FmtTypeTraits<FmtShort>::Type val template<> inline ALfloat LoadSample<FmtFloat>(FmtTypeTraits<FmtFloat>::Type val) { return val; } template<> inline ALfloat LoadSample<FmtDouble>(FmtTypeTraits<FmtDouble>::Type val) -{ return (ALfloat)val; } +{ return static_cast<ALfloat>(val); } template<> inline ALfloat LoadSample<FmtMulaw>(FmtTypeTraits<FmtMulaw>::Type val) { return muLawDecompressionTable[val] * (1.0f/32768.0f); } template<> inline ALfloat LoadSample<FmtAlaw>(FmtTypeTraits<FmtAlaw>::Type val) @@ -295,7 +295,7 @@ ALboolean MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, /* Get source info */ bool isplaying{true}; /* Will only be called while playing. */ bool isstatic{(voice->Flags&VOICE_IS_STATIC) != 0}; - ALsizei DataPosInt{(ALsizei)voice->position.load(std::memory_order_acquire)}; + ALsizei DataPosInt{static_cast<ALsizei>(voice->position.load(std::memory_order_acquire))}; ALsizei DataPosFrac{voice->position_fraction.load(std::memory_order_relaxed)}; ALbufferlistitem *BufferListItem{voice->current_buffer.load(std::memory_order_relaxed)}; ALbufferlistitem *BufferLoopItem{voice->loop_buffer.load(std::memory_order_relaxed)}; @@ -603,13 +603,13 @@ ALboolean MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, * this mix handles. */ ALfloat gain{lerp(parms.Hrtf.Old.Gain, parms.Hrtf.Target.Gain, - minf(1.0f, (ALfloat)fademix/Counter))}; + minf(1.0f, static_cast<ALfloat>(fademix))/Counter)}; MixHrtfParams hrtfparams; hrtfparams.Coeffs = &parms.Hrtf.Target.Coeffs; hrtfparams.Delay[0] = parms.Hrtf.Target.Delay[0]; hrtfparams.Delay[1] = parms.Hrtf.Target.Delay[1]; hrtfparams.Gain = 0.0f; - hrtfparams.GainStep = gain / (ALfloat)fademix; + hrtfparams.GainStep = gain / static_cast<ALfloat>(fademix); MixHrtfBlendSamples( voice->Direct.Buffer[OutLIdx], voice->Direct.Buffer[OutRIdx], @@ -631,14 +631,14 @@ ALboolean MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context, */ if(Counter > DstBufferSize) gain = lerp(parms.Hrtf.Old.Gain, gain, - (ALfloat)todo/(Counter-fademix)); + static_cast<ALfloat>(todo)/(Counter-fademix)); MixHrtfParams hrtfparams; hrtfparams.Coeffs = &parms.Hrtf.Target.Coeffs; hrtfparams.Delay[0] = parms.Hrtf.Target.Delay[0]; hrtfparams.Delay[1] = parms.Hrtf.Target.Delay[1]; hrtfparams.Gain = parms.Hrtf.Old.Gain; - hrtfparams.GainStep = (gain - parms.Hrtf.Old.Gain) / (ALfloat)todo; + hrtfparams.GainStep = (gain - parms.Hrtf.Old.Gain) / static_cast<ALfloat>(todo); MixHrtfSamples( voice->Direct.Buffer[OutLIdx], voice->Direct.Buffer[OutRIdx], samples+fademix, voice->Offset+fademix, OutPos+fademix, IrSize, diff --git a/Alc/panning.cpp b/Alc/panning.cpp index c311e31f..e184a13d 100644 --- a/Alc/panning.cpp +++ b/Alc/panning.cpp @@ -273,12 +273,12 @@ void InitDistanceComp(ALCdevice *device, const AmbDecConf *conf, const ALsizei ( const ALfloat delay{ std::floor((maxdist - speaker.Distance)/SPEEDOFSOUNDMETRESPERSEC*srate + 0.5f) }; - if(delay >= (ALfloat)MAX_DELAY_LENGTH) + if(delay >= static_cast<ALfloat>(MAX_DELAY_LENGTH)) ERR("Delay for speaker \"%s\" exceeds buffer length (%f >= %d)\n", speaker.Name.c_str(), delay, MAX_DELAY_LENGTH); device->ChannelDelay[chan].Length = static_cast<ALsizei>(clampf( - delay, 0.0f, (ALfloat)(MAX_DELAY_LENGTH-1) + delay, 0.0f, static_cast<ALfloat>(MAX_DELAY_LENGTH-1) )); device->ChannelDelay[chan].Gain = speaker.Distance / maxdist; TRACE("Channel %u \"%s\" distance compensation: %d samples, %f gain\n", chan, @@ -951,7 +951,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr * front-right channels, with a crossover at 5khz (could be * higher). */ - const ALfloat scale{(ALfloat)(5000.0 / device->Frequency)}; + const ALfloat scale{static_cast<ALfloat>(5000.0 / device->Frequency)}; stablizer->LFilter.init(scale); stablizer->RFilter = stablizer->LFilter; @@ -1016,7 +1016,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr if(device->HrtfList.empty()) device->HrtfList = EnumerateHrtf(device->DeviceName.c_str()); - if(hrtf_id >= 0 && (size_t)hrtf_id < device->HrtfList.size()) + if(hrtf_id >= 0 && static_cast<size_t>(hrtf_id) < device->HrtfList.size()) { const EnumeratedHrtf &entry = device->HrtfList[hrtf_id]; HrtfEntry *hrtf{GetLoadedHrtf(entry.hrtf)}; |