Skip to content

Commit 9f43c3e

Browse files
authored
Merge pull request #13687 from Swiftb0y/refactor/util-deprecate
Cleanup and deprecate more `util/` classes
2 parents 98012f3 + eff5567 commit 9f43c3e

40 files changed

+475
-702
lines changed

CMakeLists.txt

+9-8
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
11751175
src/util/fileaccess.cpp
11761176
src/util/fileinfo.cpp
11771177
src/util/filename.cpp
1178+
src/util/font.cpp
11781179
src/util/imagefiledata.cpp
11791180
src/util/imagefiledata.cpp
11801181
src/util/imageutils.cpp
@@ -1201,7 +1202,6 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
12011202
src/util/tapfilter.cpp
12021203
src/util/task.cpp
12031204
src/util/taskmonitor.cpp
1204-
src/util/threadcputimer.cpp
12051205
src/util/time.cpp
12061206
src/util/timer.cpp
12071207
src/util/valuetransformer.cpp
@@ -1471,7 +1471,6 @@ set(MIXXX_LIB_PRECOMPILED_HEADER
14711471
src/util/taskmonitor.h
14721472
src/util/thread_affinity.h
14731473
src/util/thread_annotations.h
1474-
src/util/threadcputimer.h
14751474
src/util/time.h
14761475
src/util/timer.h
14771476
src/util/trace.h
@@ -2245,12 +2244,6 @@ add_custom_target(mixxx-gitinfo
22452244
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
22462245
)
22472246

2248-
add_library(mixxx-gitinfostore STATIC EXCLUDE_FROM_ALL
2249-
src/util/gitinfostore.cpp
2250-
)
2251-
target_include_directories(mixxx-gitinfostore PUBLIC src ${CMAKE_BINARY_DIR}/src)
2252-
add_dependencies(mixxx-gitinfostore mixxx-gitinfo)
2253-
22542247
# Windows-only resource file
22552248
if(WIN32)
22562249
string(TIMESTAMP MIXXX_YEAR "%Y")
@@ -3166,6 +3159,14 @@ if(APPLE OR WIN32)
31663159
)
31673160
endif()
31683161

