Make some local constexpr variables static

This commit is contained in:
Chris Robinson 2022-02-23 01:29:28 -08:00
parent 7176247529
commit cadf0d1de5
7 changed files with 33 additions and 39 deletions

View File

@ -761,7 +761,7 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq,
const ALuint ambiorder{IsBFormat(*DstChannels) ? ALBuf->UnpackAmbiOrder :
(IsUHJ(*DstChannels) ? 1 : 0)};
constexpr uint line_size{BufferLineSize + MaxPostVoiceLoad};
static constexpr uint line_size{BufferLineSize + MaxPostVoiceLoad};
al::vector<al::byte,16>(FrameSizeFromFmt(*DstChannels, *DstType, ambiorder) *
size_t{line_size}).swap(ALBuf->mData);

View File

@ -30,10 +30,10 @@ std::string EaxException::make_message(
return std::string{};
}
constexpr auto left_prefix = "[";
static constexpr char left_prefix[] = "[";
const auto left_prefix_size = std::string::traits_type::length(left_prefix);
constexpr auto right_prefix = "] ";
static constexpr char right_prefix[] = "] ";
const auto right_prefix_size = std::string::traits_type::length(right_prefix);
const auto what_size =

View File

@ -87,7 +87,7 @@ START_API_FUNC
ContextRef context{GetContextRef()};
if(unlikely(!context))
{
constexpr ALenum deferror{AL_INVALID_OPERATION};
static constexpr ALenum deferror{AL_INVALID_OPERATION};
WARN("Querying error state on null context (implicitly 0x%04x)\n", deferror);
if(TrapALError)
{

View File

@ -1268,23 +1268,17 @@ void alc_initconfig(void)
#ifdef ALSOFT_EAX
{
constexpr auto eax_block_name = "eax";
static constexpr char eax_block_name[] = "eax";
const auto eax_enable_opt = ConfigValueBool(nullptr, eax_block_name, "enable");
if (eax_enable_opt)
if(const auto eax_enable_opt = ConfigValueBool(nullptr, eax_block_name, "enable"))
{
eax_g_is_enabled = *eax_enable_opt;
if (!eax_g_is_enabled)
{
if(!eax_g_is_enabled)
TRACE("%s\n", "EAX disabled by a configuration.");
}
}
else
{
eax_g_is_enabled = true;
}
if(eax_g_is_enabled && DisabledEffects[EAXREVERB_EFFECT])
{
eax_g_is_enabled = false;
@ -1530,19 +1524,19 @@ void alcSetError(ALCdevice *device, ALCenum errorCode)
std::unique_ptr<Compressor> CreateDeviceLimiter(const ALCdevice *device, const float threshold)
{
constexpr bool AutoKnee{true};
constexpr bool AutoAttack{true};
constexpr bool AutoRelease{true};
constexpr bool AutoPostGain{true};
constexpr bool AutoDeclip{true};
constexpr float LookAheadTime{0.001f};
constexpr float HoldTime{0.002f};
constexpr float PreGainDb{0.0f};
constexpr float PostGainDb{0.0f};
constexpr float Ratio{std::numeric_limits<float>::infinity()};
constexpr float KneeDb{0.0f};
constexpr float AttackTime{0.02f};
constexpr float ReleaseTime{0.2f};
static constexpr bool AutoKnee{true};
static constexpr bool AutoAttack{true};
static constexpr bool AutoRelease{true};
static constexpr bool AutoPostGain{true};
static constexpr bool AutoDeclip{true};
static constexpr float LookAheadTime{0.001f};
static constexpr float HoldTime{0.002f};
static constexpr float PreGainDb{0.0f};
static constexpr float PostGainDb{0.0f};
static constexpr float Ratio{std::numeric_limits<float>::infinity()};
static constexpr float KneeDb{0.0f};
static constexpr float AttackTime{0.02f};
static constexpr float ReleaseTime{0.2f};
return Compressor::Create(device->RealOut.Buffer.size(), static_cast<float>(device->Frequency),
AutoKnee, AutoAttack, AutoRelease, AutoPostGain, AutoDeclip, LookAheadTime, HoldTime,
@ -2503,7 +2497,7 @@ static size_t GetIntegerv(ALCdevice *device, ALCenum param, const al::span<int>
std::lock_guard<std::mutex> _{device->StateLock};
if(device->Type == DeviceType::Capture)
{
constexpr int MaxCaptureAttributes{9};
static constexpr int MaxCaptureAttributes{9};
switch(param)
{
case ALC_ATTRIBUTES_SIZE:

View File

@ -504,8 +504,8 @@ inline float ScaleAzimuthFront(float azimuth, float scale)
/* Wraps the given value in radians to stay between [-pi,+pi] */
inline float WrapRadians(float r)
{
constexpr float Pi{al::numbers::pi_v<float>};
constexpr float Pi2{Pi*2.0f};
static constexpr float Pi{al::numbers::pi_v<float>};
static constexpr float Pi2{Pi*2.0f};
if(r > Pi) return std::fmod(Pi+r, Pi2) - Pi;
if(r < -Pi) return Pi - std::fmod(Pi-r, Pi2);
return r;
@ -1103,7 +1103,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con
/* If the source distance is 0, simulate a plane-wave by using
* infinite distance, which results in a w0 of 0.
*/
constexpr float w0{0.0f};
static constexpr float w0{0.0f};
for(size_t c{0};c < num_channels;c++)
voice->mChans[c].mDryParams.NFCtrlFilter.adjust(w0);
@ -1265,7 +1265,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBa
* decay distance (so it doesn't take any longer to decay
* than the air would allow).
*/
constexpr float log10_decaygain{-3.0f/*std::log10(ReverbDecayGain)*/};
static constexpr float log10_decaygain{-3.0f/*std::log10(ReverbDecayGain)*/};
const float absorb_dist{log10_decaygain / std::log10(airAbsorption)};
DecayDistance[i].HF = minf(absorb_dist, DecayDistance[i].HF);
}
@ -1383,7 +1383,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBa
/* Calculate directional soundcones */
if(directional && props->InnerAngle < 360.0f)
{
constexpr float Rad2Deg{static_cast<float>(180.0 / al::numbers::pi)};
static constexpr float Rad2Deg{static_cast<float>(180.0 / al::numbers::pi)};
const float Angle{Rad2Deg*2.0f * std::acos(-Direction.dot_product(ToSource)) * ConeScale};
float ConeGain, ConeHF;

View File

@ -142,9 +142,9 @@ void BackendBase::setDefaultChannelOrder()
#ifdef _WIN32
void BackendBase::setChannelOrderFromWFXMask(uint chanmask)
{
constexpr uint x51{SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
static constexpr uint x51{SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
| SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT};
constexpr uint x51rear{SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
static constexpr uint x51rear{SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER
| SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT};
/* Swap a 5.1 mask using the back channels for one with the sides. */
if(chanmask == x51rear) chanmask = x51;

View File

@ -99,10 +99,10 @@ constexpr std::enable_if_t<std::is_integral<T>::value && std::is_unsigned<T>::va
int> popcount(T val) noexcept
{
using fast_type = typename detail_::fast_utype<T>::type;
constexpr fast_type b01010101{detail_::repbits<fast_type>(0x55)};
constexpr fast_type b00110011{detail_::repbits<fast_type>(0x33)};
constexpr fast_type b00001111{detail_::repbits<fast_type>(0x0f)};
constexpr fast_type b00000001{detail_::repbits<fast_type>(0x01)};
static constexpr fast_type b01010101{detail_::repbits<fast_type>(0x55)};
static constexpr fast_type b00110011{detail_::repbits<fast_type>(0x33)};
static constexpr fast_type b00001111{detail_::repbits<fast_type>(0x0f)};
static constexpr fast_type b00000001{detail_::repbits<fast_type>(0x01)};
fast_type v{fast_type{val} - ((fast_type{val} >> 1) & b01010101)};
v = (v & b00110011) + ((v >> 2) & b00110011);