Skip to content

Commit

Permalink
PR comments edits
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
tcoyvwac committed Oct 3, 2021
1 parent 21420a8 commit 0da929d
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/analyzer/analyzergain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ bool AnalyzerGain::processSamples(const CSAMPLE *pIn, const int iLen) {

int halfLength = static_cast<int>(iLen / 2);
if (halfLength > m_iBufferSize) {
m_pLeftTempBuffer = std::vector<CSAMPLE>(halfLength);
m_pRightTempBuffer = std::vector<CSAMPLE>(halfLength);
m_pLeftTempBuffer.resize(halfLength);
m_pRightTempBuffer.resize(halfLength);
}
SampleUtil::deinterleaveBuffer(m_pLeftTempBuffer.data(),
m_pRightTempBuffer.data(),
Expand Down
13 changes: 6 additions & 7 deletions src/effects/lv2/lv2effectprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ LV2EffectProcessor::LV2EffectProcessor(EngineEffect* pEngineEffect,
const LilvPlugin* plugin,
const QList<int>& audioPortIndices,
const QList<int>& controlPortIndices)
: m_pPlugin(plugin),
: m_inputL{std::vector<CSAMPLE>(MAX_BUFFER_LEN)},
m_inputR{std::vector<CSAMPLE>(MAX_BUFFER_LEN)},
m_outputL{std::vector<CSAMPLE>(MAX_BUFFER_LEN)},
m_outputR{std::vector<CSAMPLE>(MAX_BUFFER_LEN)},
m_params{std::vector<float>(pManifest->parameters().size())},
m_pPlugin(plugin),
m_audioPortIndices(audioPortIndices),
m_controlPortIndices(controlPortIndices),
m_pEffectsManager(nullptr) {
m_inputL = std::vector<CSAMPLE>(MAX_BUFFER_LEN);
m_inputR = std::vector<CSAMPLE>(MAX_BUFFER_LEN);
m_outputL = std::vector<CSAMPLE>(MAX_BUFFER_LEN);
m_outputR = std::vector<CSAMPLE>(MAX_BUFFER_LEN);
m_params = std::vector<float>(pManifest->parameters().size());

const QList<EffectManifestParameterPointer>& effectManifestParameterList =
pManifest->parameters();

Expand Down
15 changes: 7 additions & 8 deletions src/effects/lv2/lv2manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
#include "util/fpclassify.h"

LV2Manifest::LV2Manifest(const LilvPlugin* plug,
QHash<QString, LilvNode*>& properties)
QHash<QString, LilvNode*>& properties)
: m_pEffectManifest(new EffectManifest()),
m_status(AVAILABLE) {
m_minimum{std::vector<float>(lilv_plugin_get_num_ports(plug))},

m_maximum{std::vector<float>(lilv_plugin_get_num_ports(plug))},

m_default{std::vector<float>(lilv_plugin_get_num_ports(plug))},

m_status(AVAILABLE) {
m_pLV2plugin = plug;

// Get and set the ID
Expand All @@ -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<float>(numPorts);
m_maximum = std::vector<float>(numPorts);
m_default = std::vector<float>(numPorts);
lilv_plugin_get_port_ranges_float(
m_pLV2plugin, m_minimum.data(), m_maximum.data(), m_default.data());

Expand Down Expand Up @@ -152,9 +154,6 @@ LV2Manifest::LV2Manifest(const LilvPlugin* plug,
lilv_nodes_free(features);
}

LV2Manifest::~LV2Manifest() {
}

EffectManifestPointer LV2Manifest::getEffectManifest() const {
return m_pEffectManifest;
}
Expand Down
1 change: 0 additions & 1 deletion src/effects/lv2/lv2manifest.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class LV2Manifest {
};

LV2Manifest(const LilvPlugin* plug, QHash<QString, LilvNode*>& properties);
~LV2Manifest();
EffectManifestPointer getEffectManifest() const;
QList<int> getAudioPortIndices();
QList<int> getControlPortIndices();
Expand Down
10 changes: 6 additions & 4 deletions src/encoder/encoderfdkaac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned char>(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) {
Expand Down Expand Up @@ -343,7 +343,7 @@ int EncoderFdkAac::initEncoder(mixxx::audio::SampleRate sampleRate, QString* pUs
// the Live Broadcasting implementation
m_pInputFifo = new FIFO<SAMPLE>(EngineSideChain::SIDECHAIN_BUFFER_SIZE * 2);

m_pFifoChunkBuffer = std::vector<SAMPLE>(m_readRequired * sizeof(SAMPLE));
m_pFifoChunkBuffer.resize(m_readRequired * sizeof(SAMPLE));
return 0;
}

Expand Down Expand Up @@ -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;
Expand All @@ -410,7 +411,8 @@ void EncoderFdkAac::processFIFO() {
// Output (result) Buffer
AACENC_BufDesc outputBuf;
outputBuf.numBufs = 1;
outputBuf.bufs = reinterpret_cast<void**>(m_pAacDataBuffer.data());
void* dataBufs[] = {m_pAacDataBuffer.data()};
outputBuf.bufs = dataBufs;
outputBuf.bufSizes = &outDataSize;
outputBuf.bufElSizes = &outElemSize;
outputBuf.bufferIdentifiers = &outDataDescription;
Expand Down
4 changes: 2 additions & 2 deletions src/test/analyserwaveformtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class AnalyzerWaveformTest : public MixxxTest {
mixxx::audio::Bitrate(),
mixxx::Duration::fromMillis(1000));

bigbuf = std::vector<CSAMPLE>(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<CSAMPLE>(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++)
Expand Down
2 changes: 1 addition & 1 deletion src/test/sampleutiltest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SAMPLE> s16(size);
auto s16 = std::vector<SAMPLE>(size);
FillBuffer(buffer, 1.0f, size);
for (int j = 0; j < size; ++j) {
s16[j] = SAMPLE_MAXIMUM;
Expand Down
3 changes: 1 addition & 2 deletions src/util/circularbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class CircularBuffer {
// now.
}

virtual ~CircularBuffer() {
}
virtual ~CircularBuffer() = default;

// Returns true if the buffer is full
inline bool isFull() const {
Expand Down
3 changes: 0 additions & 3 deletions src/util/rotary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/util/rotary.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
class Rotary {
public:
Rotary();
~Rotary();

// Start calibration measurement
void calibrateStart();
Expand Down
2 changes: 1 addition & 1 deletion src/vinylcontrol/vinylcontrolsignalwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned char>(size * size * 4);
m_imageData = std::vector<uchar>(size * size * 4);
m_qImage = QImage(m_imageData.data(), size, size, 0, QImage::Format_ARGB32);
}

Expand Down

0 comments on commit 0da929d

Please sign in to comment.