From 0da929db9998c05db772febdf60ee89f0da65f1e Mon Sep 17 00:00:00 2001 From: tcoyvwac <53616399+tcoyvwac@users.noreply.github.com> Date: Sun, 3 Oct 2021 11:03:14 +0200 Subject: [PATCH] PR comments edits * Initialised std::vector inside of constructor initialiser-list. * Used std::vector.resize() over reassignment. * Used void*[] implicit conversions for protobuf. * Used "auto _ = std::vector{}" style for some assignments. * Default'ed empty virtual destructors and fully removed other empty destructors from codebase. * Used native qt datatype(-typedef), uchar. --- src/analyzer/analyzergain.cpp | 4 ++-- src/effects/lv2/lv2effectprocessor.cpp | 13 ++++++------- src/effects/lv2/lv2manifest.cpp | 15 +++++++-------- src/effects/lv2/lv2manifest.h | 1 - src/encoder/encoderfdkaac.cpp | 10 ++++++---- src/test/analyserwaveformtest.cpp | 4 ++-- src/test/sampleutiltest.cpp | 2 +- src/util/circularbuffer.h | 3 +-- src/util/rotary.cpp | 3 --- src/util/rotary.h | 1 - src/vinylcontrol/vinylcontrolsignalwidget.cpp | 2 +- 11 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/analyzer/analyzergain.cpp b/src/analyzer/analyzergain.cpp index 074ac38971a0..94ba97e864a1 100644 --- a/src/analyzer/analyzergain.cpp +++ b/src/analyzer/analyzergain.cpp @@ -36,8 +36,8 @@ bool AnalyzerGain::processSamples(const CSAMPLE *pIn, const int iLen) { int halfLength = static_cast(iLen / 2); if (halfLength > m_iBufferSize) { - m_pLeftTempBuffer = std::vector(halfLength); - m_pRightTempBuffer = std::vector(halfLength); + m_pLeftTempBuffer.resize(halfLength); + m_pRightTempBuffer.resize(halfLength); } SampleUtil::deinterleaveBuffer(m_pLeftTempBuffer.data(), m_pRightTempBuffer.data(), diff --git a/src/effects/lv2/lv2effectprocessor.cpp b/src/effects/lv2/lv2effectprocessor.cpp index 64a5cc3501ae..ebdb37c12bb6 100644 --- a/src/effects/lv2/lv2effectprocessor.cpp +++ b/src/effects/lv2/lv2effectprocessor.cpp @@ -9,16 +9,15 @@ LV2EffectProcessor::LV2EffectProcessor(EngineEffect* pEngineEffect, const LilvPlugin* plugin, const QList& audioPortIndices, const QList& controlPortIndices) - : m_pPlugin(plugin), + : m_inputL{std::vector(MAX_BUFFER_LEN)}, + m_inputR{std::vector(MAX_BUFFER_LEN)}, + m_outputL{std::vector(MAX_BUFFER_LEN)}, + m_outputR{std::vector(MAX_BUFFER_LEN)}, + m_params{std::vector(pManifest->parameters().size())}, + m_pPlugin(plugin), m_audioPortIndices(audioPortIndices), m_controlPortIndices(controlPortIndices), m_pEffectsManager(nullptr) { - m_inputL = std::vector(MAX_BUFFER_LEN); - m_inputR = std::vector(MAX_BUFFER_LEN); - m_outputL = std::vector(MAX_BUFFER_LEN); - m_outputR = std::vector(MAX_BUFFER_LEN); - m_params = std::vector(pManifest->parameters().size()); - const QList& effectManifestParameterList = pManifest->parameters(); diff --git a/src/effects/lv2/lv2manifest.cpp b/src/effects/lv2/lv2manifest.cpp index 65a119504d7a..08e2e572e3dc 100644 --- a/src/effects/lv2/lv2manifest.cpp +++ b/src/effects/lv2/lv2manifest.cpp @@ -4,10 +4,15 @@ #include "util/fpclassify.h" LV2Manifest::LV2Manifest(const LilvPlugin* plug, - QHash& properties) + QHash& properties) : m_pEffectManifest(new EffectManifest()), - m_status(AVAILABLE) { + m_minimum{std::vector(lilv_plugin_get_num_ports(plug))}, + + m_maximum{std::vector(lilv_plugin_get_num_ports(plug))}, + + m_default{std::vector(lilv_plugin_get_num_ports(plug))}, + m_status(AVAILABLE) { m_pLV2plugin = plug; // Get and set the ID @@ -25,9 +30,6 @@ LV2Manifest::LV2Manifest(const LilvPlugin* plug, lilv_node_free(info); int numPorts = lilv_plugin_get_num_ports(plug); - m_minimum = std::vector(numPorts); - m_maximum = std::vector(numPorts); - m_default = std::vector(numPorts); lilv_plugin_get_port_ranges_float( m_pLV2plugin, m_minimum.data(), m_maximum.data(), m_default.data()); @@ -152,9 +154,6 @@ LV2Manifest::LV2Manifest(const LilvPlugin* plug, lilv_nodes_free(features); } -LV2Manifest::~LV2Manifest() { -} - EffectManifestPointer LV2Manifest::getEffectManifest() const { return m_pEffectManifest; } diff --git a/src/effects/lv2/lv2manifest.h b/src/effects/lv2/lv2manifest.h index b759f5c2f603..e772e9e35ade 100644 --- a/src/effects/lv2/lv2manifest.h +++ b/src/effects/lv2/lv2manifest.h @@ -16,7 +16,6 @@ class LV2Manifest { }; LV2Manifest(const LilvPlugin* plug, QHash& properties); - ~LV2Manifest(); EffectManifestPointer getEffectManifest() const; QList getAudioPortIndices(); QList getControlPortIndices(); diff --git a/src/encoder/encoderfdkaac.cpp b/src/encoder/encoderfdkaac.cpp index 885081a96f18..f5f94c08ec19 100644 --- a/src/encoder/encoderfdkaac.cpp +++ b/src/encoder/encoderfdkaac.cpp @@ -279,7 +279,7 @@ int EncoderFdkAac::initEncoder(mixxx::audio::SampleRate sampleRate, QString* pUs // This initializes the encoder handle but not the encoder itself. // Actual encoder init is done below. aacEncOpen(&m_aacEnc, 0, m_channels); - m_pAacDataBuffer = std::vector(kOutBufferBits * m_channels); + m_pAacDataBuffer.resize(kOutBufferBits * m_channels); // AAC Object Type: specifies "mode": AAC-LC, HE-AAC, HE-AACv2, DAB AAC, etc... if (aacEncoder_SetParam(m_aacEnc, AACENC_AOT, m_aacAot) != AACENC_OK) { @@ -343,7 +343,7 @@ int EncoderFdkAac::initEncoder(mixxx::audio::SampleRate sampleRate, QString* pUs // the Live Broadcasting implementation m_pInputFifo = new FIFO(EngineSideChain::SIDECHAIN_BUFFER_SIZE * 2); - m_pFifoChunkBuffer = std::vector(m_readRequired * sizeof(SAMPLE)); + m_pFifoChunkBuffer.resize(m_readRequired * sizeof(SAMPLE)); return 0; } @@ -398,7 +398,8 @@ void EncoderFdkAac::processFIFO() { // Input Buffer AACENC_BufDesc inputBuf; inputBuf.numBufs = 1; - inputBuf.bufs = (void**)&m_pFifoChunkBuffer; + void* chunkBuffer[] = {m_pFifoChunkBuffer.data()}; + inputBuf.bufs = chunkBuffer; inputBuf.bufSizes = &inDataSize; inputBuf.bufElSizes = &inSampleSize; inputBuf.bufferIdentifiers = &inDataDescription; @@ -410,7 +411,8 @@ void EncoderFdkAac::processFIFO() { // Output (result) Buffer AACENC_BufDesc outputBuf; outputBuf.numBufs = 1; - outputBuf.bufs = reinterpret_cast(m_pAacDataBuffer.data()); + void* dataBufs[] = {m_pAacDataBuffer.data()}; + outputBuf.bufs = dataBufs; outputBuf.bufSizes = &outDataSize; outputBuf.bufElSizes = &outElemSize; outputBuf.bufferIdentifiers = &outDataDescription; diff --git a/src/test/analyserwaveformtest.cpp b/src/test/analyserwaveformtest.cpp index af38186b1aca..5374dcda432b 100644 --- a/src/test/analyserwaveformtest.cpp +++ b/src/test/analyserwaveformtest.cpp @@ -32,14 +32,14 @@ class AnalyzerWaveformTest : public MixxxTest { mixxx::audio::Bitrate(), mixxx::Duration::fromMillis(1000)); - bigbuf = std::vector(BIGBUF_SIZE); + bigbuf.resize(BIGBUF_SIZE); for (int i = 0; i < BIGBUF_SIZE; i++) bigbuf[i] = MAGIC_FLOAT; //Memory layout for canaryBigBuf looks like // [ canary | big buf | canary ] - canaryBigBuf = std::vector(BIGBUF_SIZE + 2 * CANARY_SIZE); + canaryBigBuf.resize(BIGBUF_SIZE + 2 * CANARY_SIZE); for (int i = 0; i < CANARY_SIZE; i++) canaryBigBuf[i] = CANARY_FLOAT; for (int i = CANARY_SIZE; i < CANARY_SIZE + BIGBUF_SIZE; i++) diff --git a/src/test/sampleutiltest.cpp b/src/test/sampleutiltest.cpp index a0f68c25105e..ecf19f3b321c 100644 --- a/src/test/sampleutiltest.cpp +++ b/src/test/sampleutiltest.cpp @@ -261,7 +261,7 @@ TEST_F(SampleUtilTest, convertS16ToFloat32) { for (int i = 0; i < buffers.size(); ++i) { CSAMPLE* buffer = buffers[i]; int size = sizes[i]; - std::vector s16(size); + auto s16 = std::vector(size); FillBuffer(buffer, 1.0f, size); for (int j = 0; j < size; ++j) { s16[j] = SAMPLE_MAXIMUM; diff --git a/src/util/circularbuffer.h b/src/util/circularbuffer.h index 90c95ec0fb1a..7c4334cace99 100644 --- a/src/util/circularbuffer.h +++ b/src/util/circularbuffer.h @@ -22,8 +22,7 @@ class CircularBuffer { // now. } - virtual ~CircularBuffer() { - } + virtual ~CircularBuffer() = default; // Returns true if the buffer is full inline bool isFull() const { diff --git a/src/util/rotary.cpp b/src/util/rotary.cpp index 66cc81a95a52..3659421b6518 100644 --- a/src/util/rotary.cpp +++ b/src/util/rotary.cpp @@ -16,9 +16,6 @@ Rotary::Rotary() } } -Rotary::~Rotary() { -} - /* Note: There's probably a bug in this function (or this class) somewhere. The filter function seems to be the cause of the "drifting" bug in the Hercules stuff. What happens is that filter() gets called to do some magic to a value that's returned diff --git a/src/util/rotary.h b/src/util/rotary.h index 2709757e049d..52c732642239 100644 --- a/src/util/rotary.h +++ b/src/util/rotary.h @@ -5,7 +5,6 @@ class Rotary { public: Rotary(); - ~Rotary(); // Start calibration measurement void calibrateStart(); diff --git a/src/vinylcontrol/vinylcontrolsignalwidget.cpp b/src/vinylcontrol/vinylcontrolsignalwidget.cpp index 2984f67130de..176b6d5a5614 100644 --- a/src/vinylcontrol/vinylcontrolsignalwidget.cpp +++ b/src/vinylcontrol/vinylcontrolsignalwidget.cpp @@ -17,7 +17,7 @@ void VinylControlSignalWidget::setSize(int size) { setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); setMinimumSize(size, size); setMaximumSize(size, size); - m_imageData = std::vector(size * size * 4); + m_imageData = std::vector(size * size * 4); m_qImage = QImage(m_imageData.data(), size, size, 0, QImage::Format_ARGB32); }