Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup and deprecate more util/ classes #13687

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b6696e9
refactor: remove unused and unmaintained ThreadCpuTimer
Swiftb0y Sep 21, 2024
ba9b7e8
refactor: slim down valuetransformer.h and auto memory management
Swiftb0y Sep 21, 2024
534d6c4
refactor: fix some transient dependencies on util/math.h
Swiftb0y Sep 21, 2024
152e344
refactor: convert static-only member classes to namespaces
Swiftb0y Sep 21, 2024
448ca20
refactor: slim down font.h
Swiftb0y Sep 21, 2024
07877a1
refactor: remove unused atomic utility functions from util/qatomic.h
Swiftb0y Sep 21, 2024
7849fa4
refactor: remove util/math.h dependency from util/types.h
Swiftb0y Sep 21, 2024
79e7506
refactor: slim down util/xml.h
Swiftb0y Sep 21, 2024
2109be2
refactor: simplify Rotary (jog) filter drastically.
Swiftb0y Sep 22, 2024
0e4dd46
chore: mark `DISALLOW_COPY_AND_ASSIGN` macro as deprecated
Swiftb0y Sep 22, 2024
923310d
refactor: cleanup SemanticVersion
Swiftb0y Sep 22, 2024
ad841da
refactor: modernize `TaskWatcher` and mark deprecated
Swiftb0y Sep 22, 2024
ec0c12d
refactor: slim down trace.h
Swiftb0y Sep 22, 2024
ec51089
refactor: make Autopan `RampedSample` constexpr, fix cmath abs
Swiftb0y Sep 23, 2024
7578cfa
refactor: optimize Rotary Jog filter (moving arithm. average)
Swiftb0y Oct 4, 2024
4100f30
fixup! refactor: slim down valuetransformer.h and auto memory management
Swiftb0y Oct 9, 2024
0698a5b
fixup! refactor: remove unused atomic utility functions from util/qat…
Swiftb0y Oct 9, 2024
77798f1
fixup! chore: mark `DISALLOW_COPY_AND_ASSIGN` macro as deprecated
Swiftb0y Oct 9, 2024
0f69157
fixup! refactor: cleanup SemanticVersion
Swiftb0y Oct 9, 2024
c03c588
fixup! refactor: remove unused and unmaintained ThreadCpuTimer
Swiftb0y Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/util/fileaccess.cpp
src/util/fileinfo.cpp
src/util/filename.cpp
src/util/font.cpp
src/util/imagefiledata.cpp
src/util/imagefiledata.cpp
src/util/imageutils.cpp
Expand All @@ -1200,7 +1201,6 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/util/tapfilter.cpp
src/util/task.cpp
src/util/taskmonitor.cpp
src/util/threadcputimer.cpp
src/util/time.cpp
src/util/timer.cpp
src/util/valuetransformer.cpp
Expand Down Expand Up @@ -1470,7 +1470,6 @@ set(MIXXX_LIB_PRECOMPILED_HEADER
src/util/taskmonitor.h
src/util/thread_affinity.h
src/util/thread_annotations.h
src/util/threadcputimer.h
src/util/time.h
src/util/timer.h
src/util/trace.h
Expand Down
26 changes: 13 additions & 13 deletions src/analyzer/analyzerwaveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ struct WaveformStride {
inline void store(WaveformData* data) {
for (int i = 0; i < ChannelCount; ++i) {
WaveformData& datum = *(data + i);
datum.filtered.all = static_cast<unsigned char>(math_min(255.0,
datum.filtered.all = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_overallData[i] + 0.5));
datum.filtered.low = static_cast<unsigned char>(math_min(255.0,
datum.filtered.low = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_filteredData[i][Low] + 0.5));
datum.filtered.mid = static_cast<unsigned char>(math_min(255.0,
datum.filtered.mid = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_filteredData[i][Mid] + 0.5));
datum.filtered.high = static_cast<unsigned char>(math_min(255.0,
datum.filtered.high = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_filteredData[i][High] + 0.5));
for (int stemIdx = 0; stemIdx < m_stemCount; stemIdx++) {
datum.stems[stemIdx] = static_cast<unsigned char>(math_min(255.0,
datum.stems[stemIdx] = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_stemData[i][stemIdx] + 0.5));
}
}
Expand All @@ -78,17 +78,17 @@ struct WaveformStride {
if (m_averageDivisor) {
for (int i = 0; i < ChannelCount; ++i) {
WaveformData& datum = *(data + i);
datum.filtered.all = static_cast<unsigned char>(math_min(255.0,
datum.filtered.all = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_averageOverallData[i] / m_averageDivisor + 0.5));
datum.filtered.low = static_cast<unsigned char>(math_min(255.0,
datum.filtered.low = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_averageFilteredData[i][Low] /
m_averageDivisor +
0.5));
datum.filtered.mid = static_cast<unsigned char>(math_min(255.0,
datum.filtered.mid = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_averageFilteredData[i][Mid] /
m_averageDivisor +
0.5));
datum.filtered.high = static_cast<unsigned char>(math_min(255.0,
datum.filtered.high = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_averageFilteredData[i][High] /
m_averageDivisor +
0.5));
Expand All @@ -97,13 +97,13 @@ struct WaveformStride {
// This is the case if The Overview Waveform has more samples than the detailed waveform
for (int i = 0; i < ChannelCount; ++i) {
WaveformData& datum = *(data + i);
datum.filtered.all = static_cast<unsigned char>(math_min(255.0,
datum.filtered.all = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_overallData[i] + 0.5));
datum.filtered.low = static_cast<unsigned char>(math_min(255.0,
datum.filtered.low = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_filteredData[i][Low] + 0.5));
datum.filtered.mid = static_cast<unsigned char>(math_min(255.0,
datum.filtered.mid = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_filteredData[i][Mid] + 0.5));
datum.filtered.high = static_cast<unsigned char>(math_min(255.0,
datum.filtered.high = static_cast<unsigned char>(std::min(255.0,
m_postScaleConversion * m_filteredData[i][High] + 0.5));
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/database/schemamanager.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#include "database/schemamanager.h"

#include <QDomElement>
#include <QDomNode>
#include <QDomNodeList>

#include "util/assert.h"
#include "util/db/fwdsqlquery.h"
#include "util/db/sqltransaction.h"
#include "util/logger.h"
#include "util/math.h"
#include "util/optional.h"
#include "util/xml.h"

namespace {
Expand Down
15 changes: 7 additions & 8 deletions src/effects/backends/builtin/autopaneffect.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <QMap>
#include <cmath>

#include "effects/backends/effectprocessor.h"
#include "engine/filters/enginefilterpansingle.h"
Expand All @@ -13,27 +14,25 @@
// somewhere else (I hear clicks when I change the period of flanger for example).
class RampedSample {
public:
inline RampedSample()
constexpr RampedSample()
: ramped(false),
maxDifference(1.0f),
currentValue(0),
initialized(false) {
}

virtual ~RampedSample(){};

inline void setRampingThreshold(const float newMaxDifference) {
constexpr void setRampingThreshold(float newMaxDifference) {
maxDifference = newMaxDifference;
}

inline void setWithRampingApplied(const float newValue) {
constexpr void setWithRampingApplied(float newValue) {
if (!initialized) {
currentValue = newValue;
initialized = true;
} else {
float difference = newValue - currentValue;
if (fabs(difference) > maxDifference) {
currentValue += difference / fabs(difference) * maxDifference;
if (abs(difference) > maxDifference) {
currentValue += difference / abs(difference) * maxDifference;
ramped = true;
} else {
currentValue = newValue;
Expand All @@ -42,7 +41,7 @@ class RampedSample {
}
}

inline operator float() {
constexpr operator float() {
return currentValue;
}

Expand Down
2 changes: 2 additions & 0 deletions src/effects/backends/builtin/compressoreffect.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "effects/backends/builtin/compressoreffect.h"

#include "util/math.h"

namespace {
// Auto make up time is empirically selected parameter, which is good enough for most cases
constexpr double defaultMakeUpAttackMs = 150;
Expand Down
2 changes: 1 addition & 1 deletion src/effects/backends/builtin/distortioneffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class DistortionEffect : public EffectProcessorImpl<DistortionGroupState> {
pState->m_previousMakeUpGain = gain;

// Crossfade
CSAMPLE crossfadeParam = math_min(driveParam / ModeParams::crossfadeEndParam, 1.f);
CSAMPLE crossfadeParam = std::min(driveParam / ModeParams::crossfadeEndParam, 1.f);
SampleUtil::applyRampingGain(pOutput,
pState->m_crossfadeParameter,
crossfadeParam,
Expand Down
1 change: 1 addition & 0 deletions src/effects/backends/builtin/phasereffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "effects/backends/effectmanifest.h"
#include "engine/effects/engineeffectparameter.h"
#include "util/math.h"

namespace {
constexpr unsigned int updateCoef = 32;
Expand Down
1 change: 1 addition & 0 deletions src/effects/backends/builtin/pitchshifteffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "effects/backends/effectmanifest.h"
#include "engine/effects/engineeffectparameter.h"
#include "util/math.h"
#include "util/sample.h"

namespace {
Expand Down
7 changes: 4 additions & 3 deletions src/encoder/encodersndfileflac.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "encoder/encodersndfileflac.h"

#include <QtDebug>
#include <algorithm>

#include "encoder/encoderflacsettings.h"

Expand All @@ -13,14 +14,14 @@ void convertFloat32ToIntFormat(int* pDest, const CSAMPLE* pSrc, SINT numSamples,
if (format & SF_FORMAT_PCM_16) {
// note: LOOP VECTORIZED"
for (SINT i = 0; i < numSamples; ++i) {
pDest[i] = static_cast<int>(math_clamp(pSrc[i] * kFloatToIntConversionFactor,
pDest[i] = static_cast<int>(std::clamp(pSrc[i] * kFloatToIntConversionFactor,
static_cast<CSAMPLE>(static_cast<int>(INT_MIN & 0xFFFF0000)),
static_cast<CSAMPLE>(static_cast<int>(INT_MAX & 0xFFFF0000))));
}
} else if (format & SF_FORMAT_PCM_24) {
// note: LOOP VECTORIZED"
for (SINT i = 0; i < numSamples; ++i) {
pDest[i] = static_cast<int>(math_clamp(pSrc[i] * kFloatToIntConversionFactor,
pDest[i] = static_cast<int>(std::clamp(pSrc[i] * kFloatToIntConversionFactor,
static_cast<CSAMPLE>(static_cast<int>(INT_MIN & 0xFFFFFF00)),
static_cast<CSAMPLE>(static_cast<int>(INT_MAX & 0xFFFFFF00))));
}
Expand Down Expand Up @@ -62,7 +63,7 @@ void EncoderSndfileFlac::encodeBuffer(const CSAMPLE* pBuffer, const int iBufferS
if (m_pClampBuffer) {
SINT numSamplesLeft = iBufferSize;
while (numSamplesLeft > 0) {
const SINT numSamplesToWrite = math_min(numSamplesLeft, kEncBufferSize);
const SINT numSamplesToWrite = std::min(numSamplesLeft, kEncBufferSize);
convertFloat32ToIntFormat(m_pClampBuffer.get(),
pBuffer,
numSamplesToWrite,
Expand Down
13 changes: 1 addition & 12 deletions src/engine/controls/ratecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,8 @@ RateControl::RateControl(const QString& group,


m_pJog = new ControlObject(ConfigKey(group, "jog"));
m_pJogFilter = new Rotary();
// FIXME: This should be dependent on sample rate/block size or something
m_pJogFilter->setFilterLength(25);

// // Update Internal Settings
// // Set Pitchbend Mode
// m_eRateRampMode = static_cast<RampMode>(
// getConfig()->getValue(ConfigKey("[Controls]","RateRamp"),
// static_cast<int>(RampMode::Stepping)));

// // Set the Sensitivity
// m_iRateRampSensitivity =
// getConfig()->getValueString(ConfigKey("[Controls]","RateRampSensitivity")).toInt();
m_pJogFilter = new Rotary(25);

m_pSyncMode = new ControlProxy(group, "sync_mode", this);
}
Expand Down
4 changes: 3 additions & 1 deletion src/engine/enginesidechaincompressor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "engine/enginesidechaincompressor.h"

#include <QtDebug>

#include "engine/enginesidechaincompressor.h"
#include "util/assert.h"

EngineSideChainCompressor::EngineSideChainCompressor(const QString& group)
: m_compressRatio(1.0),
Expand Down
6 changes: 5 additions & 1 deletion src/preferences/broadcastprofile.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#include "preferences/broadcastprofile.h"

#include <QDomDocument>
#include <QDomElement>
#include <QDomNode>
#include <QEventLoop>
#include <QFile>
#include <QFileInfo>
Expand All @@ -16,7 +21,6 @@ using namespace QKeychain;
#endif // __QTKEYCHAIN__

#include "broadcast/defs_broadcast.h"
#include "broadcastprofile.h"
#include "defs_urls.h"
#include "errordialoghandler.h"
#include "moc_broadcastprofile.cpp"
Expand Down
5 changes: 4 additions & 1 deletion src/skin/legacy/legacyskinparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QtGlobal>

#include "control/controlobject.h"
#include "control/controlpushbutton.h"
#include "controllers/controllerlearningeventfilter.h"
#include "controllers/controllermanager.h"
#include "controllers/keyboard/keyboardeventfilter.h"
Expand Down Expand Up @@ -2306,7 +2307,9 @@ void LegacySkinParser::setupConnections(const QDomNode& node, WBaseWidget* pWidg
ValueTransformer* pTransformer = nullptr;
QDomElement transform = m_pContext->selectElement(con, "Transform");
if (!transform.isNull()) {
pTransformer = ValueTransformer::parseFromXml(transform, *m_pContext);
pTransformer =
ValueTransformer::parseFromXml(transform, *m_pContext)
.release(); // TODO don't leak here
}

QString property;
Expand Down
2 changes: 1 addition & 1 deletion src/sources/audiosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ bool AudioSource::verifyReadable() {
// Counterexample: The broken FAAD version 2.9.1 is able to open a file
// but then fails to decode any sample frames.
const SINT numSampleFrames =
math_min(kVerifyReadableMaxFrameCount, frameIndexRange().length());
std::min(kVerifyReadableMaxFrameCount, frameIndexRange().length());
SampleBuffer sampleBuffer(
m_signalInfo.frames2samples(numSampleFrames));
WritableSampleFrames writableSampleFrames(
Expand Down
10 changes: 5 additions & 5 deletions src/sources/readaheadframebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ WritableSampleFrames ReadAheadFrameBuffer::consumeAndFillBuffer(
// Detect and handle unexpected discontinuities: Overlap
if (inputRange.start() < outputRange.start()) {
const auto overlapRange = IndexRange::between(
math_max(inputRange.start(), minOutputIndex),
std::max(inputRange.start(), minOutputIndex),
outputRange.start());
DEBUG_ASSERT(
overlapRange.orientation() !=
Expand All @@ -313,7 +313,7 @@ WritableSampleFrames ReadAheadFrameBuffer::consumeAndFillBuffer(
}
if (!isEmpty() && inputRange.start() < writeIndex()) {
const auto overlapRange = IndexRange::between(
math_max(inputRange.start(), readIndex()),
std::max(inputRange.start(), readIndex()),
writeIndex());
DEBUG_ASSERT(
overlapRange.orientation() !=
Expand All @@ -340,7 +340,7 @@ WritableSampleFrames ReadAheadFrameBuffer::consumeAndFillBuffer(
const auto precedingRange =
IndexRange::between(
inputRange.start(),
math_min(outputRange.start(), inputRange.end()));
std::min(outputRange.start(), inputRange.end()));
#if VERBOSE_DEBUG_LOG
kLogger.debug()
<< "Discarding input data"
Expand All @@ -363,7 +363,7 @@ WritableSampleFrames ReadAheadFrameBuffer::consumeAndFillBuffer(
const auto gapRange =
IndexRange::between(
outputRange.start(),
math_min(inputRange.start(), outputRange.end()));
std::min(inputRange.start(), outputRange.end()));
DEBUG_ASSERT(
gapRange.orientation() !=
IndexRange::Orientation::Backward);
Expand All @@ -390,7 +390,7 @@ WritableSampleFrames ReadAheadFrameBuffer::consumeAndFillBuffer(
const auto copyableFrameRange =
IndexRange::between(
outputRange.start(),
math_min(inputRange.end(), outputRange.end()));
std::min(inputRange.end(), outputRange.end()));
DEBUG_ASSERT(copyableFrameRange.orientation() != IndexRange::Orientation::Backward);
if (copyableFrameRange.orientation() == IndexRange::Orientation::Forward) {
#if VERBOSE_DEBUG_LOG
Expand Down
8 changes: 6 additions & 2 deletions src/util/class.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#pragma once

// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
// DEPRECATED: Adhere to the rule "the rule of zero" or "the rule of five".
// See https://en.cppreference.com/w/cpp/language/rule_of_three
// Rationale: If a class deals with ownership, it should do nothing more and explicitly
// define the behavior of all special member functions.
// This macro is sprinkled into lots of big classes and ignores the move-related SMF's.
// So its common use violates both principles and thus it should not be used anymore!
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete;
27 changes: 0 additions & 27 deletions src/util/compatibility/qatomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@
// Until the minimum required Qt version of Mixxx is increased some utility
// functions that work independently of the Qt version are needed.

template<typename T>
inline T atomicLoadAcquire(const QAtomicInteger<T>& atomicInt) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return atomicInt.loadAcquire();
#else
return atomicInt.load();
#endif
}

template<typename T>
inline T* atomicLoadAcquire(const QAtomicPointer<T>& atomicPtr) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return atomicPtr.loadAcquire();
#else
return atomicPtr.load();
#endif
}

template<typename T>
inline T atomicLoadRelaxed(const QAtomicInteger<T>& atomicInt) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
Expand All @@ -45,15 +27,6 @@ inline T* atomicLoadRelaxed(const QAtomicPointer<T>& atomicPtr) {
#endif
}

template<typename T>
inline void atomicStoreRelaxed(QAtomicInteger<T>& atomicInt, T newValue) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
atomicInt.storeRelaxed(newValue);
#else
atomicInt.store(newValue);
#endif
}

template<typename T>
inline void atomicStoreRelaxed(QAtomicPointer<T>& atomicPtr, T* newValue) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
Expand Down
Loading
Loading