Skip to content

Commit

Permalink
Much more clang-tidy cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Dec 11, 2023
1 parent cf37d92 commit bb3387b
Show file tree
Hide file tree
Showing 53 changed files with 659 additions and 651 deletions.
40 changes: 20 additions & 20 deletions al/auxeffectslot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,31 @@ namespace {

struct FactoryItem {
EffectSlotType Type;
EffectStateFactory* (&GetFactory)(void);
EffectStateFactory* (&GetFactory)();
};
constexpr FactoryItem FactoryList[] = {
{ EffectSlotType::None, NullStateFactory_getFactory },
{ EffectSlotType::EAXReverb, ReverbStateFactory_getFactory },
{ EffectSlotType::Reverb, StdReverbStateFactory_getFactory },
{ EffectSlotType::Autowah, AutowahStateFactory_getFactory },
{ EffectSlotType::Chorus, ChorusStateFactory_getFactory },
{ EffectSlotType::Compressor, CompressorStateFactory_getFactory },
{ EffectSlotType::Distortion, DistortionStateFactory_getFactory },
{ EffectSlotType::Echo, EchoStateFactory_getFactory },
{ EffectSlotType::Equalizer, EqualizerStateFactory_getFactory },
{ EffectSlotType::Flanger, FlangerStateFactory_getFactory },
{ EffectSlotType::FrequencyShifter, FshifterStateFactory_getFactory },
{ EffectSlotType::RingModulator, ModulatorStateFactory_getFactory },
{ EffectSlotType::PitchShifter, PshifterStateFactory_getFactory },
{ EffectSlotType::VocalMorpher, VmorpherStateFactory_getFactory },
{ EffectSlotType::DedicatedDialog, DedicatedStateFactory_getFactory },
{ EffectSlotType::DedicatedLFE, DedicatedStateFactory_getFactory },
{ EffectSlotType::Convolution, ConvolutionStateFactory_getFactory },
constexpr std::array FactoryList{
FactoryItem{EffectSlotType::None, NullStateFactory_getFactory},
FactoryItem{EffectSlotType::EAXReverb, ReverbStateFactory_getFactory},
FactoryItem{EffectSlotType::Reverb, StdReverbStateFactory_getFactory},
FactoryItem{EffectSlotType::Autowah, AutowahStateFactory_getFactory},
FactoryItem{EffectSlotType::Chorus, ChorusStateFactory_getFactory},
FactoryItem{EffectSlotType::Compressor, CompressorStateFactory_getFactory},
FactoryItem{EffectSlotType::Distortion, DistortionStateFactory_getFactory},
FactoryItem{EffectSlotType::Echo, EchoStateFactory_getFactory},
FactoryItem{EffectSlotType::Equalizer, EqualizerStateFactory_getFactory},
FactoryItem{EffectSlotType::Flanger, FlangerStateFactory_getFactory},
FactoryItem{EffectSlotType::FrequencyShifter, FshifterStateFactory_getFactory},
FactoryItem{EffectSlotType::RingModulator, ModulatorStateFactory_getFactory},
FactoryItem{EffectSlotType::PitchShifter, PshifterStateFactory_getFactory},
FactoryItem{EffectSlotType::VocalMorpher, VmorpherStateFactory_getFactory},
FactoryItem{EffectSlotType::DedicatedDialog, DedicatedStateFactory_getFactory},
FactoryItem{EffectSlotType::DedicatedLFE, DedicatedStateFactory_getFactory},
FactoryItem{EffectSlotType::Convolution, ConvolutionStateFactory_getFactory},
};

EffectStateFactory *getFactoryByType(EffectSlotType type)
{
auto iter = std::find_if(std::begin(FactoryList), std::end(FactoryList),
auto iter = std::find_if(FactoryList.begin(), FactoryList.end(),
[type](const FactoryItem &item) noexcept -> bool
{ return item.Type == type; });
return (iter != std::end(FactoryList)) ? iter->GetFactory() : nullptr;
Expand Down
2 changes: 1 addition & 1 deletion al/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include <algorithm>
#include <array>
#include <cstddef>
#include <cstring>
#include <mutex>
#include <optional>
#include <stddef.h>
#include <stdexcept>
#include <string>
#include <utility>
Expand Down
3 changes: 1 addition & 2 deletions al/eax/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ EaxCall::EaxCall(
ALuint property_source_id,
ALvoid* property_buffer,
ALuint property_size)
: mCallType{type}, mVersion{0}, mPropertySetId{EaxCallPropertySetId::none}
, mIsDeferred{(property_id & deferred_flag) != 0}
: mCallType{type}, mIsDeferred{(property_id & deferred_flag) != 0}
, mPropertyId{property_id & ~deferred_flag}, mPropertySourceId{property_source_id}
, mPropertyBuffer{property_buffer}, mPropertyBufferSize{property_size}
{
Expand Down
14 changes: 7 additions & 7 deletions al/eax/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ class EaxCall {
}

private:
const EaxCallType mCallType{};
const EaxCallType mCallType;
int mVersion{};
EaxFxSlotIndex mFxSlotIndex{};
EaxCallPropertySetId mPropertySetId{};
bool mIsDeferred{};
EaxCallPropertySetId mPropertySetId{EaxCallPropertySetId::none};
bool mIsDeferred;

const ALuint mPropertyId{};
const ALuint mPropertySourceId{};
ALvoid*const mPropertyBuffer{};
const ALuint mPropertyBufferSize{};
const ALuint mPropertyId;
const ALuint mPropertySourceId;
ALvoid*const mPropertyBuffer;
const ALuint mPropertyBufferSize;

[[noreturn]] static void fail(const char* message);
[[noreturn]] static void fail_too_small();
Expand Down
47 changes: 24 additions & 23 deletions al/effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,24 @@ struct EffectPropsItem {
const EffectProps &DefaultProps;
const EffectVtable &Vtable;
};
constexpr EffectPropsItem EffectPropsList[] = {
{ AL_EFFECT_NULL, NullEffectProps, NullEffectVtable },
{ AL_EFFECT_EAXREVERB, ReverbEffectProps, ReverbEffectVtable },
{ AL_EFFECT_REVERB, StdReverbEffectProps, StdReverbEffectVtable },
{ AL_EFFECT_AUTOWAH, AutowahEffectProps, AutowahEffectVtable },
{ AL_EFFECT_CHORUS, ChorusEffectProps, ChorusEffectVtable },
{ AL_EFFECT_COMPRESSOR, CompressorEffectProps, CompressorEffectVtable },
{ AL_EFFECT_DISTORTION, DistortionEffectProps, DistortionEffectVtable },
{ AL_EFFECT_ECHO, EchoEffectProps, EchoEffectVtable },
{ AL_EFFECT_EQUALIZER, EqualizerEffectProps, EqualizerEffectVtable },
{ AL_EFFECT_FLANGER, FlangerEffectProps, FlangerEffectVtable },
{ AL_EFFECT_FREQUENCY_SHIFTER, FshifterEffectProps, FshifterEffectVtable },
{ AL_EFFECT_RING_MODULATOR, ModulatorEffectProps, ModulatorEffectVtable },
{ AL_EFFECT_PITCH_SHIFTER, PshifterEffectProps, PshifterEffectVtable },
{ AL_EFFECT_VOCAL_MORPHER, VmorpherEffectProps, VmorpherEffectVtable },
{ AL_EFFECT_DEDICATED_DIALOGUE, DedicatedEffectProps, DedicatedEffectVtable },
{ AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, DedicatedEffectProps, DedicatedEffectVtable },
{ AL_EFFECT_CONVOLUTION_SOFT, ConvolutionEffectProps, ConvolutionEffectVtable },
constexpr std::array EffectPropsList{
EffectPropsItem{AL_EFFECT_NULL, NullEffectProps, NullEffectVtable},
EffectPropsItem{AL_EFFECT_EAXREVERB, ReverbEffectProps, ReverbEffectVtable},
EffectPropsItem{AL_EFFECT_REVERB, StdReverbEffectProps, StdReverbEffectVtable},
EffectPropsItem{AL_EFFECT_AUTOWAH, AutowahEffectProps, AutowahEffectVtable},
EffectPropsItem{AL_EFFECT_CHORUS, ChorusEffectProps, ChorusEffectVtable},
EffectPropsItem{AL_EFFECT_COMPRESSOR, CompressorEffectProps, CompressorEffectVtable},
EffectPropsItem{AL_EFFECT_DISTORTION, DistortionEffectProps, DistortionEffectVtable},
EffectPropsItem{AL_EFFECT_ECHO, EchoEffectProps, EchoEffectVtable},
EffectPropsItem{AL_EFFECT_EQUALIZER, EqualizerEffectProps, EqualizerEffectVtable},
EffectPropsItem{AL_EFFECT_FLANGER, FlangerEffectProps, FlangerEffectVtable},
EffectPropsItem{AL_EFFECT_FREQUENCY_SHIFTER, FshifterEffectProps, FshifterEffectVtable},
EffectPropsItem{AL_EFFECT_RING_MODULATOR, ModulatorEffectProps, ModulatorEffectVtable},
EffectPropsItem{AL_EFFECT_PITCH_SHIFTER, PshifterEffectProps, PshifterEffectVtable},
EffectPropsItem{AL_EFFECT_VOCAL_MORPHER, VmorpherEffectProps, VmorpherEffectVtable},
EffectPropsItem{AL_EFFECT_DEDICATED_DIALOGUE, DedicatedEffectProps, DedicatedEffectVtable},
EffectPropsItem{AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, DedicatedEffectProps, DedicatedEffectVtable},
EffectPropsItem{AL_EFFECT_CONVOLUTION_SOFT, ConvolutionEffectProps, ConvolutionEffectVtable},
};


Expand All @@ -136,7 +136,7 @@ void ALeffect_getParamfv(const ALeffect *effect, ALenum param, float *values)

const EffectPropsItem *getEffectPropsItemByType(ALenum type)
{
auto iter = std::find_if(std::begin(EffectPropsList), std::end(EffectPropsList),
auto iter = std::find_if(EffectPropsList.begin(), EffectPropsList.end(),
[type](const EffectPropsItem &item) noexcept -> bool
{ return item.Type == type; });
return (iter != std::end(EffectPropsList)) ? al::to_address(iter) : nullptr;
Expand Down Expand Up @@ -542,11 +542,12 @@ EffectSubList::~EffectSubList()
}


#define DECL(x) { #x, EFX_REVERB_PRESET_##x }
static const struct {
const char name[32];
struct EffectPreset {
const char name[32]; /* NOLINT(*-avoid-c-arrays) */
EFXEAXREVERBPROPERTIES props;
} reverblist[] = {
};
#define DECL(x) EffectPreset{#x, EFX_REVERB_PRESET_##x}
static constexpr std::array reverblist{
DECL(GENERIC),
DECL(PADDEDCELL),
DECL(ROOM),
Expand Down
2 changes: 1 addition & 1 deletion al/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class filter_exception final : public al::base_exception {
filter_exception(ALenum code, const char *msg, ...);
~filter_exception() override;

ALenum errorCode() const noexcept { return mErrorCode; }
[[nodiscard]] auto errorCode() const noexcept -> ALenum { return mErrorCode; }
};

filter_exception::filter_exception(ALenum code, const char* msg, ...) : mErrorCode{code}
Expand Down
2 changes: 2 additions & 0 deletions al/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

namespace {

/* NOLINTBEGIN(*-avoid-c-arrays) */
constexpr ALchar alVendor[] = "OpenAL Community";
constexpr ALchar alVersion[] = "1.1 ALSOFT " ALSOFT_VERSION;
constexpr ALchar alRenderer[] = "OpenAL Soft";
Expand All @@ -73,6 +74,7 @@ constexpr ALchar alErrInvalidOp[] = "Invalid Operation";
constexpr ALchar alErrOutOfMemory[] = "Out of Memory";
constexpr ALchar alStackOverflow[] = "Stack Overflow";
constexpr ALchar alStackUnderflow[] = "Stack Underflow";
/* NOLINTEND(*-avoid-c-arrays) */

/* Resampler strings */
template<Resampler rtype> struct ResamplerName { };
Expand Down
1 change: 1 addition & 0 deletions alc/backends/null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ using std::chrono::seconds;
using std::chrono::milliseconds;
using std::chrono::nanoseconds;

/* NOLINTNEXTLINE(*-avoid-c-arrays) */
constexpr char nullDevice[] = "No Output";


Expand Down
12 changes: 5 additions & 7 deletions alc/backends/pipewire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,8 +1420,7 @@ class PipeWirePlayback final : public BackendBase {
PwStreamPtr mStream;
spa_hook mStreamListener{};
spa_io_rate_match *mRateMatch{};
std::unique_ptr<float*[]> mChannelPtrs;
uint mNumChannels{};
std::vector<float*> mChannelPtrs;

static constexpr pw_stream_events CreateEvents()
{
Expand Down Expand Up @@ -1468,7 +1467,7 @@ void PipeWirePlayback::outputCallback() noexcept
if(!pw_buf) UNLIKELY return;

const al::span<spa_data> datas{pw_buf->buffer->datas,
minu(mNumChannels, pw_buf->buffer->n_datas)};
minz(mChannelPtrs.size(), pw_buf->buffer->n_datas)};
#if PW_CHECK_VERSION(0,3,49)
/* In 0.3.49, pw_buffer::requested specifies the number of samples needed
* by the resampler/graph for this audio update.
Expand All @@ -1488,7 +1487,7 @@ void PipeWirePlayback::outputCallback() noexcept
* buffer length in any one channel is smaller than we wanted (shouldn't
* be, but just in case).
*/
float **chanptr_end{mChannelPtrs.get()};
auto chanptr_end = mChannelPtrs.begin();
for(const auto &data : datas)
{
length = minu(length, data.maxsize/sizeof(float));
Expand All @@ -1500,7 +1499,7 @@ void PipeWirePlayback::outputCallback() noexcept
data.chunk->size = length * sizeof(float);
}

mDevice->renderSamples({mChannelPtrs.get(), chanptr_end}, length);
mDevice->renderSamples(mChannelPtrs, length);

pw_buf->size = length;
pw_stream_queue_buffer(mStream.get(), pw_buf);
Expand Down Expand Up @@ -1711,8 +1710,7 @@ bool PipeWirePlayback::reset()
*/
plock.unlock();

mNumChannels = mDevice->channelsFromFmt();
mChannelPtrs = std::make_unique<float*[]>(mNumChannels);
mChannelPtrs.resize(mDevice->channelsFromFmt());

setDefaultWFXChannelOrder();

Expand Down
3 changes: 2 additions & 1 deletion alc/backends/portaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@

namespace {

constexpr char pa_device[] = "PortAudio Default";
/* NOLINTNEXTLINE(*-avoid-c-arrays) */
constexpr char pa_device[]{"PortAudio Default"};


#ifdef HAVE_DYNLOAD
Expand Down
3 changes: 2 additions & 1 deletion alc/backends/sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ namespace {
#define DEVNAME_PREFIX ""
#endif

constexpr char defaultDeviceName[] = DEVNAME_PREFIX "Default Device";
/* NOLINTNEXTLINE(*-avoid-c-arrays) */
constexpr char defaultDeviceName[]{DEVNAME_PREFIX "Default Device"};

struct Sdl2Backend final : public BackendBase {
Sdl2Backend(DeviceBase *device) noexcept : BackendBase{device} { }
Expand Down
2 changes: 1 addition & 1 deletion alc/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

#include <algorithm>
#include <array>
#include <cstddef>
#include <cstring>
#include <functional>
#include <limits>
#include <numeric>
#include <stddef.h>
#include <stdexcept>
#include <string_view>
#include <utility>
Expand Down
2 changes: 1 addition & 1 deletion alc/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include "device.h"

#include <cstddef>
#include <numeric>
#include <stddef.h>

#include "albit.h"
#include "alconfig.h"
Expand Down
2 changes: 1 addition & 1 deletion alc/effects/convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <array>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <iterator>
#include <memory>
#include <stdint.h>
#include <utility>

#ifdef HAVE_SSE_INTRINSICS
Expand Down
2 changes: 1 addition & 1 deletion alc/effects/null.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#include "config.h"

#include <stddef.h>
#include <cstddef>

#include "almalloc.h"
#include "alspan.h"
Expand Down
Loading

0 comments on commit bb3387b

Please sign in to comment.