diff options
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alc.cpp | 8 | ||||
-rw-r--r-- | alc/alconfig.cpp | 12 | ||||
-rw-r--r-- | alc/backends/base.h | 2 | ||||
-rw-r--r-- | alc/backends/pulseaudio.cpp | 2 | ||||
-rw-r--r-- | alc/filters/biquad.cpp | 28 | ||||
-rw-r--r-- | alc/filters/biquad.h | 32 | ||||
-rw-r--r-- | alc/filters/splitter.cpp | 44 | ||||
-rw-r--r-- | alc/filters/splitter.h | 10 | ||||
-rw-r--r-- | alc/hrtf.cpp | 8 | ||||
-rw-r--r-- | alc/hrtf.h | 2 | ||||
-rw-r--r-- | alc/mixvoice.cpp | 29 |
11 files changed, 89 insertions, 88 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 8e9d3963..fa88cba8 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -3731,11 +3731,11 @@ START_API_FUNC al::vector<ContextRef> orphanctxs; for(ALCcontext *ctx : *dev->mContexts.load()) { - auto iter = std::lower_bound(ContextList.begin(), ContextList.end(), ctx); - if(iter != ContextList.end() && *iter == ctx) + auto ctxiter = std::lower_bound(ContextList.begin(), ContextList.end(), ctx); + if(ctxiter != ContextList.end() && *ctxiter == ctx) { - orphanctxs.emplace_back(std::move(*iter)); - ContextList.erase(iter); + orphanctxs.emplace_back(std::move(*ctxiter)); + ContextList.erase(ctxiter); } } listlock.unlock(); diff --git a/alc/alconfig.cpp b/alc/alconfig.cpp index 8ca81bc8..666c2c2d 100644 --- a/alc/alconfig.cpp +++ b/alc/alconfig.cpp @@ -359,7 +359,7 @@ void ReadALConfig() else fname += "alsoft.conf"; TRACE("Loading config %s...\n", fname.c_str()); - al::ifstream f{fname}; + f = al::ifstream{fname}; if(f.is_open()) LoadConfigFromFile(f); } @@ -376,7 +376,7 @@ void ReadALConfig() if((configURL=CFBundleCopyResourceURL(mainBundle, CFSTR(".alsoftrc"), CFSTR(""), nullptr)) && CFURLGetFileSystemRepresentation(configURL, true, fileName, sizeof(fileName))) { - al::ifstream f{reinterpret_cast<char*>(fileName)}; + f = al::ifstream{reinterpret_cast<char*>(fileName)}; if(f.is_open()) LoadConfigFromFile(f); } @@ -390,7 +390,7 @@ void ReadALConfig() else fname += ".alsoftrc"; TRACE("Loading config %s...\n", fname.c_str()); - al::ifstream f{fname}; + f = al::ifstream{fname}; if(f.is_open()) LoadConfigFromFile(f); } @@ -414,7 +414,7 @@ void ReadALConfig() if(!fname.empty()) { TRACE("Loading config %s...\n", fname.c_str()); - al::ifstream f{fname}; + f = al::ifstream{fname}; if(f.is_open()) LoadConfigFromFile(f); } @@ -426,7 +426,7 @@ void ReadALConfig() else ppath += "alsoft.conf"; TRACE("Loading config %s...\n", ppath.c_str()); - al::ifstream f{ppath}; + f = al::ifstream{ppath}; if(f.is_open()) LoadConfigFromFile(f); } @@ -434,7 +434,7 @@ void ReadALConfig() if(auto confname = al::getenv("ALSOFT_CONF")) { TRACE("Loading config %s...\n", confname->c_str()); - al::ifstream f{*confname}; + f = al::ifstream{*confname}; if(f.is_open()) LoadConfigFromFile(f); } diff --git a/alc/backends/base.h b/alc/backends/base.h index 5e294fe8..e88734dc 100644 --- a/alc/backends/base.h +++ b/alc/backends/base.h @@ -68,6 +68,8 @@ enum class DevProbe { struct BackendFactory { + virtual ~BackendFactory() = default; + virtual bool init() = 0; virtual bool querySupport(BackendType type) = 0; diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index 9c54c07b..23d4e71a 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -484,7 +484,7 @@ pa_stream *pulse_connect_stream(const char *device_name, std::unique_lock<std::m { if(!PA_STREAM_IS_GOOD(state)) { - int err{pa_context_errno(context)}; + err = pa_context_errno(context); pa_stream_unref(stream); throw al::backend_exception{ALC_INVALID_VALUE, "%s did not get ready (%s)", stream_id, pa_strerror(err)}; diff --git a/alc/filters/biquad.cpp b/alc/filters/biquad.cpp index a4d81604..8a8810e2 100644 --- a/alc/filters/biquad.cpp +++ b/alc/filters/biquad.cpp @@ -81,11 +81,11 @@ void BiquadFilterR<Real>::setParams(BiquadType type, Real gain, Real f0norm, Rea break; } - a1 = a[1] / a[0]; - a2 = a[2] / a[0]; - b0 = b[0] / a[0]; - b1 = b[1] / a[0]; - b2 = b[2] / a[0]; + mA1 = a[1] / a[0]; + mA2 = a[2] / a[0]; + mB0 = b[0] / a[0]; + mB1 = b[1] / a[0]; + mB2 = b[2] / a[0]; } template<typename Real> @@ -93,13 +93,13 @@ void BiquadFilterR<Real>::process(Real *dst, const Real *src, const size_t numsa { ASSUME(numsamples > 0); - const Real b0{this->b0}; - const Real b1{this->b1}; - const Real b2{this->b2}; - const Real a1{this->a1}; - const Real a2{this->a2}; - Real z1{this->z1}; - Real z2{this->z2}; + const Real b0{mB0}; + const Real b1{mB1}; + const Real b2{mB2}; + const Real a1{mA1}; + const Real a2{mA2}; + Real z1{mZ1}; + Real z2{mZ2}; /* Processing loop is Transposed Direct Form II. This requires less storage * compared to Direct Form I (only two delay components, instead of a four- @@ -118,8 +118,8 @@ void BiquadFilterR<Real>::process(Real *dst, const Real *src, const size_t numsa }; std::transform(src, src+numsamples, dst, proc_sample); - this->z1 = z1; - this->z2 = z2; + mZ1 = z1; + mZ2 = z2; } template class BiquadFilterR<float>; diff --git a/alc/filters/biquad.h b/alc/filters/biquad.h index 9de86f2f..9af954ae 100644 --- a/alc/filters/biquad.h +++ b/alc/filters/biquad.h @@ -38,14 +38,14 @@ enum class BiquadType { template<typename Real> class BiquadFilterR { /* Last two delayed components for direct form II. */ - Real z1{0.0f}, z2{0.0f}; + Real mZ1{0.0f}, mZ2{0.0f}; /* Transfer function coefficients "b" (numerator) */ - Real b0{1.0f}, b1{0.0f}, b2{0.0f}; + Real mB0{1.0f}, mB1{0.0f}, mB2{0.0f}; /* Transfer function coefficients "a" (denominator; a0 is pre-applied). */ - Real a1{0.0f}, a2{0.0f}; + Real mA1{0.0f}, mA2{0.0f}; public: - void clear() noexcept { z1 = z2 = 0.0f; } + void clear() noexcept { mZ1 = mZ2 = 0.0f; } /** * Sets the filter state for the specified filter type and its parameters. @@ -65,26 +65,24 @@ public: void copyParamsFrom(const BiquadFilterR &other) { - b0 = other.b0; - b1 = other.b1; - b2 = other.b2; - a1 = other.a1; - a2 = other.a2; + mB0 = other.mB0; + mB1 = other.mB1; + mB2 = other.mB2; + mA1 = other.mA1; + mA2 = other.mA2; } void process(Real *dst, const Real *src, const size_t numsamples); /* Rather hacky. It's just here to support "manual" processing. */ - std::pair<Real,Real> getComponents() const noexcept - { return {z1, z2}; } - void setComponents(Real z1_, Real z2_) noexcept - { z1 = z1_; z2 = z2_; } - Real processOne(const Real in, Real &z1_, Real &z2_) const noexcept + std::pair<Real,Real> getComponents() const noexcept { return {mZ1, mZ2}; } + void setComponents(Real z1, Real z2) noexcept { mZ1 = z1; mZ2 = z2; } + Real processOne(const Real in, Real &z1, Real &z2) const noexcept { - Real out{in*b0 + z1_}; - z1_ = in*b1 - out*a1 + z2_; - z2_ = in*b2 - out*a2; + Real out{in*mB0 + z1}; + z1 = in*mB1 - out*mA1 + z2; + z2 = in*mB2 - out*mA2; return out; } diff --git a/alc/filters/splitter.cpp b/alc/filters/splitter.cpp index 66806ea9..c6218e70 100644 --- a/alc/filters/splitter.cpp +++ b/alc/filters/splitter.cpp @@ -17,13 +17,13 @@ void BandSplitterR<Real>::init(Real f0norm) const Real w{f0norm * al::MathDefs<Real>::Tau()}; const Real cw{std::cos(w)}; if(cw > std::numeric_limits<float>::epsilon()) - coeff = (std::sin(w) - 1.0f) / cw; + mCoeff = (std::sin(w) - 1.0f) / cw; else - coeff = cw * -0.5f; + mCoeff = cw * -0.5f; - lp_z1 = 0.0f; - lp_z2 = 0.0f; - ap_z1 = 0.0f; + mLpZ1 = 0.0f; + mLpZ2 = 0.0f; + mApZ1 = 0.0f; } template<typename Real> @@ -31,11 +31,11 @@ void BandSplitterR<Real>::process(Real *hpout, Real *lpout, const Real *input, c { ASSUME(count > 0); - const Real ap_coeff{this->coeff}; - const Real lp_coeff{this->coeff*0.5f + 0.5f}; - Real lp_z1{this->lp_z1}; - Real lp_z2{this->lp_z2}; - Real ap_z1{this->ap_z1}; + const Real ap_coeff{mCoeff}; + const Real lp_coeff{mCoeff*0.5f + 0.5f}; + Real lp_z1{mLpZ1}; + Real lp_z2{mLpZ2}; + Real ap_z1{mApZ1}; auto proc_sample = [ap_coeff,lp_coeff,&lp_z1,&lp_z2,&ap_z1,&lpout](const Real in) noexcept -> Real { /* Low-pass sample processing. */ @@ -57,9 +57,9 @@ void BandSplitterR<Real>::process(Real *hpout, Real *lpout, const Real *input, c return ap_y - lp_y; }; std::transform(input, input+count, hpout, proc_sample); - this->lp_z1 = lp_z1; - this->lp_z2 = lp_z2; - this->ap_z1 = ap_z1; + mLpZ1 = lp_z1; + mLpZ2 = lp_z2; + mApZ1 = ap_z1; } template<typename Real> @@ -67,11 +67,11 @@ void BandSplitterR<Real>::applyHfScale(Real *samples, const Real hfscale, const { ASSUME(count > 0); - const Real ap_coeff{this->coeff}; - const Real lp_coeff{this->coeff*0.5f + 0.5f}; - Real lp_z1{this->lp_z1}; - Real lp_z2{this->lp_z2}; - Real ap_z1{this->ap_z1}; + const Real ap_coeff{mCoeff}; + const Real lp_coeff{mCoeff*0.5f + 0.5f}; + Real lp_z1{mLpZ1}; + Real lp_z2{mLpZ2}; + Real ap_z1{mApZ1}; auto proc_sample = [hfscale,ap_coeff,lp_coeff,&lp_z1,&lp_z2,&ap_z1](const Real in) noexcept -> Real { /* Low-pass sample processing. */ @@ -91,9 +91,9 @@ void BandSplitterR<Real>::applyHfScale(Real *samples, const Real hfscale, const return (ap_y-lp_y)*hfscale + lp_y; }; std::transform(samples, samples+count, samples, proc_sample); - this->lp_z1 = lp_z1; - this->lp_z2 = lp_z2; - this->ap_z1 = ap_z1; + mLpZ1 = lp_z1; + mLpZ2 = lp_z2; + mApZ1 = ap_z1; } template<typename Real> @@ -101,7 +101,7 @@ void BandSplitterR<Real>::applyAllpass(Real *samples, const size_t count) const { ASSUME(count > 0); - const Real coeff{this->coeff}; + const Real coeff{mCoeff}; Real z1{0.0f}; auto proc_sample = [coeff,&z1](const Real in) noexcept -> Real { diff --git a/alc/filters/splitter.h b/alc/filters/splitter.h index b024f0c3..5117a244 100644 --- a/alc/filters/splitter.h +++ b/alc/filters/splitter.h @@ -7,10 +7,10 @@ /* Band splitter. Splits a signal into two phase-matching frequency bands. */ template<typename Real> class BandSplitterR { - Real coeff{0.0f}; - Real lp_z1{0.0f}; - Real lp_z2{0.0f}; - Real ap_z1{0.0f}; + Real mCoeff{0.0f}; + Real mLpZ1{0.0f}; + Real mLpZ2{0.0f}; + Real mApZ1{0.0f}; public: BandSplitterR() = default; @@ -18,7 +18,7 @@ public: BandSplitterR(Real f0norm) { init(f0norm); } void init(Real f0norm); - void clear() noexcept { lp_z1 = lp_z2 = ap_z1 = 0.0f; } + void clear() noexcept { mLpZ1 = mLpZ2 = mApZ1 = 0.0f; } void process(Real *hpout, Real *lpout, const Real *input, const size_t count); void applyHfScale(Real *samples, const Real hfscale, const size_t count); diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp index e20bf0a9..3d2f36ea 100644 --- a/alc/hrtf.cpp +++ b/alc/hrtf.cpp @@ -475,7 +475,7 @@ std::unique_ptr<HrtfEntry> CreateHrtfStore(ALuint rate, ALushort irSize, const A ERR("Out of memory allocating storage for %s.\n", filename); else { - InitRef(Hrtf->ref, 1u); + InitRef(Hrtf->mRef, 1u); Hrtf->sampleRate = rate; Hrtf->irSize = irSize; Hrtf->fdCount = fdCount; @@ -1362,13 +1362,13 @@ HrtfEntry *GetLoadedHrtf(HrtfHandle *handle) void HrtfEntry::IncRef() { - auto ref = IncrementRef(this->ref); + auto ref = IncrementRef(mRef); TRACE("HrtfEntry %p increasing refcount to %u\n", this, ref); } void HrtfEntry::DecRef() { - auto ref = DecrementRef(this->ref); + auto ref = DecrementRef(mRef); TRACE("HrtfEntry %p decreasing refcount to %u\n", this, ref); if(ref == 0) { @@ -1378,7 +1378,7 @@ void HrtfEntry::DecRef() auto delete_unused = [](HrtfHandlePtr &handle) -> void { HrtfEntry *entry{handle->entry.get()}; - if(entry && ReadRef(entry->ref) == 0) + if(entry && ReadRef(entry->mRef) == 0) { TRACE("Unloading unused HRTF %s\n", handle->filename.data()); handle->entry = nullptr; @@ -26,7 +26,7 @@ struct HrtfHandle; struct HrtfEntry { - RefCount ref; + RefCount mRef; ALuint sampleRate; ALuint irSize; diff --git a/alc/mixvoice.cpp b/alc/mixvoice.cpp index d7a32f35..2b5972f3 100644 --- a/alc/mixvoice.cpp +++ b/alc/mixvoice.cpp @@ -405,24 +405,24 @@ ALfloat *LoadBufferStatic(ALbufferlistitem *BufferListItem, ALbufferlistitem *&B BufferLoopItem = nullptr; /* Load what's left to play from the buffer */ - const size_t DataSize{minz(SrcBuffer.size(), Buffer->SampleLen-DataPosInt)}; + const size_t DataRem{minz(SrcBuffer.size(), Buffer->SampleLen-DataPosInt)}; const al::byte *Data{Buffer->mData.data()}; Data += (DataPosInt*NumChannels + chan)*SampleSize; - LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mFmtType, DataSize); - SrcBuffer = SrcBuffer.subspan(DataSize); + LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mFmtType, DataRem); + SrcBuffer = SrcBuffer.subspan(DataRem); } else { /* Load what's left of this loop iteration */ - const size_t DataSize{minz(SrcBuffer.size(), LoopEnd-DataPosInt)}; + const size_t DataRem{minz(SrcBuffer.size(), LoopEnd-DataPosInt)}; const al::byte *Data{Buffer->mData.data()}; Data += (DataPosInt*NumChannels + chan)*SampleSize; - LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mFmtType, DataSize); - SrcBuffer = SrcBuffer.subspan(DataSize); + LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mFmtType, DataRem); + SrcBuffer = SrcBuffer.subspan(DataRem); /* Load any repeats of the loop we can to fill the buffer. */ const auto LoopSize = static_cast<size_t>(LoopEnd - LoopStart); @@ -430,8 +430,7 @@ ALfloat *LoadBufferStatic(ALbufferlistitem *BufferListItem, ALbufferlistitem *&B { const size_t DataSize{minz(SrcBuffer.size(), LoopSize)}; - const al::byte *Data{Buffer->mData.data()}; - Data += (LoopStart*NumChannels + chan)*SampleSize; + Data = Buffer->mData.data() + (LoopStart*NumChannels + chan)*SampleSize; LoadSamples(SrcBuffer.data(), Data, NumChannels, Buffer->mFmtType, DataSize); SrcBuffer = SrcBuffer.subspan(DataSize); @@ -510,12 +509,14 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) for(ALuint chan{0};chan < NumChannels;chan++) { ChannelData &chandata = mChans[chan]; - DirectParams &parms = chandata.mDryParams; - if(!(mFlags&VOICE_HAS_HRTF)) - std::copy(std::begin(parms.Gains.Target), std::end(parms.Gains.Target), - std::begin(parms.Gains.Current)); - else - parms.Hrtf.Old = parms.Hrtf.Target; + { + DirectParams &parms = chandata.mDryParams; + if(!(mFlags&VOICE_HAS_HRTF)) + std::copy(std::begin(parms.Gains.Target), std::end(parms.Gains.Target), + std::begin(parms.Gains.Current)); + else + parms.Hrtf.Old = parms.Hrtf.Target; + } for(ALuint send{0};send < NumSends;++send) { if(mSend[send].Buffer.empty()) |