From 857e3581b0d8719404d7e00cd62ee222d5249bfe Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 7 Oct 2019 17:33:52 +0200 Subject: [PATCH] Ref T730, style * set object name * use m_XYZ member name --- samples/afvclient/main.cpp | 10 +++----- src/blackcore/afv/audio/output.cpp | 10 +++++--- .../afv/audio/receiversampleprovider.cpp | 2 +- .../afv/audio/receiversampleprovider.h | 5 ++-- .../afv/connection/clientconnection.h | 2 +- src/blackcore/context/context.h | 2 +- src/blackgui/loadindicator.cpp | 1 + src/blackinput/win/joystickwindows.cpp | 25 +++++++++++-------- src/blackmisc/filedeleter.cpp | 9 ++++--- src/blacksound/codecs/opusdecoder.h | 5 +++- src/blacksound/dsp/biquadfilter.h | 1 - .../sampleprovider/bufferedwaveprovider.cpp | 2 +- .../sampleprovider/mixingsampleprovider.h | 1 + .../sampleprovider/pinknoisegenerator.cpp | 25 ++++++++++--------- .../sampleprovider/pinknoisegenerator.h | 4 +-- src/blacksound/sampleprovider/resourcesound.h | 1 - .../resourcesoundsampleprovider.h | 3 +-- .../sampleprovider/sawtoothgenerator.cpp | 4 ++- .../sampleprovider/sawtoothgenerator.h | 6 ++--- 19 files changed, 64 insertions(+), 54 deletions(-) diff --git a/samples/afvclient/main.cpp b/samples/afvclient/main.cpp index 4d1806f54..5bdbe3414 100644 --- a/samples/afvclient/main.cpp +++ b/samples/afvclient/main.cpp @@ -29,17 +29,15 @@ int main(int argc, char *argv[]) QGuiApplication qa(argc, argv); BlackCore::registerMetadata(); - BlackCore::CApplication a("sampleafvclient", CApplicationInfo::Sample); CAfvMapReader *afvMapReader = new CAfvMapReader(&a); afvMapReader->updateFromMap(); - CAfvClient *voiceClient = new CAfvClient("https://voice1.vatsim.uk", &qa); + CAfvClient *voiceClient = new CAfvClient("https://voice1.vatsim.uk", &qa); + voiceClient->start(QThread::TimeCriticalPriority); // background thread CAfvClientBridge *voiceClientBridge = new CAfvClientBridge(voiceClient, &qa); - voiceClient->start(QThread::TimeCriticalPriority); - QObject::connect(&qa, &QCoreApplication::aboutToQuit, [voiceClient]() { voiceClient->quitAndWait(); @@ -56,8 +54,8 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; QQmlContext *ctxt = engine.rootContext(); ctxt->setContextProperty("afvMapReader", afvMapReader); - ctxt->setContextProperty("voiceClient", voiceClientBridge); - ctxt->setContextProperty("userName", defaultUserName); + ctxt->setContextProperty("voiceClient", voiceClientBridge); + ctxt->setContextProperty("userName", defaultUserName); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return a.exec(); diff --git a/src/blackcore/afv/audio/output.cpp b/src/blackcore/afv/audio/output.cpp index dd04af9a2..edb052470 100644 --- a/src/blackcore/afv/audio/output.cpp +++ b/src/blackcore/afv/audio/output.cpp @@ -30,7 +30,9 @@ namespace BlackCore CAudioOutputBuffer::CAudioOutputBuffer(ISampleProvider *sampleProvider, QObject *parent) : QIODevice(parent), m_sampleProvider(sampleProvider) - { } + { + this->setObjectName("CAudioOutputBuffer"); + } qint64 CAudioOutputBuffer::readData(char *data, qint64 maxlen) { @@ -42,7 +44,7 @@ namespace BlackCore for (float sample : buffer) { - float absSample = qAbs(sample); + const float absSample = qAbs(sample); if (absSample > m_maxSampleOutput) { m_maxSampleOutput = absSample; } } @@ -80,7 +82,9 @@ namespace BlackCore } Output::Output(QObject *parent) : QObject(parent) - { } + { + this->setObjectName("COutput"); + } void Output::start(const CAudioDeviceInfo &outputDevice, ISampleProvider *sampleProvider) { diff --git a/src/blackcore/afv/audio/receiversampleprovider.cpp b/src/blackcore/afv/audio/receiversampleprovider.cpp index 8439a70b6..b69a190b3 100644 --- a/src/blackcore/afv/audio/receiversampleprovider.cpp +++ b/src/blackcore/afv/audio/receiversampleprovider.cpp @@ -31,7 +31,7 @@ namespace BlackCore for (int i = 0; i < voiceInputNumber; i++) { - auto voiceInput = new CallsignSampleProvider(audioFormat, this, m_mixer); + const auto voiceInput = new CallsignSampleProvider(audioFormat, this, m_mixer); m_voiceInputs.push_back(voiceInput); m_mixer->addMixerInput(voiceInput); } diff --git a/src/blackcore/afv/audio/receiversampleprovider.h b/src/blackcore/afv/audio/receiversampleprovider.h index 61c03d34f..533ca8083 100644 --- a/src/blackcore/afv/audio/receiversampleprovider.h +++ b/src/blackcore/afv/audio/receiversampleprovider.h @@ -83,9 +83,8 @@ namespace BlackCore private: uint m_frequencyHz = 122800000; - bool m_mute = false; - - const double m_clickGain = 1.0; + bool m_mute = false; + const double m_clickGain = 1.0; const double m_blockToneGain = 0.10; quint16 m_id; diff --git a/src/blackcore/afv/connection/clientconnection.h b/src/blackcore/afv/connection/clientconnection.h index aaeae0216..a01ab48b3 100644 --- a/src/blackcore/afv/connection/clientconnection.h +++ b/src/blackcore/afv/connection/clientconnection.h @@ -91,7 +91,7 @@ namespace BlackCore const QUuid m_networkVersion = QUuid("3a5ddc6d-cf5d-4319-bd0e-d184f772db80"); - //Data + // Data CClientConnectionData m_connection; // Voice server diff --git a/src/blackcore/context/context.h b/src/blackcore/context/context.h index 3b3183b75..fd0a30b91 100644 --- a/src/blackcore/context/context.h +++ b/src/blackcore/context/context.h @@ -142,7 +142,7 @@ namespace BlackCore protected: CCoreFacadeConfig::ContextMode m_mode; //!< How context is used qint64 m_contextId; //!< unique identifer, avoid redirection rountrips - bool m_debugEnabled = false; //!< debug messages enabled + bool m_debugEnabled = false; //!< debug messages enabled //! Constructor IContext(CCoreFacadeConfig::ContextMode mode, QObject *parent) : diff --git a/src/blackgui/loadindicator.cpp b/src/blackgui/loadindicator.cpp index 898aaef82..829dd0e43 100644 --- a/src/blackgui/loadindicator.cpp +++ b/src/blackgui/loadindicator.cpp @@ -23,6 +23,7 @@ namespace BlackGui CLoadIndicator::CLoadIndicator(int width, int height, QWidget *parent) : QWidget(parent) { + this->setObjectName("CLoadIndicator"); this->resize(width, height); this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); this->setFocusPolicy(Qt::NoFocus); diff --git a/src/blackinput/win/joystickwindows.cpp b/src/blackinput/win/joystickwindows.cpp index 291825d54..f55d2f51d 100644 --- a/src/blackinput/win/joystickwindows.cpp +++ b/src/blackinput/win/joystickwindows.cpp @@ -28,7 +28,9 @@ namespace BlackInput m_deviceName(QString::fromWCharArray(pdidInstance->tszInstanceName)), m_productName(QString::fromWCharArray(pdidInstance->tszProductName)), m_directInput(directInputPtr) - {} + { + this->setObjectName("CJoystickDevice"); + } bool CJoystickDevice::init(HWND helperWindow) { @@ -378,24 +380,25 @@ namespace BlackInput // LRESULT CALLBACK CJoystickWindows::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - CJoystickWindows* joystickWindows = static_cast(GetProp(hWnd, L"CJoystickWindows")); + CJoystickWindows *joystickWindows = static_cast(GetProp(hWnd, L"CJoystickWindows")); if (joystickWindows) { switch (uMsg) { case WM_DEVICECHANGE: - { - if (wParam == DBT_DEVICEARRIVAL) { - DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam; - if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + if (wParam == DBT_DEVICEARRIVAL) { - joystickWindows->enumJoystickDevices(); + // DEV_BROADCAST_HDR *dbh = reinterpret_cast(lParam); ??? + DEV_BROADCAST_HDR *dbh = (DEV_BROADCAST_HDR *) lParam; + if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) + { + joystickWindows->enumJoystickDevices(); + } } } } - } } return DefWindowProc(hWnd, uMsg, wParam, lParam); @@ -406,7 +409,7 @@ namespace BlackInput CJoystickWindows *obj = static_cast(pContext); /* ignore XInput devices here, keep going. */ - //if (isXInputDevice( &pdidInstance->guidProduct )) return DIENUM_CONTINUE; + // if (isXInputDevice(&pdidInstance->guidProduct)) return DIENUM_CONTINUE; if (! obj->isJoystickAlreadyAdded(pdidInstance)) { @@ -418,9 +421,9 @@ namespace BlackInput bool operator == (const CJoystickDevice &lhs, const CJoystickDevice &rhs) { - return lhs.m_guidDevice == rhs.m_guidDevice && + return lhs.m_guidDevice == rhs.m_guidDevice && lhs.m_guidProduct == rhs.m_guidProduct && - lhs.m_deviceName == rhs.m_deviceName && + lhs.m_deviceName == rhs.m_deviceName && lhs.m_productName == rhs.m_productName; } diff --git a/src/blackmisc/filedeleter.cpp b/src/blackmisc/filedeleter.cpp index 1e34b7e75..df0742567 100644 --- a/src/blackmisc/filedeleter.cpp +++ b/src/blackmisc/filedeleter.cpp @@ -18,13 +18,13 @@ namespace BlackMisc void CFileDeleter::addFileForDeletion(const QString &file) { if (file.isEmpty()) { return; } - if (!this->m_fileNames.contains(file)) this->m_fileNames.append(file); + if (!m_fileNames.contains(file)) m_fileNames.append(file); } void CFileDeleter::addFilesForDeletion(const QStringList &files) { if (files.isEmpty()) { return; } - this->m_fileNames.append(files); + m_fileNames.append(files); } CFileDeleter::~CFileDeleter() @@ -49,14 +49,15 @@ namespace BlackMisc QObject(parent) { Q_ASSERT_X(!file.isEmpty(), Q_FUNC_INFO, "No file name"); + this->setObjectName("CTimedFileDeleter"); if (deleteAfterMs < 100) { deleteAfterMs = 100; } // makes sure timer is started properly - this->m_fileDeleter.addFileForDeletion(file); + m_fileDeleter.addFileForDeletion(file); m_timerId = startTimer(deleteAfterMs); } void CTimedFileDeleter::timerEvent(QTimerEvent *event) { - Q_UNUSED(event); + Q_UNUSED(event) if (m_timerId > 0) { this->killTimer(m_timerId); } m_timerId = -1; m_fileDeleter.deleteFiles(); diff --git a/src/blacksound/codecs/opusdecoder.h b/src/blacksound/codecs/opusdecoder.h index 1e14f6240..bae7ab60f 100644 --- a/src/blacksound/codecs/opusdecoder.h +++ b/src/blacksound/codecs/opusdecoder.h @@ -30,14 +30,17 @@ namespace BlackSound //! Dtor ~COpusDecoder(); + //! Frame count int frameCount(int bufferSize); + //! Decode QVector decode(const QByteArray opusData, int dataLength, int *decodedLength); + //! Reset void resetState(); private: - OpusDecoder *opusDecoder; + OpusDecoder *opusDecoder = nullptr; int m_sampleRate; int m_channels; diff --git a/src/blacksound/dsp/biquadfilter.h b/src/blacksound/dsp/biquadfilter.h index 33fcb7dcd..d0281d1c3 100644 --- a/src/blacksound/dsp/biquadfilter.h +++ b/src/blacksound/dsp/biquadfilter.h @@ -30,7 +30,6 @@ namespace BlackSound void setPeakingEq(float sampleRate, float centreFrequency, float q, float dbGain); void setHighPassFilter(float sampleRate, float cutoffFrequency, float q); - static BiQuadFilter lowPassFilter(float sampleRate, float cutoffFrequency, float q); static BiQuadFilter highPassFilter(float sampleRate, float cutoffFrequency, float q); static BiQuadFilter peakingEQ(float sampleRate, float centreFrequency, float q, float dbGain); diff --git a/src/blacksound/sampleprovider/bufferedwaveprovider.cpp b/src/blacksound/sampleprovider/bufferedwaveprovider.cpp index bc1bab2be..3926239a0 100644 --- a/src/blacksound/sampleprovider/bufferedwaveprovider.cpp +++ b/src/blacksound/sampleprovider/bufferedwaveprovider.cpp @@ -25,7 +25,7 @@ namespace BlackSound int CBufferedWaveProvider::readSamples(QVector &samples, qint64 count) { - qint64 len = qMin(count, static_cast(m_audioBuffer.size())); + const int len = static_cast(qMin(count, static_cast(m_audioBuffer.size()))); samples = m_audioBuffer.mid(0, len); // if (len != 0) qDebug() << "Reading" << count << "samples." << m_audioBuffer.size() << "currently in the buffer."; m_audioBuffer.remove(0, len); diff --git a/src/blacksound/sampleprovider/mixingsampleprovider.h b/src/blacksound/sampleprovider/mixingsampleprovider.h index 1c769f22a..2bb6864e8 100644 --- a/src/blacksound/sampleprovider/mixingsampleprovider.h +++ b/src/blacksound/sampleprovider/mixingsampleprovider.h @@ -24,6 +24,7 @@ namespace BlackSound class BLACKSOUND_EXPORT CMixingSampleProvider : public ISampleProvider { public: + //! Ctor mixing provider CMixingSampleProvider(QObject *parent = nullptr) : ISampleProvider(parent) {} //! Add a provider diff --git a/src/blacksound/sampleprovider/pinknoisegenerator.cpp b/src/blacksound/sampleprovider/pinknoisegenerator.cpp index c424df9c5..b2e51a9b9 100644 --- a/src/blacksound/sampleprovider/pinknoisegenerator.cpp +++ b/src/blacksound/sampleprovider/pinknoisegenerator.cpp @@ -16,25 +16,26 @@ namespace BlackSound { int CPinkNoiseGenerator::readSamples(QVector &samples, qint64 count) { + const int c = static_cast(count); samples.clear(); - samples.fill(0, count); + samples.fill(0, c); for (int sampleCount = 0; sampleCount < count; sampleCount++) { - double white = 2 * random.generateDouble() - 1; + double white = 2 * m_random.generateDouble() - 1; - pinkNoiseBuffer[0] = 0.99886 * pinkNoiseBuffer[0] + white * 0.0555179; - pinkNoiseBuffer[1] = 0.99332 * pinkNoiseBuffer[1] + white * 0.0750759; - pinkNoiseBuffer[2] = 0.96900 * pinkNoiseBuffer[2] + white * 0.1538520; - pinkNoiseBuffer[3] = 0.86650 * pinkNoiseBuffer[3] + white * 0.3104856; - pinkNoiseBuffer[4] = 0.55000 * pinkNoiseBuffer[4] + white * 0.5329522; - pinkNoiseBuffer[5] = -0.7616 * pinkNoiseBuffer[5] - white * 0.0168980; - double pink = pinkNoiseBuffer[0] + pinkNoiseBuffer[1] + pinkNoiseBuffer[2] + pinkNoiseBuffer[3] + pinkNoiseBuffer[4] + pinkNoiseBuffer[5] + pinkNoiseBuffer[6] + white * 0.5362; - pinkNoiseBuffer[6] = white * 0.115926; - double sampleValue = (m_gain * (pink / 5)); + m_pinkNoiseBuffer[0] = 0.99886 * m_pinkNoiseBuffer[0] + white * 0.0555179; + m_pinkNoiseBuffer[1] = 0.99332 * m_pinkNoiseBuffer[1] + white * 0.0750759; + m_pinkNoiseBuffer[2] = 0.96900 * m_pinkNoiseBuffer[2] + white * 0.1538520; + m_pinkNoiseBuffer[3] = 0.86650 * m_pinkNoiseBuffer[3] + white * 0.3104856; + m_pinkNoiseBuffer[4] = 0.55000 * m_pinkNoiseBuffer[4] + white * 0.5329522; + m_pinkNoiseBuffer[5] = -0.7616 * m_pinkNoiseBuffer[5] - white * 0.0168980; + double pink = m_pinkNoiseBuffer[0] + m_pinkNoiseBuffer[1] + m_pinkNoiseBuffer[2] + m_pinkNoiseBuffer[3] + m_pinkNoiseBuffer[4] + m_pinkNoiseBuffer[5] + m_pinkNoiseBuffer[6] + white * 0.5362; + m_pinkNoiseBuffer[6] = white * 0.115926; + const float sampleValue = static_cast(m_gain * (pink / 5)); samples[sampleCount] = sampleValue; } - return count; + return c; } } } diff --git a/src/blacksound/sampleprovider/pinknoisegenerator.h b/src/blacksound/sampleprovider/pinknoisegenerator.h index 214fbeefd..74b575a29 100644 --- a/src/blacksound/sampleprovider/pinknoisegenerator.h +++ b/src/blacksound/sampleprovider/pinknoisegenerator.h @@ -39,8 +39,8 @@ namespace BlackSound void setGain(double gain) { m_gain = gain; } private: - QRandomGenerator random; - std::array pinkNoiseBuffer = {{0}}; + QRandomGenerator m_random; + std::array m_pinkNoiseBuffer = {{0}}; double m_gain = 0.0; }; } diff --git a/src/blacksound/sampleprovider/resourcesound.h b/src/blacksound/sampleprovider/resourcesound.h index 7a271b601..e058d74a2 100644 --- a/src/blacksound/sampleprovider/resourcesound.h +++ b/src/blacksound/sampleprovider/resourcesound.h @@ -24,7 +24,6 @@ namespace BlackSound { namespace SampleProvider { - //! CResourceSound shared data struct CResourceSoundData : public QSharedData { diff --git a/src/blacksound/sampleprovider/resourcesoundsampleprovider.h b/src/blacksound/sampleprovider/resourcesoundsampleprovider.h index 031419edc..ca0ac3c72 100644 --- a/src/blacksound/sampleprovider/resourcesoundsampleprovider.h +++ b/src/blacksound/sampleprovider/resourcesoundsampleprovider.h @@ -48,8 +48,7 @@ namespace BlackSound CResourceSound m_resourceSound; qint64 m_position = 0; - // const int m_tempBufferSize = 9600; //9600 = 200ms - const int m_tempBufferSize = 24000; //24000 = 500ms (avoid " + const int m_tempBufferSize = 24000; //24000 = 500ms (avoid buffer overflow), m_tempBufferSize = 9600; //9600 = 200ms QVector m_tempBuffer; bool m_isFinished = false; }; diff --git a/src/blacksound/sampleprovider/sawtoothgenerator.cpp b/src/blacksound/sampleprovider/sawtoothgenerator.cpp index cd62b59e2..c16ec1737 100644 --- a/src/blacksound/sampleprovider/sawtoothgenerator.cpp +++ b/src/blacksound/sampleprovider/sawtoothgenerator.cpp @@ -16,7 +16,9 @@ namespace BlackSound CSawToothGenerator::CSawToothGenerator(double frequency, QObject *parent) : ISampleProvider(parent), m_frequency(frequency) - {} + { + this->setObjectName("CSawToothGenerator"); + } int CSawToothGenerator::readSamples(QVector &samples, qint64 count) { diff --git a/src/blacksound/sampleprovider/sawtoothgenerator.h b/src/blacksound/sampleprovider/sawtoothgenerator.h index 2764aaaa1..1bc6bd527 100644 --- a/src/blacksound/sampleprovider/sawtoothgenerator.h +++ b/src/blacksound/sampleprovider/sawtoothgenerator.h @@ -37,10 +37,10 @@ namespace BlackSound void setGain(double gain) { m_gain = gain; } private: - double m_gain = 0.0; - double m_frequency = 0.0; + double m_gain = 0.0; + double m_frequency = 0.0; double m_sampleRate = 48000; - int m_nSample = 0; + int m_nSample = 0; }; } // ns } // ns