aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-12-08 10:11:08 -0800
committerChris Robinson <[email protected]>2023-12-08 10:11:08 -0800
commit040c172cdf186c9ccfb0642aa9ac598f115bb46b (patch)
tree0aaefde29bb9151042933f97f914946e007047e7 /alc
parent4527b873788373edb630046b0ab586255aa15e44 (diff)
Clean up some more clang-tidy warnings
Diffstat (limited to 'alc')
-rw-r--r--alc/alc.cpp42
-rw-r--r--alc/alu.cpp21
-rw-r--r--alc/backends/base.h2
-rw-r--r--alc/backends/jack.cpp6
-rw-r--r--alc/backends/opensl.cpp2
-rw-r--r--alc/backends/pipewire.cpp6
-rw-r--r--alc/context.cpp2
-rw-r--r--alc/effects/convolution.cpp10
-rw-r--r--alc/effects/dedicated.cpp8
-rw-r--r--alc/panning.cpp16
10 files changed, 58 insertions, 57 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp
index 1ceae5ee..62f798f2 100644
--- a/alc/alc.cpp
+++ b/alc/alc.cpp
@@ -1008,8 +1008,8 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
std::optional<DevFmtType> opttype;
std::optional<DevAmbiLayout> optlayout;
std::optional<DevAmbiScaling> optscale;
- uint period_size{DEFAULT_UPDATE_SIZE};
- uint buffer_size{DEFAULT_UPDATE_SIZE * DEFAULT_NUM_UPDATES};
+ uint period_size{DefaultUpdateSize};
+ uint buffer_size{DefaultUpdateSize * DefaultNumUpdates};
int hrtf_id{-1};
uint aorder{0u};
@@ -1019,9 +1019,9 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
if(auto freqopt = device->configValue<uint>(nullptr, "frequency"))
{
- optsrate = clampu(*freqopt, MIN_OUTPUT_RATE, MAX_OUTPUT_RATE);
+ optsrate = clampu(*freqopt, MinOutputRate, MaxOutputRate);
- const double scale{static_cast<double>(*optsrate) / DEFAULT_OUTPUT_RATE};
+ const double scale{static_cast<double>(*optsrate) / double{DefaultOutputRate}};
period_size = static_cast<uint>(period_size*scale + 0.5);
}
@@ -1030,7 +1030,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
if(auto numperopt = device->configValue<uint>(nullptr, "periods"))
buffer_size = clampu(*numperopt, 2, 16) * period_size;
else
- buffer_size = period_size * DEFAULT_NUM_UPDATES;
+ buffer_size = period_size * uint{DefaultNumUpdates};
if(auto typeopt = device->configValue<std::string>(nullptr, "sample-type"))
{
@@ -1201,7 +1201,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
case ATTRIBUTE(ALC_MAX_AUXILIARY_SENDS)
numSends = static_cast<uint>(attrList[attrIdx + 1]);
if(numSends > INT_MAX) numSends = 0;
- else numSends = minu(numSends, MAX_SENDS);
+ else numSends = minu(numSends, MaxSendCount);
break;
case ATTRIBUTE(ALC_HRTF_SOFT)
@@ -1244,7 +1244,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
{
if(!optchans || !opttype)
return ALC_INVALID_VALUE;
- if(freqAttr < MIN_OUTPUT_RATE || freqAttr > MAX_OUTPUT_RATE)
+ if(freqAttr < int{MinOutputRate} || freqAttr > int{MaxOutputRate})
return ALC_INVALID_VALUE;
if(*optchans == DevFmtAmbi3D)
{
@@ -1321,8 +1321,8 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
if(freqAttr)
{
- uint oldrate = optsrate.value_or(DEFAULT_OUTPUT_RATE);
- freqAttr = clampi(freqAttr, MIN_OUTPUT_RATE, MAX_OUTPUT_RATE);
+ uint oldrate = optsrate.value_or(DefaultOutputRate);
+ freqAttr = clampi(freqAttr, MinOutputRate, MaxOutputRate);
const double scale{static_cast<double>(freqAttr) / oldrate};
period_size = static_cast<uint>(period_size*scale + 0.5);
@@ -1397,7 +1397,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
device->mAmbiOrder = 0;
device->BufferSize = buffer_size;
device->UpdateSize = period_size;
- device->Frequency = optsrate.value_or(DEFAULT_OUTPUT_RATE);
+ device->Frequency = optsrate.value_or(DefaultOutputRate);
device->Flags.set(FrequencyRequest, optsrate.has_value())
.set(ChannelsRequest, optchans.has_value())
.set(SampleTypeRequest, opttype.has_value());
@@ -1500,7 +1500,7 @@ ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList)
device->NumStereoSources = numStereo;
if(auto sendsopt = device->configValue<int>(nullptr, "sends"))
- numSends = minu(numSends, static_cast<uint>(clampi(*sendsopt, 0, MAX_SENDS)));
+ numSends = minu(numSends, static_cast<uint>(clampi(*sendsopt, 0, MaxSendCount)));
device->NumAuxSends = numSends;
TRACE("Max sources: %d (%d + %d), effect slots: %d, sends: %d\n",
@@ -1781,7 +1781,7 @@ bool ResetDeviceParams(ALCdevice *device, const int *attrList)
if(!device->Connected.load(std::memory_order_relaxed)) UNLIKELY
{
/* Make sure disconnection is finished before continuing on. */
- device->waitForMix();
+ std::ignore = device->waitForMix();
for(ContextBase *ctxbase : *device->mContexts.load(std::memory_order_acquire))
{
@@ -2101,7 +2101,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int>
values[0] = alcEFXMinorVersion;
return 1;
case ALC_MAX_AUXILIARY_SENDS:
- values[0] = MAX_SENDS;
+ values[0] = MaxSendCount;
return 1;
case ALC_ATTRIBUTES_SIZE:
@@ -2720,7 +2720,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
dev->mContexts.store(newarray.release());
if(oldarray != &DeviceBase::sEmptyContextArray)
{
- dev->waitForMix();
+ std::ignore = dev->waitForMix();
delete oldarray;
}
}
@@ -2892,7 +2892,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) noexcep
#ifdef ALSOFT_EAX
eax_g_is_enabled ? uint{EAX_MAX_FXSLOTS} :
#endif // ALSOFT_EAX
- DEFAULT_SENDS
+ uint{DefaultSendCount}
};
DeviceRef device{new ALCdevice{DeviceType::Playback}};
@@ -2900,9 +2900,9 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) noexcep
/* Set output format */
device->FmtChans = DevFmtChannelsDefault;
device->FmtType = DevFmtTypeDefault;
- device->Frequency = DEFAULT_OUTPUT_RATE;
- device->UpdateSize = DEFAULT_UPDATE_SIZE;
- device->BufferSize = DEFAULT_UPDATE_SIZE * DEFAULT_NUM_UPDATES;
+ device->Frequency = DefaultOutputRate;
+ device->UpdateSize = DefaultUpdateSize;
+ device->BufferSize = DefaultUpdateSize * DefaultNumUpdates;
device->SourcesMax = 256;
device->NumStereoSources = 1;
@@ -3199,7 +3199,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN
#ifdef ALSOFT_EAX
eax_g_is_enabled ? uint{EAX_MAX_FXSLOTS} :
#endif // ALSOFT_EAX
- DEFAULT_SENDS
+ uint{DefaultSendCount}
};
DeviceRef device{new ALCdevice{DeviceType::Loopback}};
@@ -3212,7 +3212,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN
device->BufferSize = 0;
device->UpdateSize = 0;
- device->Frequency = DEFAULT_OUTPUT_RATE;
+ device->Frequency = DefaultOutputRate;
device->FmtChans = DevFmtChannelsDefault;
device->FmtType = DevFmtTypeDefault;
@@ -3255,7 +3255,7 @@ ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device
else
{
if(DevFmtTypeFromEnum(type).has_value() && DevFmtChannelsFromEnum(channels).has_value()
- && freq >= MIN_OUTPUT_RATE && freq <= MAX_OUTPUT_RATE)
+ && freq >= int{MinOutputRate} && freq <= int{MaxOutputRate})
return ALC_TRUE;
}
diff --git a/alc/alu.cpp b/alc/alu.cpp
index fe47f9be..0a5dabc9 100644
--- a/alc/alu.cpp
+++ b/alc/alu.cpp
@@ -282,7 +282,7 @@ void DeviceBase::ProcessHrtf(const size_t SamplesToDo)
const size_t lidx{RealOut.ChannelIndex[FrontLeft]};
const size_t ridx{RealOut.ChannelIndex[FrontRight]};
- MixDirectHrtf(RealOut.Buffer[lidx], RealOut.Buffer[ridx], Dry.Buffer, HrtfAccumData,
+ MixDirectHrtf(RealOut.Buffer[lidx], RealOut.Buffer[ridx], Dry.Buffer, HrtfAccumData.data(),
mHrtfState->mTemp.data(), mHrtfState->mChannels.data(), mHrtfState->mIrSize, SamplesToDo);
}
@@ -776,8 +776,8 @@ struct GainTriplet { float Base, HF, LF; };
void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, const float zpos,
const float Distance, const float Spread, const GainTriplet &DryGain,
- const al::span<const GainTriplet,MAX_SENDS> WetGain,
- const al::span<EffectSlot*,MAX_SENDS> SendSlots, const VoiceProps *props,
+ const al::span<const GainTriplet,MaxSendCount> WetGain,
+ const al::span<EffectSlot*,MaxSendCount> SendSlots, const VoiceProps *props,
const ContextParams &Context, DeviceBase *Device)
{
static constexpr ChanPosMap MonoMap[1]{
@@ -1397,7 +1397,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con
void CalcNonAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBase *context)
{
DeviceBase *Device{context->mDevice};
- EffectSlot *SendSlots[MAX_SENDS];
+ std::array<EffectSlot*,MaxSendCount> SendSlots;
voice->mDirect.Buffer = Device->Dry.Buffer;
for(uint i{0};i < Device->NumAuxSends;i++)
@@ -1427,7 +1427,8 @@ void CalcNonAttnSourceParams(Voice *voice, const VoiceProps *props, const Contex
context->mParams.Gain, GainMixMax);
DryGain.HF = props->Direct.GainHF;
DryGain.LF = props->Direct.GainLF;
- GainTriplet WetGain[MAX_SENDS];
+
+ std::array<GainTriplet,MaxSendCount> WetGain;
for(uint i{0};i < Device->NumAuxSends;i++)
{
WetGain[i].Base = minf(clampf(props->Gain, props->MinGain, props->MaxGain) *
@@ -1447,9 +1448,9 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBa
/* Set mixing buffers and get send parameters. */
voice->mDirect.Buffer = Device->Dry.Buffer;
- std::array<EffectSlot*,MAX_SENDS> SendSlots{};
- std::array<float,MAX_SENDS> RoomRolloff{};
- std::bitset<MAX_SENDS> UseDryAttnForRoom{0};
+ std::array<EffectSlot*,MaxSendCount> SendSlots{};
+ std::array<float,MaxSendCount> RoomRolloff{};
+ std::bitset<MaxSendCount> UseDryAttnForRoom{0};
for(uint i{0};i < NumSends;i++)
{
SendSlots[i] = props->Send[i].Slot;
@@ -1502,7 +1503,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBa
/* Calculate distance attenuation */
float ClampedDist{Distance};
float DryGainBase{props->Gain};
- std::array<float,MAX_SENDS> WetGainBase{};
+ std::array<float,MaxSendCount> WetGainBase{};
WetGainBase.fill(props->Gain);
float DryAttnBase{1.0f};
@@ -1605,7 +1606,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBa
DryGain.HF = ConeHF * props->Direct.GainHF;
DryGain.LF = props->Direct.GainLF;
- std::array<GainTriplet,MAX_SENDS> WetGain{};
+ std::array<GainTriplet,MaxSendCount> WetGain{};
for(uint i{0};i < NumSends;i++)
{
WetGainBase[i] = clampf(WetGainBase[i]*WetCone, props->MinGain, props->MaxGain) *
diff --git a/alc/backends/base.h b/alc/backends/base.h
index 70f96275..ecca6b2e 100644
--- a/alc/backends/base.h
+++ b/alc/backends/base.h
@@ -99,7 +99,7 @@ public:
backend_exception(backend_error code, const char *msg, ...);
~backend_exception() override;
- backend_error errorCode() const noexcept { return mErrorCode; }
+ [[nodiscard]] auto errorCode() const noexcept -> backend_error { return mErrorCode; }
};
} // namespace al
diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp
index 4999a738..ca862276 100644
--- a/alc/backends/jack.cpp
+++ b/alc/backends/jack.cpp
@@ -307,7 +307,7 @@ struct JackPlayback final : public BackendBase {
std::string mPortPattern;
jack_client_t *mClient{nullptr};
- std::array<jack_port_t*,MAX_OUTPUT_CHANNELS> mPort{};
+ std::array<jack_port_t*,MaxOutputChannels> mPort{};
std::mutex mMutex;
@@ -339,7 +339,7 @@ JackPlayback::~JackPlayback()
int JackPlayback::processRt(jack_nframes_t numframes) noexcept
{
- std::array<jack_default_audio_sample_t*,MAX_OUTPUT_CHANNELS> out;
+ std::array<jack_default_audio_sample_t*,MaxOutputChannels> out;
size_t numchans{0};
for(auto port : mPort)
{
@@ -363,7 +363,7 @@ int JackPlayback::processRt(jack_nframes_t numframes) noexcept
int JackPlayback::process(jack_nframes_t numframes) noexcept
{
- std::array<jack_default_audio_sample_t*,MAX_OUTPUT_CHANNELS> out;
+ std::array<jack_default_audio_sample_t*,MaxOutputChannels> out;
size_t numchans{0};
for(auto port : mPort)
{
diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp
index 32745edd..f49b2ef8 100644
--- a/alc/backends/opensl.cpp
+++ b/alc/backends/opensl.cpp
@@ -439,7 +439,7 @@ bool OpenSLPlayback::reset()
JCALL(env,ReleaseStringUTFChars)(srateStr, strchars);
if(!sampleRate) sampleRate = device->Frequency;
- else sampleRate = maxu(sampleRate, MIN_OUTPUT_RATE);
+ else sampleRate = maxu(sampleRate, MinOutputRate);
}
#endif
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index 96b6623f..ca7e3cf3 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -831,7 +831,7 @@ void DeviceNode::parseSampleRate(const spa_pod *value, bool force_update) noexce
/* [0] is the default, [1] is the min, and [2] is the max. */
TRACE(" sample rate: %d (range: %d -> %d)\n", srates[0], srates[1], srates[2]);
if(!mSampleRate || force_update)
- mSampleRate = static_cast<uint>(clampi(srates[0], MIN_OUTPUT_RATE, MAX_OUTPUT_RATE));
+ mSampleRate = static_cast<uint>(clampi(srates[0], MinOutputRate, MaxOutputRate));
return;
}
@@ -857,7 +857,7 @@ void DeviceNode::parseSampleRate(const spa_pod *value, bool force_update) noexce
*/
for(const auto &rate : srates)
{
- if(rate >= MIN_OUTPUT_RATE && rate <= MAX_OUTPUT_RATE)
+ if(rate >= int{MinOutputRate} && rate <= int{MaxOutputRate})
{
if(!mSampleRate || force_update)
mSampleRate = static_cast<uint>(rate);
@@ -878,7 +878,7 @@ void DeviceNode::parseSampleRate(const spa_pod *value, bool force_update) noexce
TRACE(" sample rate: %d\n", srates[0]);
if(!mSampleRate || force_update)
- mSampleRate = static_cast<uint>(clampi(srates[0], MIN_OUTPUT_RATE, MAX_OUTPUT_RATE));
+ mSampleRate = static_cast<uint>(clampi(srates[0], MinOutputRate, MaxOutputRate));
return;
}
diff --git a/alc/context.cpp b/alc/context.cpp
index ffc2743e..4e962469 100644
--- a/alc/context.cpp
+++ b/alc/context.cpp
@@ -276,7 +276,7 @@ bool ALCcontext::deinit()
mDevice->mContexts.store(newarray);
if(oldarray != &DeviceBase::sEmptyContextArray)
{
- mDevice->waitForMix();
+ std::ignore = mDevice->waitForMix();
delete oldarray;
}
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index 517e6b08..8db7a045 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -218,8 +218,8 @@ struct ConvolutionState final : public EffectState {
alignas(16) FloatBufferLine mBuffer{};
float mHfScale{}, mLfScale{};
BandSplitter mFilter{};
- float Current[MAX_OUTPUT_CHANNELS]{};
- float Target[MAX_OUTPUT_CHANNELS]{};
+ std::array<float,MaxOutputChannels> Current{};
+ std::array<float,MaxOutputChannels> Target{};
};
std::vector<ChannelData> mChans;
al::vector<float,16> mComplexData;
@@ -246,8 +246,8 @@ void ConvolutionState::NormalMix(const al::span<FloatBufferLine> samplesOut,
const size_t samplesToDo)
{
for(auto &chan : mChans)
- MixSamples({chan.mBuffer.data(), samplesToDo}, samplesOut, chan.Current, chan.Target,
- samplesToDo, 0);
+ MixSamples({chan.mBuffer.data(), samplesToDo}, samplesOut, chan.Current.data(),
+ chan.Target.data(), samplesToDo, 0);
}
void ConvolutionState::UpsampleMix(const al::span<FloatBufferLine> samplesOut,
@@ -257,7 +257,7 @@ void ConvolutionState::UpsampleMix(const al::span<FloatBufferLine> samplesOut,
{
const al::span<float> src{chan.mBuffer.data(), samplesToDo};
chan.mFilter.processScale(src, chan.mHfScale, chan.mLfScale);
- MixSamples(src, samplesOut, chan.Current, chan.Target, samplesToDo, 0);
+ MixSamples(src, samplesOut, chan.Current.data(), chan.Target.data(), samplesToDo, 0);
}
}
diff --git a/alc/effects/dedicated.cpp b/alc/effects/dedicated.cpp
index a9131bfa..69e70847 100644
--- a/alc/effects/dedicated.cpp
+++ b/alc/effects/dedicated.cpp
@@ -47,8 +47,8 @@ struct DedicatedState final : public EffectState {
* gains for all possible output channels and not just the main ambisonic
* buffer.
*/
- float mCurrentGains[MAX_OUTPUT_CHANNELS];
- float mTargetGains[MAX_OUTPUT_CHANNELS];
+ std::array<float,MaxOutputChannels> mCurrentGains;
+ std::array<float,MaxOutputChannels> mTargetGains;
void deviceUpdate(const DeviceBase *device, const BufferStorage *buffer) override;
@@ -104,8 +104,8 @@ void DedicatedState::update(const ContextBase*, const EffectSlot *slot,
void DedicatedState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
{
- MixSamples({samplesIn[0].data(), samplesToDo}, samplesOut, mCurrentGains, mTargetGains,
- samplesToDo, 0);
+ MixSamples({samplesIn[0].data(), samplesToDo}, samplesOut, mCurrentGains.data(),
+ mTargetGains.data(), samplesToDo, 0);
}
diff --git a/alc/panning.cpp b/alc/panning.cpp
index b512a42a..93ebee73 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -249,7 +249,7 @@ void InitNearFieldCtrl(ALCdevice *device, float ctrl_dist, uint order, bool is3d
}
void InitDistanceComp(ALCdevice *device, const al::span<const Channel> channels,
- const al::span<const float,MAX_OUTPUT_CHANNELS> dists)
+ const al::span<const float,MaxOutputChannels> dists)
{
const float maxdist{std::accumulate(std::begin(dists), std::end(dists), 0.0f, maxf)};
@@ -329,7 +329,7 @@ constexpr auto GetAmbiLayout(DevAmbiLayout layouttype) noexcept
DecoderView MakeDecoderView(ALCdevice *device, const AmbDecConf *conf,
- DecoderConfig<DualBand, MAX_OUTPUT_CHANNELS> &decoder)
+ DecoderConfig<DualBand,MaxOutputChannels> &decoder)
{
DecoderView ret{};
@@ -969,9 +969,9 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optional<StereoEncodin
break;
}
- std::unique_ptr<DecoderConfig<DualBand,MAX_OUTPUT_CHANNELS>> decoder_store;
+ std::unique_ptr<DecoderConfig<DualBand,MaxOutputChannels>> decoder_store;
DecoderView decoder{};
- float speakerdists[MAX_OUTPUT_CHANNELS]{};
+ std::array<float,MaxOutputChannels> speakerdists{};
auto load_config = [device,&decoder_store,&decoder,&speakerdists](const char *config)
{
AmbDecConf conf{};
@@ -981,10 +981,10 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optional<StereoEncodin
ERR(" %s\n", err->c_str());
return false;
}
- else if(conf.NumSpeakers > MAX_OUTPUT_CHANNELS)
+ else if(conf.NumSpeakers > MaxOutputChannels)
{
- ERR("Unsupported decoder speaker count %zu (max %d)\n", conf.NumSpeakers,
- MAX_OUTPUT_CHANNELS);
+ ERR("Unsupported decoder speaker count %zu (max %zu)\n", conf.NumSpeakers,
+ MaxOutputChannels);
return false;
}
else if(conf.ChanMask > Ambi3OrderMask)
@@ -998,7 +998,7 @@ void aluInitRenderer(ALCdevice *device, int hrtf_id, std::optional<StereoEncodin
conf.Description.c_str());
device->mXOverFreq = clampf(conf.XOverFreq, 100.0f, 1000.0f);
- decoder_store = std::make_unique<DecoderConfig<DualBand,MAX_OUTPUT_CHANNELS>>();
+ decoder_store = std::make_unique<DecoderConfig<DualBand,MaxOutputChannels>>();
decoder = MakeDecoderView(device, &conf, *decoder_store);
for(size_t i{0};i < decoder.mChannels.size();++i)
speakerdists[i] = conf.Speakers[i].Distance;