diff options
author | tcoyvwac <53616399+tcoyvwac@users.noreply.github.com> | 2021-09-27 01:09:55 +0200 |
---|---|---|
committer | tcoyvwac <53616399+tcoyvwac@users.noreply.github.com> | 2021-09-27 04:53:27 +0200 |
commit | edf209a016b202ca4322c2d62d73c21cc61a7f0f (patch) | |
tree | f39eac99b60dff73881ee992460d8f5c85e5f184 /src/engine | |
parent | 3926fde35a0c5932fd15bb98c150a4c58dc36d92 (diff) |
Promote simple const variables to constexpr
Diffstat (limited to 'src/engine')
23 files changed, 34 insertions, 35 deletions
diff --git a/src/engine/bufferscalers/enginebufferscalelinear.h b/src/engine/bufferscalers/enginebufferscalelinear.h index a27c11f7be..4d7b989c29 100644 --- a/src/engine/bufferscalers/enginebufferscalelinear.h +++ b/src/engine/bufferscalers/enginebufferscalelinear.h @@ -4,7 +4,7 @@ #include "engine/readaheadmanager.h" /** Number of samples to read ahead */ -const int kiLinearScaleReadAheadLength = 10240; +constexpr int kiLinearScaleReadAheadLength = 10240; class EngineBufferScaleLinear : public EngineBufferScale { diff --git a/src/engine/bufferscalers/enginebufferscalerubberband.cpp b/src/engine/bufferscalers/enginebufferscalerubberband.cpp index e1b5f02542..45bd55ff92 100644 --- a/src/engine/bufferscalers/enginebufferscalerubberband.cpp +++ b/src/engine/bufferscalers/enginebufferscalerubberband.cpp @@ -54,7 +54,7 @@ void EngineBufferScaleRubberBand::setScaleParameters(double base_rate, // References: // https://bugs.launchpad.net/ubuntu/+bug/1263233 // https://bitbucket.org/breakfastquay/rubberband/issue/4/sigfpe-zero-division-with-high-time-ratios - const double kMinSeekSpeed = 1.0 / 128.0; + constexpr double kMinSeekSpeed = 1.0 / 128.0; double speed_abs = fabs(*pTempoRatio); if (speed_abs < kMinSeekSpeed) { // Let the caller know we ignored their speed. diff --git a/src/engine/bufferscalers/enginebufferscalest.cpp b/src/engine/bufferscalers/enginebufferscalest.cpp index f23aa4b936..b5966a8e96 100644 --- a/src/engine/bufferscalers/enginebufferscalest.cpp +++ b/src/engine/bufferscalers/enginebufferscalest.cpp @@ -22,7 +22,7 @@ namespace { // 0.918 (upscaling 44.1 kHz to 48 kHz) will produce an additional offset of 3 Frames // 0.459 (upscaling 44.1 kHz to 96 kHz) will produce an additional offset of 18 Frames // (Rubberband does not suffer this issue) -const SINT kSeekOffsetFrames = 519; +constexpr SINT kSeekOffsetFrames = 519; } // namespace diff --git a/src/engine/cachingreader/cachingreader.cpp b/src/engine/cachingreader/cachingreader.cpp index 91a8e940ee..550228a7fa 100644 --- a/src/engine/cachingreader/cachingreader.cpp +++ b/src/engine/cachingreader/cachingreader.cpp @@ -20,7 +20,7 @@ mixxx::Logger kLogger("CachingReader"); // This is the default hint frameCount that is adopted in case of Hint::kFrameCountForward and // Hint::kFrameCountBackward count is provided. It matches 23 ms @ 44.1 kHz // TODO() Do we suffer cache misses if we use an audio buffer of above 23 ms? -const SINT kDefaultHintFrames = 1024; +constexpr SINT kDefaultHintFrames = 1024; // With CachingReaderChunk::kFrames = 8192 each chunk consumes // 8192 frames * 2 channels/frame * 4-bytes per sample = 65 kB. @@ -37,7 +37,7 @@ const SINT kDefaultHintFrames = 1024; // (kNumberOfCachedChunksInMemory = 1, 2, 3, ...) for testing purposes // to verify that the MRU/LRU cache works as expected. Even though // massive drop outs are expected to occur Mixxx should run reliably! -const SINT kNumberOfCachedChunksInMemory = 80; +constexpr SINT kNumberOfCachedChunksInMemory = 80; } // anonymous namespace diff --git a/src/engine/cachingreader/cachingreaderchunk.cpp b/src/engine/cachingreader/cachingreaderchunk.cpp index 1ce0a1de0b..fed9aa5272 100644 --- a/src/engine/cachingreader/cachingreaderchunk.cpp +++ b/src/engine/cachingreader/cachingreaderchunk.cpp @@ -13,7 +13,7 @@ namespace { mixxx::Logger kLogger("CachingReaderChunk"); -const SINT kInvalidChunkIndex = -1; +constexpr SINT kInvalidChunkIndex = -1; } // anonymous namespace diff --git a/src/engine/channelhandle.h b/src/engine/channelhandle.h index 240e5254f5..1fc1d4abcf 100644 --- a/src/engine/channelhandle.h +++ b/src/engine/channelhandle.h @@ -167,7 +167,7 @@ typedef std::shared_ptr<ChannelHandleFactory> ChannelHandleFactoryPointer; // integer value. template <class T> class ChannelHandleMap { - static const int kMaxExpectedGroups = 256; + static constexpr int kMaxExpectedGroups = 256; typedef QVarLengthArray<T, kMaxExpectedGroups> container_type; public: typedef typename QVarLengthArray<T, kMaxExpectedGroups>::const_iterator const_iterator; diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp index 7c161341f6..ac34068bd6 100644 --- a/src/engine/controls/bpmcontrol.cpp +++ b/src/engine/controls/bpmcontrol.cpp @@ -514,16 +514,16 @@ double BpmControl::calcSyncAdjustment(bool userTweakingSync) { // Threshold above which sync is really, really bad, so much so that we // don't even know if we're ahead or behind. This can occur when quantize was // off, but then it gets turned on. - const double kTrainWreckThreshold = 0.2; - const double kSyncAdjustmentCap = 0.05; + constexpr double kTrainWreckThreshold = 0.2; + constexpr double kSyncAdjustmentCap = 0.05; if (fabs(error) > kTrainWreckThreshold) { // Assume poor reflexes (late button push) -- speed up to catch the other track. adjustment = 1.0 + kSyncAdjustmentCap; } else if (fabs(error) > kErrorThreshold) { // Proportional control constant. The higher this is, the more we // influence sync. - const double kSyncAdjustmentProportional = 0.7; - const double kSyncDeltaCap = 0.02; + constexpr double kSyncAdjustmentProportional = 0.7; + constexpr double kSyncDeltaCap = 0.02; // TODO(owilliams): There are a lot of "1.0"s in this code -- can we eliminate them? const double adjust = 1.0 + (-error * kSyncAdjustmentProportional); diff --git a/src/engine/controls/enginecontrol.h b/src/engine/controls/enginecontrol.h index 753703f07f..d155568a61 100644 --- a/src/engine/controls/enginecontrol.h +++ b/src/engine/controls/enginecontrol.h @@ -17,7 +17,7 @@ class EngineMaster; class EngineBuffer; -const int kNoTrigger = -1; +constexpr int kNoTrigger = -1; static_assert( mixxx::audio::FramePos::kLegacyInvalidEnginePosition == kNoTrigger, "Invalid engine position value mismatch"); diff --git a/src/engine/controls/keycontrol.cpp b/src/engine/controls/keycontrol.cpp index 874cdf5cb5..01e4fbea6f 100644 --- a/src/engine/controls/keycontrol.cpp +++ b/src/engine/controls/keycontrol.cpp @@ -12,8 +12,8 @@ #include "track/keyutils.h" //static const double kLockOriginalKey = 0; -static const double kLockCurrentKey = 1; -static const double kKeepUnlockedKey = 1; +static constexpr double kLockCurrentKey = 1; +static constexpr double kKeepUnlockedKey = 1; KeyControl::KeyControl(const QString& group, UserSettingsPointer pConfig) diff --git a/src/engine/controls/ratecontrol.cpp b/src/engine/controls/ratecontrol.cpp index 51716267f8..dc0c3babd9 100644 --- a/src/engine/controls/ratecontrol.cpp +++ b/src/engine/controls/ratecontrol.cpp @@ -364,7 +364,7 @@ double RateControl::getWheelFactor() const { double RateControl::getJogFactor() const { // FIXME: Sensitivity should be configurable separately? - const double jogSensitivity = 0.1; // Nudges during playback + constexpr double jogSensitivity = 0.1; // Nudges during playback double jogValue = m_pJog->get(); // Since m_pJog is an accumulator, reset it since we've used its value. diff --git a/src/engine/enginemaster.cpp b/src/engine/enginemaster.cpp index c8267451cb..6995288ad8 100644 --- a/src/engine/enginemaster.cpp +++ b/src/engine/enginemaster.cpp @@ -399,7 +399,7 @@ void EngineMaster::process(const int iBufferSize) { m_sampleRate = mixxx::audio::SampleRate::fromDouble(m_pMasterSampleRate->get()); m_iBufferSize = iBufferSize; // TODO: remove assumption of stereo buffer - const unsigned int kChannels = 2; + constexpr unsigned int kChannels = 2; const unsigned int iFrames = iBufferSize / kChannels; if (m_pEngineEffectsManager) { @@ -825,7 +825,7 @@ void EngineMaster::addChannel(EngineChannel* pChannel) { pChannelInfo->m_pBuffer = SampleUtil::alloc(MAX_BUFFER_LEN); SampleUtil::clear(pChannelInfo->m_pBuffer, MAX_BUFFER_LEN); m_channels.append(pChannelInfo); - const GainCache gainCacheDefault = {0, false}; + constexpr GainCache gainCacheDefault = {0, false}; m_channelHeadphoneGainCache.append(gainCacheDefault); m_channelTalkoverGainCache.append(gainCacheDefault); m_channelMasterGainCache.append(gainCacheDefault); diff --git a/src/engine/enginemaster.h b/src/engine/enginemaster.h index 7033f9ca2c..badf694c8b 100644 --- a/src/engine/enginemaster.h +++ b/src/engine/enginemaster.h @@ -33,7 +33,7 @@ class EngineDelay; // The number of channels to pre-allocate in various structures in the // engine. Prevents memory allocation in EngineMaster::addChannel. -static const int kPreallocatedChannels = 64; +static constexpr int kPreallocatedChannels = 64; class EngineMaster : public QObject, public AudioSource { Q_OBJECT diff --git a/src/engine/enginepregain.cpp b/src/engine/enginepregain.cpp index e4f1bbb0b0..d8d938560e 100644 --- a/src/engine/enginepregain.cpp +++ b/src/engine/enginepregain.cpp @@ -95,7 +95,7 @@ void EnginePregain::process(CSAMPLE* pInOut, const int iBufferSize) { // This means that a ReplayGain value has been calculated after the // track has been loaded - const float kFadeSeconds = 1.0; + constexpr float kFadeSeconds = 1.0; if (m_bSmoothFade) { float seconds = static_cast<float>(m_timer.elapsed().toDoubleSeconds()); diff --git a/src/engine/filters/enginefiltermoogladder4.h b/src/engine/filters/enginefiltermoogladder4.h index b1f33c7c70..c6e3bd8a98 100644 --- a/src/engine/filters/enginefiltermoogladder4.h +++ b/src/engine/filters/enginefiltermoogladder4.h @@ -73,7 +73,7 @@ class EngineFilterMoogLadderBase : public EngineObjectConstIn { // cutoff in Hz // resonance range 0 ... 4 (4 = self resonance) void setParameter(int sampleRate, float cutoff, float resonance) { - const float v2 = 2 + kVt; // twice the 'thermal voltage of a transistor' + constexpr float v2 = 2 + kVt; // twice the 'thermal voltage of a transistor' float kfc = cutoff / sampleRate; float kf = kfc; @@ -182,8 +182,7 @@ class EngineFilterMoogLadderBase : public EngineObjectConstIn { } inline CSAMPLE processSample(float input, struct Buffer* pB) { - - const float v2 = 2 + kVt; // twice the 'thermal voltage of a transistor' + constexpr float v2 = 2 + kVt; // twice the 'thermal voltage of a transistor' // cascade of 4 1st-order sections float x1 = input - pB->m_amf * m_kacr; diff --git a/src/engine/filters/enginefilterpan.h b/src/engine/filters/enginefilterpan.h index 30127ea0ce..51ad19c03d 100644 --- a/src/engine/filters/enginefilterpan.h +++ b/src/engine/filters/enginefilterpan.h @@ -5,7 +5,7 @@ #include "engine/engineobject.h" #include "util/assert.h" -static const int numChannels = 2; +static constexpr int numChannels = 2; template<unsigned int SIZE> class EngineFilterPan : public EngineObjectConstIn { diff --git a/src/engine/filters/enginefilterpansingle.h b/src/engine/filters/enginefilterpansingle.h index df0a608148..1861b97db8 100644 --- a/src/engine/filters/enginefilterpansingle.h +++ b/src/engine/filters/enginefilterpansingle.h @@ -12,7 +12,7 @@ #include "engine/engineobject.h" #include "util/assert.h" -static const int numChannels = 2; +static constexpr int numChannels = 2; template<unsigned int SIZE> class EngineFilterPanSingle { diff --git a/src/engine/positionscratchcontroller.cpp b/src/engine/positionscratchcontroller.cpp index 0edc4a7ac5..e217a8fb73 100644 --- a/src/engine/positionscratchcontroller.cpp +++ b/src/engine/positionscratchcontroller.cpp @@ -145,9 +145,9 @@ void PositionScratchController::process(double currentSample, double releaseRate } // Max velocity we would like to stop in a given time period. - const double kMaxVelocity = 100; + constexpr double kMaxVelocity = 100; // Seconds to stop a throw at the max velocity. - const double kTimeToStop = 1.0; + constexpr double kTimeToStop = 1.0; // We calculate the exponential decay constant based on the above // constants. Roughly we backsolve what the decay should be if we want to @@ -239,7 +239,7 @@ void PositionScratchController::process(double currentSample, double releaseRate // The rate threshold above which disabling position scratching will enable // an 'inertia' mode. - const double kThrowThreshold = 2.5; + constexpr double kThrowThreshold = 2.5; if (fabs(m_dRate) > kThrowThreshold) { m_bEnableInertia = true; diff --git a/src/engine/readaheadmanager.cpp b/src/engine/readaheadmanager.cpp index 8958ea44ac..451c00adb1 100644 --- a/src/engine/readaheadmanager.cpp +++ b/src/engine/readaheadmanager.cpp @@ -7,7 +7,7 @@ #include "util/math.h" #include "util/sample.h" -static const int kNumChannels = 2; +static constexpr int kNumChannels = 2; ReadAheadManager::ReadAheadManager() : m_pLoopingControl(nullptr), diff --git a/src/engine/sidechain/enginenetworkstream.cpp b/src/engine/sidechain/enginenetworkstream.cpp index 6c8b75c643..bd4c3f1efa 100644 --- a/src/engine/sidechain/enginenetworkstream.cpp +++ b/src/engine/sidechain/enginenetworkstream.cpp @@ -19,7 +19,7 @@ static PgGetSystemTimeFn s_pfpgGetSystemTimeFn = NULL; #include "util/sample.h" namespace { -const int kNetworkLatencyFrames = 8192; // 185 ms @ 44100 Hz +constexpr int kNetworkLatencyFrames = 8192; // 185 ms @ 44100 Hz // Related chunk sizes: // Mp3 frames = 1152 samples // Ogg frames = 64 to 8192 samples. diff --git a/src/engine/sidechain/enginerecord.cpp b/src/engine/sidechain/enginerecord.cpp index a2678a8eed..bb77b5d7ea 100644 --- a/src/engine/sidechain/enginerecord.cpp +++ b/src/engine/sidechain/enginerecord.cpp @@ -10,7 +10,7 @@ #include "track/track.h" #include "util/event.h" -const int kMetaDataLifeTimeout = 16; +constexpr int kMetaDataLifeTimeout = 16; EngineRecord::EngineRecord(UserSettingsPointer pConfig) : m_pConfig(pConfig), diff --git a/src/engine/sidechain/enginesidechain.cpp b/src/engine/sidechain/enginesidechain.cpp index 40e2af7a7e..ee930a0fcd 100644 --- a/src/engine/sidechain/enginesidechain.cpp +++ b/src/engine/sidechain/enginesidechain.cpp @@ -78,7 +78,7 @@ void EngineSideChain::receiveBuffer(const AudioInput& input, void EngineSideChain::writeSamples(const CSAMPLE* pBuffer, int iFrames) { Trace sidechain("EngineSideChain::writeSamples"); // TODO: remove assumption of stereo buffer - const int kChannels = 2; + constexpr int kChannels = 2; const int iSamples = iFrames * kChannels; int samples_written = m_sampleFifo.write(pBuffer, iSamples); diff --git a/src/engine/sidechain/enginesidechain.h b/src/engine/sidechain/enginesidechain.h index 15209e2fdc..5552580aeb 100644 --- a/src/engine/sidechain/enginesidechain.h +++ b/src/engine/sidechain/enginesidechain.h @@ -32,7 +32,7 @@ class EngineSideChain : public QThread, public AudioDestination { // Thread-safe, blocking. void addSideChainWorker(SideChainWorker* pWorker); - static const int SIDECHAIN_BUFFER_SIZE = 65536; + static constexpr int SIDECHAIN_BUFFER_SIZE = 65536; private: void run() override; diff --git a/src/engine/sidechain/shoutconnection.cpp b/src/engine/sidechain/shoutconnection.cpp index 768028e5f4..a9c541e872 100644 --- a/src/engine/sidechain/shoutconnection.cpp +++ b/src/engine/sidechain/shoutconnection.cpp @@ -33,11 +33,11 @@ namespace { -const int kConnectRetries = 30; -const int kMaxNetworkCache = 491520; // 10 s mp3 @ 192 kbit/s +constexpr int kConnectRetries = 30; +constexpr int kMaxNetworkCache = 491520; // 10 s mp3 @ 192 kbit/s // Shoutcast default receive buffer 1048576 and autodumpsourcetime 30 s // http://wiki.shoutcast.com/wiki/SHOUTcast_DNAS_Server_2 -const int kMaxShoutFailures = 3; +constexpr int kMaxShoutFailures = 3; const QRegularExpression kArtistOrTitleRegex(QStringLiteral("\\$artist|\\$title")); const QRegularExpression kArtistRegex(QStringLiteral("\\$artist")); |