3162+
add_library(mixxx-gitinfostore STATIC EXCLUDE_FROM_ALL
3163+
src/util/gitinfostore.cpp
3164+
)
3165+
# QtCore for QString
3166+
target_link_libraries(mixxx-gitinfostore PUBLIC Qt${QT_VERSION_MAJOR}::Core)
3167+
target_include_directories(mixxx-gitinfostore PUBLIC src ${CMAKE_BINARY_DIR}/src)
3168+
add_dependencies(mixxx-gitinfostore mixxx-gitinfo)
3169+
31693170
# Queen Mary DSP
31703171
add_library(QueenMaryDsp STATIC EXCLUDE_FROM_ALL
31713172
# lib/qm-dsp/base/KaiserWindow.cpp

src/analyzer/analyzerwaveform.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ struct WaveformStride {
4646
inline void store(WaveformData* data) {
4747
for (int i = 0; i < ChannelCount; ++i) {
4848
WaveformData& datum = *(data + i);
49-
datum.filtered.all = static_cast<unsigned char>(math_min(255.0,
49+
datum.filtered.all = static_cast<unsigned char>(std::min(255.0,
5050
m_postScaleConversion * m_overallData[i] + 0.5));
51-
datum.filtered.low = static_cast<unsigned char>(math_min(255.0,
51+
datum.filtered.low = static_cast<unsigned char>(std::min(255.0,
5252
m_postScaleConversion * m_filteredData[i][Low] + 0.5));
53-
datum.filtered.mid = static_cast<unsigned char>(math_min(255.0,
53+
datum.filtered.mid = static_cast<unsigned char>(std::min(255.0,
5454
m_postScaleConversion * m_filteredData[i][Mid] + 0.5));
55-
datum.filtered.high = static_cast<unsigned char>(math_min(255.0,
55+
datum.filtered.high = static_cast<unsigned char>(std::min(255.0,
5656
m_postScaleConversion * m_filteredData[i][High] + 0.5));
5757
for (int stemIdx = 0; stemIdx < m_stemCount; stemIdx++) {
58-
datum.stems[stemIdx] = static_cast<unsigned char>(math_min(255.0,
58+
datum.stems[stemIdx] = static_cast<unsigned char>(std::min(255.0,
5959
m_postScaleConversion * m_stemData[i][stemIdx] + 0.5));
6060
}
6161
}
@@ -78,17 +78,17 @@ struct WaveformStride {
7878
if (m_averageDivisor) {
7979
for (int i = 0; i < ChannelCount; ++i) {
8080
WaveformData& datum = *(data + i);
81-
datum.filtered.all = static_cast<unsigned char>(math_min(255.0,
81+
datum.filtered.all = static_cast<unsigned char>(std::min(255.0,
8282
m_postScaleConversion * m_averageOverallData[i] / m_averageDivisor + 0.5));
83-
datum.filtered.low = static_cast<unsigned char>(math_min(255.0,
83+
datum.filtered.low = static_cast<unsigned char>(std::min(255.0,
8484
m_postScaleConversion * m_averageFilteredData[i][Low] /
8585
m_averageDivisor +
8686
0.5));
87-
datum.filtered.mid = static_cast<unsigned char>(math_min(255.0,
87+
datum.filtered.mid = static_cast<unsigned char>(std::min(255.0,
8888
m_postScaleConversion * m_averageFilteredData[i][Mid] /
8989
m_averageDivisor +
9090
0.5));
91-
datum.filtered.high = static_cast<unsigned char>(math_min(255.0,
91+
datum.filtered.high = static_cast<unsigned char>(std::min(255.0,
9292
m_postScaleConversion * m_averageFilteredData[i][High] /
9393
m_averageDivisor +
9494
0.5));
@@ -97,13 +97,13 @@ struct WaveformStride {
9797
// This is the case if The Overview Waveform has more samples than the detailed waveform
9898
for (int i = 0; i < ChannelCount; ++i) {
9999
WaveformData& datum = *(data + i);
100-
datum.filtered.all = static_cast<unsigned char>(math_min(255.0,
100+
datum.filtered.all = static_cast<unsigned char>(std::min(255.0,
101101
m_postScaleConversion * m_overallData[i] + 0.5));
102-
datum.filtered.low = static_cast<unsigned char>(math_min(255.0,
102+
datum.filtered.low = static_cast<unsigned char>(std::min(255.0,
103103
m_postScaleConversion * m_filteredData[i][Low] + 0.5));
104-
datum.filtered.mid = static_cast<unsigned char>(math_min(255.0,
104+
datum.filtered.mid = static_cast<unsigned char>(std::min(255.0,
105105
m_postScaleConversion * m_filteredData[i][Mid] + 0.5));
106-
datum.filtered.high = static_cast<unsigned char>(math_min(255.0,
106+
datum.filtered.high = static_cast<unsigned char>(std::min(255.0,
107107
m_postScaleConversion * m_filteredData[i][High] + 0.5));
108108
}
109109
}

src/database/schemamanager.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#include "database/schemamanager.h"
22

3+
#include <QDomElement>
4+
#include <QDomNode>
5+
#include <QDomNodeList>
6+
37
#include "util/assert.h"
48
#include "util/db/fwdsqlquery.h"
59
#include "util/db/sqltransaction.h"
610
#include "util/logger.h"
711
#include "util/math.h"
8-
#include "util/optional.h"
912
#include "util/xml.h"
1013

1114
namespace {

src/effects/backends/builtin/autopaneffect.h

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <QMap>
4+
#include <cmath>
45

56
#include "effects/backends/effectprocessor.h"
67
#include "engine/filters/enginefilterpansingle.h"
@@ -13,27 +14,25 @@
1314
// somewhere else (I hear clicks when I change the period of flanger for example).
1415
class RampedSample {
1516
public:
16-
inline RampedSample()
17+
constexpr RampedSample()
1718
: ramped(false),
1819
maxDifference(1.0f),
1920
currentValue(0),
2021
initialized(false) {
2122
}
2223

23-
virtual ~RampedSample(){};
24-
25-
inline void setRampingThreshold(const float newMaxDifference) {
24+
constexpr void setRampingThreshold(float newMaxDifference) {
2625
maxDifference = newMaxDifference;
2726
}
2827

29-
inline void setWithRampingApplied(const float newValue) {
28+
constexpr void setWithRampingApplied(float newValue) {
3029
if (!initialized) {
3130
currentValue = newValue;
3231
initialized = true;
3332
} else {
3433
float difference = newValue - currentValue;
35-
if (fabs(difference) > maxDifference) {
36-
currentValue += difference / fabs(difference) * maxDifference;
34+
if (abs(difference) > maxDifference) {
35+
currentValue += difference / abs(difference) * maxDifference;
3736
ramped = true;
3837
} else {
3938
currentValue = newValue;
@@ -42,7 +41,7 @@ class RampedSample {
4241
}
4342
}
4443

45-
inline operator float() {
44+
constexpr operator float() {
4645
return currentValue;
4746
}
4847

src/effects/backends/builtin/compressoreffect.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "effects/backends/builtin/compressoreffect.h"
22

3+
#include "util/math.h"
4+
35
namespace {
46
// Auto make up time is empirically selected parameter, which is good enough for most cases
57
constexpr double defaultMakeUpAttackMs = 150;

src/effects/backends/builtin/distortioneffect.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class DistortionEffect : public EffectProcessorImpl<DistortionGroupState> {
9191
pState->m_previousMakeUpGain = gain;
9292

9393
// Crossfade
94-
CSAMPLE crossfadeParam = math_min(driveParam / ModeParams::crossfadeEndParam, 1.f);
94+
CSAMPLE crossfadeParam = std::min(driveParam / ModeParams::crossfadeEndParam, 1.f);
9595
SampleUtil::applyRampingGain(pOutput,
9696
pState->m_crossfadeParameter,
9797
crossfadeParam,

src/effects/backends/builtin/phasereffect.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "effects/backends/effectmanifest.h"
44
#include "engine/effects/engineeffectparameter.h"
5+
#include "util/math.h"
56

67
namespace {
78
constexpr unsigned int updateCoef = 32;

src/effects/backends/builtin/pitchshifteffect.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "effects/backends/effectmanifest.h"
88
#include "engine/effects/engineeffectparameter.h"
9+
#include "util/math.h"
910
#include "util/sample.h"
1011

1112
namespace {

src/encoder/encodersndfileflac.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "encoder/encodersndfileflac.h"
22

33
#include <QtDebug>
4+
#include <algorithm>
45

56
#include "encoder/encoderflacsettings.h"
67

@@ -13,14 +14,14 @@ void convertFloat32ToIntFormat(int* pDest, const CSAMPLE* pSrc, SINT numSamples,
1314
if (format & SF_FORMAT_PCM_16) {
1415
// note: LOOP VECTORIZED"
1516
for (SINT i = 0; i < numSamples; ++i) {
16-
pDest[i] = static_cast<int>(math_clamp(pSrc[i] * kFloatToIntConversionFactor,
17+
pDest[i] = static_cast<int>(std::clamp(pSrc[i] * kFloatToIntConversionFactor,
1718
static_cast<CSAMPLE>(static_cast<int>(INT_MIN & 0xFFFF0000)),
1819
static_cast<CSAMPLE>(static_cast<int>(INT_MAX & 0xFFFF0000))));
1920
}
2021
} else if (format & SF_FORMAT_PCM_24) {
2122
// note: LOOP VECTORIZED"
2223
for (SINT i = 0; i < numSamples; ++i) {
23-
pDest[i] = static_cast<int>(math_clamp(pSrc[i] * kFloatToIntConversionFactor,
24+
pDest[i] = static_cast<int>(std::clamp(pSrc[i] * kFloatToIntConversionFactor,
2425
static_cast<CSAMPLE>(static_cast<int>(INT_MIN & 0xFFFFFF00)),
2526
static_cast<CSAMPLE>(static_cast<int>(INT_MAX & 0xFFFFFF00))));
2627
}
@@ -62,7 +63,7 @@ void EncoderSndfileFlac::encodeBuffer(const CSAMPLE* pBuffer, const std::size_t
6263
if (m_pClampBuffer) {
6364
SINT numSamplesLeft = bufferSize;
6465
while (numSamplesLeft > 0) {
65-
const SINT numSamplesToWrite = math_min(numSamplesLeft, kEncBufferSize);
66+
const SINT numSamplesToWrite = std::min(numSamplesLeft, kEncBufferSize);
6667
convertFloat32ToIntFormat(m_pClampBuffer.get(),
6768
pBuffer,
6869
numSamplesToWrite,

src/engine/controls/ratecontrol.cpp

+1-12
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,8 @@ RateControl::RateControl(const QString& group,
165165

166166

167167
m_pJog = new ControlObject(ConfigKey(group, "jog"));
168-
m_pJogFilter = new Rotary();
169168
// FIXME: This should be dependent on sample rate/block size or something
170-
m_pJogFilter->setFilterLength(25);
171-
172-
// // Update Internal Settings
173-
// // Set Pitchbend Mode
174-
// m_eRateRampMode = static_cast<RampMode>(
175-
// getConfig()->getValue(ConfigKey("[Controls]","RateRamp"),
176-
// static_cast<int>(RampMode::Stepping)));
177-
178-
// // Set the Sensitivity
179-
// m_iRateRampSensitivity =
180-
// getConfig()->getValueString(ConfigKey("[Controls]","RateRampSensitivity")).toInt();
169+
m_pJogFilter = new Rotary(25);
181170

182171
m_pSyncMode = new ControlProxy(group, "sync_mode", this);
183172
}

src/engine/enginesidechaincompressor.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
#include "engine/enginesidechaincompressor.h"
2+
13
#include <QtDebug>
24

3-
#include "engine/enginesidechaincompressor.h"
5+
#include "util/assert.h"
46

57
EngineSideChainCompressor::EngineSideChainCompressor(const QString& group)
68
: m_compressRatio(1.0),

src/preferences/broadcastprofile.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#include "preferences/broadcastprofile.h"
2+
3+
#include <QDomDocument>
4+
#include <QDomElement>
5+
#include <QDomNode>
16
#include <QEventLoop>
27
#include <QFile>
38
#include <QFileInfo>
@@ -16,7 +21,6 @@ using namespace QKeychain;
1621
#endif // __QTKEYCHAIN__
1722

1823
#include "broadcast/defs_broadcast.h"
19-
#include "broadcastprofile.h"
2024
#include "defs_urls.h"
2125
#include "errordialoghandler.h"
2226
#include "moc_broadcastprofile.cpp"

src/sources/audiosource.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ bool AudioSource::verifyReadable() {
193193
// Counterexample: The broken FAAD version 2.9.1 is able to open a file
194194
// but then fails to decode any sample frames.
195195
const SINT numSampleFrames =
196-
math_min(kVerifyReadableMaxFrameCount, frameIndexRange().length());
196+
std::min(kVerifyReadableMaxFrameCount, frameIndexRange().length());
197197
SampleBuffer sampleBuffer(
198198
m_signalInfo.frames2samples(numSampleFrames));
199199
WritableSampleFrames writableSampleFrames(

src/sources/readaheadframebuffer.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ WritableSampleFrames ReadAheadFrameBuffer::consumeAndFillBuffer(
288288
// Detect and handle unexpected discontinuities: Overlap
289289
if (inputRange.start() < outputRange.start()) {
290290
const auto overlapRange = IndexRange::between(
291-
math_max(inputRange.start(), minOutputIndex),
291+
std::max(inputRange.start(), minOutputIndex),
292292
outputRange.start());
293293
DEBUG_ASSERT(
294294
overlapRange.orientation() !=
@@ -313,7 +313,7 @@ WritableSampleFrames ReadAheadFrameBuffer::consumeAndFillBuffer(
313313
}
314314
if (!isEmpty() && inputRange.start() < writeIndex()) {
315315
const auto overlapRange = IndexRange::between(
316-
math_max(inputRange.start(), readIndex()),
316+
std::max(inputRange.start(), readIndex()),
317317
writeIndex());
318318
DEBUG_ASSERT(
319319
overlapRange.orientation() !=
@@ -340,7 +340,7 @@ WritableSampleFrames ReadAheadFrameBuffer::consumeAndFillBuffer(
340340
const auto precedingRange =
341341
IndexRange::between(
342342
inputRange.start(),
343-
math_min(outputRange.start(), inputRange.end()));
343+
std::min(outputRange.start(), inputRange.end()));
344344
#if VERBOSE_DEBUG_LOG
345345
kLogger.debug()
346346
<< "Discarding input data"
@@ -363,7 +363,7 @@ WritableSampleFrames ReadAheadFrameBuffer::consumeAndFillBuffer(
363363
const auto gapRange =
364364
IndexRange::between(
365365
outputRange.start(),
366-
math_min(inputRange.start(), outputRange.end()));
366+
std::min(inputRange.start(), outputRange.end()));
367367
DEBUG_ASSERT(
368368
gapRange.orientation() !=
369369
IndexRange::Orientation::Backward);
@@ -390,7 +390,7 @@ WritableSampleFrames ReadAheadFrameBuffer::consumeAndFillBuffer(
390390
const auto copyableFrameRange =
391391
IndexRange::between(
392392
outputRange.start(),
393-
math_min(inputRange.end(), outputRange.end()));
393+
std::min(inputRange.end(), outputRange.end()));
394394
DEBUG_ASSERT(copyableFrameRange.orientation() != IndexRange::Orientation::Backward);
395395
if (copyableFrameRange.orientation() == IndexRange::Orientation::Forward) {
396396
#if VERBOSE_DEBUG_LOG

src/util/class.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#pragma once
22

3-
// A macro to disallow the copy constructor and operator= functions
4-
// This should be used in the private: declarations for a class
3+
// DEPRECATED: Adhere to the rule "the rule of zero" or "the rule of five".
4+
// See https://en.cppreference.com/w/cpp/language/rule_of_three
5+
// Rationale: If a class deals with ownership, it should do nothing more and explicitly
6+
// define the behavior of all special member functions.
7+
// This macro is sprinkled into lots of big classes and ignores the move-related SMF's.
8+
// So its common use violates both principles and thus it should not be used anymore!
59
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
610
TypeName(const TypeName&) = delete; \
711
void operator=(const TypeName&) = delete;

0 commit comments

Comments
 (0)