diff --git a/plugins/channelrx/wdsprx/wdsprx.cpp b/plugins/channelrx/wdsprx/wdsprx.cpp index 12f5f4670..80f8fef53 100644 --- a/plugins/channelrx/wdsprx/wdsprx.cpp +++ b/plugins/channelrx/wdsprx/wdsprx.cpp @@ -84,6 +84,7 @@ WDSPRx::WDSPRx(DeviceAPI *deviceAPI) : WDSPRx::~WDSPRx() { + qDebug("WDSPRx::~WDSPRx"); QObject::disconnect( m_networkManager, &QNetworkAccessManager::finished, @@ -94,7 +95,8 @@ WDSPRx::~WDSPRx() m_deviceAPI->removeChannelSinkAPI(this); m_deviceAPI->removeChannelSink(this); - stop(); + WDSPRx::stop(); + qDebug("WDSPRx::~WDSPRx: emd"); } void WDSPRx::setDeviceAPI(DeviceAPI *deviceAPI) @@ -196,7 +198,7 @@ bool WDSPRx::handleMessage(const Message& cmd) { if (MsgConfigureWDSPRx::match(cmd)) { - MsgConfigureWDSPRx& cfg = (MsgConfigureWDSPRx&) cmd; + auto& cfg = (const MsgConfigureWDSPRx&) cmd; qDebug("WDSPRx::handleMessage: MsgConfigureWDSPRx"); applySettings(cfg.getSettings(), cfg.getForce()); @@ -206,7 +208,7 @@ bool WDSPRx::handleMessage(const Message& cmd) else if (DSPSignalNotification::match(cmd)) { qDebug() << "WDSPRx::handleMessage: DSPSignalNotification"; - DSPSignalNotification& notif = (DSPSignalNotification&) cmd; + auto& notif = (const DSPSignalNotification&) cmd; m_basebandSampleRate = notif.getSampleRate(); // Forward to the sink if (m_running) { @@ -235,7 +237,7 @@ bool WDSPRx::handleMessage(const Message& cmd) void WDSPRx::setCenterFrequency(qint64 frequency) { WDSPRxSettings settings = m_settings; - settings.m_inputFrequencyOffset = frequency; + settings.m_inputFrequencyOffset = (qint32) frequency; applySettings(settings, false); if (m_guiMessageQueue) // forward to GUI if any @@ -360,7 +362,7 @@ void WDSPRx::applySettings(const WDSPRxSettings& settings, bool force) QList pipes; MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes); - if (pipes.size() > 0) { + if (!pipes.empty()) { sendChannelSettings(pipes, reverseAPIKeys, settings, force); } @@ -389,12 +391,12 @@ bool WDSPRx::deserialize(const QByteArray& data) } } -void WDSPRx::sendSampleRateToDemodAnalyzer() +void WDSPRx::sendSampleRateToDemodAnalyzer() const { QList pipes; MainCore::instance()->getMessagePipes().getMessagePipes(this, "reportdemod", pipes); - if (pipes.size() > 0) + if (!pipes.empty()) { for (const auto& pipe: pipes) { @@ -463,7 +465,7 @@ void WDSPRx::webapiUpdateChannelSettings( SWGSDRangel::SWGChannelSettings& response) { if (channelSettingsKeys.contains("inputFrequencyOffset")) { - settings.m_inputFrequencyOffset = response.getWdspRxSettings()->getInputFrequencyOffset(); + settings.m_inputFrequencyOffset = (qint32) response.getWdspRxSettings()->getInputFrequencyOffset(); } if (channelSettingsKeys.contains("profileIndex")) { settings.m_profileIndex = response.getWdspRxSettings()->getProfileIndex(); @@ -669,13 +671,13 @@ void WDSPRx::webapiUpdateChannelSettings( settings.m_reverseAPIAddress = *response.getWdspRxSettings()->getReverseApiAddress(); } if (channelSettingsKeys.contains("reverseAPIPort")) { - settings.m_reverseAPIPort = response.getWdspRxSettings()->getReverseApiPort(); + settings.m_reverseAPIPort = (uint16_t) response.getWdspRxSettings()->getReverseApiPort(); } if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) { - settings.m_reverseAPIDeviceIndex = response.getWdspRxSettings()->getReverseApiDeviceIndex(); + settings.m_reverseAPIDeviceIndex = (uint16_t) response.getWdspRxSettings()->getReverseApiDeviceIndex(); } if (channelSettingsKeys.contains("reverseAPIChannelIndex")) { - settings.m_reverseAPIChannelIndex = response.getWdspRxSettings()->getReverseApiChannelIndex(); + settings.m_reverseAPIChannelIndex = (uint16_t) response.getWdspRxSettings()->getReverseApiChannelIndex(); } if (settings.m_spectrumGUI && channelSettingsKeys.contains("spectrumConfig")) { settings.m_spectrumGUI->updateFrom(channelSettingsKeys, response.getWdspRxSettings()->getSpectrumConfig()); @@ -717,11 +719,11 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon response.getWdspRxSettings()->setDnb(settings.m_dnb ? 1 : 0); response.getWdspRxSettings()->setNbScheme((int) settings.m_nbScheme); response.getWdspRxSettings()->setNb2Mode((int) settings.m_nb2Mode); - response.getWdspRxSettings()->setNbSlewTime(settings.m_nbSlewTime); - response.getWdspRxSettings()->setNbLeadTime(settings.m_nbLeadTime); - response.getWdspRxSettings()->setNbLagTime(settings.m_nbLagTime); + response.getWdspRxSettings()->setNbSlewTime((float) settings.m_nbSlewTime); + response.getWdspRxSettings()->setNbLeadTime((float) settings.m_nbLeadTime); + response.getWdspRxSettings()->setNbLagTime((float) settings.m_nbLagTime); response.getWdspRxSettings()->setNbThreshold(settings.m_nbThreshold); - response.getWdspRxSettings()->setNbAvgTime(settings.m_nbAvgTime); + response.getWdspRxSettings()->setNbAvgTime((float) settings.m_nbAvgTime); response.getWdspRxSettings()->setDnr(settings.m_dnr ? 1 : 0); response.getWdspRxSettings()->setAnf(settings.m_anf ? 1 : 0); response.getWdspRxSettings()->setNrScheme((int) settings.m_nrScheme); @@ -731,22 +733,22 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon response.getWdspRxSettings()->setNr2ArtifactReduction(settings.m_nr2ArtifactReduction ? 1 : 0); response.getWdspRxSettings()->setAmFadeLevel(settings.m_amFadeLevel ? 1 : 0); response.getWdspRxSettings()->setCwPeaking(settings.m_cwPeaking ? 1 : 0); - response.getWdspRxSettings()->setCwPeakFrequency(settings.m_cwPeakFrequency); - response.getWdspRxSettings()->setCwBandwidth(settings.m_cwBandwidth); - response.getWdspRxSettings()->setCwGain(settings.m_cwGain); - response.getWdspRxSettings()->setFmDeviation(settings.m_fmDeviation); - response.getWdspRxSettings()->setFmAfLow(settings.m_fmAFLow); - response.getWdspRxSettings()->setFmAfHigh(settings.m_fmAFHigh); + response.getWdspRxSettings()->setCwPeakFrequency((float) settings.m_cwPeakFrequency); + response.getWdspRxSettings()->setCwBandwidth((float) settings.m_cwBandwidth); + response.getWdspRxSettings()->setCwGain((float) settings.m_cwGain); + response.getWdspRxSettings()->setFmDeviation((float) settings.m_fmDeviation); + response.getWdspRxSettings()->setFmAfLow((float) settings.m_fmAFLow); + response.getWdspRxSettings()->setFmAfHigh((float) settings.m_fmAFHigh); response.getWdspRxSettings()->setFmAfLimiter(settings.m_fmAFLimiter ? 1 : 0); - response.getWdspRxSettings()->setFmAfLimiterGain(settings.m_fmAFLimiterGain); + response.getWdspRxSettings()->setFmAfLimiterGain((float) settings.m_fmAFLimiterGain); response.getWdspRxSettings()->setFmCtcssNotch(settings.m_fmCTCSSNotch ? 1 : 0); - response.getWdspRxSettings()->setFmCtcssNotchFrequency(settings.m_fmCTCSSNotchFrequency); + response.getWdspRxSettings()->setFmCtcssNotchFrequency((float) settings.m_fmCTCSSNotchFrequency); response.getWdspRxSettings()->setSquelch(settings.m_squelch ? 1 : 0); response.getWdspRxSettings()->setSquelchThreshold(settings.m_squelchThreshold); response.getWdspRxSettings()->setSquelchMode((int) settings.m_squelchMode); - response.getWdspRxSettings()->setSsqlTauMute(settings.m_ssqlTauMute); - response.getWdspRxSettings()->setSsqlTauUnmute(settings.m_ssqlTauUnmute); - response.getWdspRxSettings()->setAmsqMaxTail(settings.m_amsqMaxTail); + response.getWdspRxSettings()->setSsqlTauMute((float) settings.m_ssqlTauMute); + response.getWdspRxSettings()->setSsqlTauUnmute((float) settings.m_ssqlTauUnmute); + response.getWdspRxSettings()->setAmsqMaxTail((float) settings.m_amsqMaxTail); response.getWdspRxSettings()->setEqualizer(settings.m_equalizer ? 1 : 0); if (!response.getWdspRxSettings()->getEqF()) { @@ -770,11 +772,11 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon } response.getWdspRxSettings()->setRit(settings.m_rit ? 1 : 0); - response.getWdspRxSettings()->setRitFrequency(settings.m_ritFrequency); + response.getWdspRxSettings()->setRitFrequency((float) settings.m_ritFrequency); response.getWdspRxSettings()->setSpanLog2(settings.m_profiles[settings.m_profileIndex].m_spanLog2); response.getWdspRxSettings()->setRfBandwidth(settings.m_profiles[settings.m_profileIndex].m_highCutoff); response.getWdspRxSettings()->setLowCutoff(settings.m_profiles[settings.m_profileIndex].m_lowCutoff); - response.getWdspRxSettings()->setFftWindow((int) settings.m_profiles[settings.m_profileIndex].m_fftWindow); + response.getWdspRxSettings()->setFftWindow(settings.m_profiles[settings.m_profileIndex].m_fftWindow); response.getWdspRxSettings()->setRgbColor(settings.m_rgbColor); if (response.getWdspRxSettings()->getTitle()) { @@ -810,7 +812,7 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon } else { - SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum(); + auto *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum(); settings.m_spectrumGUI->formatTo(swgGLSpectrum); response.getWdspRxSettings()->setSpectrumConfig(swgGLSpectrum); } @@ -824,7 +826,7 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon } else { - SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker(); + auto *swgChannelMarker = new SWGSDRangel::SWGChannelMarker(); settings.m_channelMarker->formatTo(swgChannelMarker); response.getWdspRxSettings()->setChannelMarker(swgChannelMarker); } @@ -838,7 +840,7 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon } else { - SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState(); + auto *swgRollupState = new SWGSDRangel::SWGRollupState(); settings.m_rollupState->formatTo(swgRollupState); response.getWdspRxSettings()->setRollupState(swgRollupState); } @@ -847,11 +849,12 @@ void WDSPRx::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon void WDSPRx::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) { - double magsqAvg, magsqPeak; + double magsqAvg; + double magsqPeak; int nbMagsqSamples; getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples); - response.getSsbDemodReport()->setChannelPowerDb(CalcDb::dbPower(magsqAvg)); + response.getSsbDemodReport()->setChannelPowerDb((float) CalcDb::dbPower(magsqAvg)); if (m_running) { @@ -861,9 +864,9 @@ void WDSPRx::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) } } -void WDSPRx::webapiReverseSendSettings(QList& channelSettingsKeys, const WDSPRxSettings& settings, bool force) +void WDSPRx::webapiReverseSendSettings(const QList& channelSettingsKeys, const WDSPRxSettings& settings, bool force) { - SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings(); + auto *swgChannelSettings = new SWGSDRangel::SWGChannelSettings(); webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force); QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings") @@ -874,8 +877,8 @@ void WDSPRx::webapiReverseSendSettings(QList& channelSettingsKeys, cons m_networkRequest.setUrl(QUrl(channelSettingsURL)); m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QBuffer *buffer = new QBuffer(); - buffer->open((QBuffer::ReadWrite)); + auto *buffer = new QBuffer(); + buffer->open(QBuffer::ReadWrite); buffer->write(swgChannelSettings->asJson().toUtf8()); buffer->seek(0); @@ -888,9 +891,9 @@ void WDSPRx::webapiReverseSendSettings(QList& channelSettingsKeys, cons void WDSPRx::sendChannelSettings( const QList& pipes, - QList& channelSettingsKeys, + const QList& channelSettingsKeys, const WDSPRxSettings& settings, - bool force) + bool force) const { qDebug("WDSPRx::sendChannelSettings: %d pipes", pipes.size()); @@ -900,7 +903,7 @@ void WDSPRx::sendChannelSettings( if (messageQueue) { - SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings(); + auto *swgChannelSettings = new SWGSDRangel::SWGChannelSettings(); webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force); MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create( this, @@ -914,11 +917,11 @@ void WDSPRx::sendChannelSettings( } void WDSPRx::webapiFormatChannelSettings( - QList& channelSettingsKeys, + const QList& channelSettingsKeys, SWGSDRangel::SWGChannelSettings *swgChannelSettings, const WDSPRxSettings& settings, bool force -) +) const { swgChannelSettings->setDirection(0); // Single sink (Rx) swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet()); @@ -978,19 +981,19 @@ void WDSPRx::webapiFormatChannelSettings( swgWDSPRxSettings->setNb2Mode((int) settings.m_nb2Mode); } if (channelSettingsKeys.contains("nbSlewTime")) { - swgWDSPRxSettings->setNbSlewTime(settings.m_nbSlewTime); + swgWDSPRxSettings->setNbSlewTime((float) settings.m_nbSlewTime); } if (channelSettingsKeys.contains("nbLeadTime")) { - swgWDSPRxSettings->setNbLeadTime(settings.m_nbSlewTime); + swgWDSPRxSettings->setNbLeadTime((float) settings.m_nbSlewTime); } if (channelSettingsKeys.contains("nbLagTime")) { - swgWDSPRxSettings->setNbLagTime(settings.m_nbLagTime); + swgWDSPRxSettings->setNbLagTime((float) settings.m_nbLagTime); } if (channelSettingsKeys.contains("nbThreshold")) { swgWDSPRxSettings->setNbThreshold(settings.m_nbThreshold); } if (channelSettingsKeys.contains("nbAvgTime")) { - swgWDSPRxSettings->setNbAvgTime(settings.m_nbAvgTime); + swgWDSPRxSettings->setNbAvgTime((float) settings.m_nbAvgTime); } if (channelSettingsKeys.contains("dnr")) { swgWDSPRxSettings->setDnr(settings.m_dnr ? 1 : 0); @@ -1020,34 +1023,34 @@ void WDSPRx::webapiFormatChannelSettings( swgWDSPRxSettings->setCwPeaking(settings.m_cwPeaking ? 1 : 0); } if (channelSettingsKeys.contains("cwPeakFrequency")) { - swgWDSPRxSettings->setCwPeakFrequency(settings.m_cwPeakFrequency); + swgWDSPRxSettings->setCwPeakFrequency((float) settings.m_cwPeakFrequency); } if (channelSettingsKeys.contains("cwBandwidth")) { - swgWDSPRxSettings->setCwBandwidth(settings.m_cwBandwidth); + swgWDSPRxSettings->setCwBandwidth((float) settings.m_cwBandwidth); } if (channelSettingsKeys.contains("cwGain")) { - swgWDSPRxSettings->setCwGain(settings.m_cwGain); + swgWDSPRxSettings->setCwGain((float) settings.m_cwGain); } if (channelSettingsKeys.contains("fmDeviation")) { - swgWDSPRxSettings->setFmDeviation(settings.m_fmDeviation); + swgWDSPRxSettings->setFmDeviation((float) settings.m_fmDeviation); } if (channelSettingsKeys.contains("fmAFLow")) { - swgWDSPRxSettings->setFmAfLow(settings.m_fmAFLow); + swgWDSPRxSettings->setFmAfLow((float) settings.m_fmAFLow); } if (channelSettingsKeys.contains("fmAFHigh")) { - swgWDSPRxSettings->setFmAfHigh(settings.m_fmAFHigh); + swgWDSPRxSettings->setFmAfHigh((float) settings.m_fmAFHigh); } if (channelSettingsKeys.contains("fmAFLimiter")) { swgWDSPRxSettings->setFmAfLimiter(settings.m_fmAFLimiter ? 1 : 0); } if (channelSettingsKeys.contains("fmAFLimiterGain")) { - swgWDSPRxSettings->setFmAfLimiterGain(settings.m_fmAFLimiterGain); + swgWDSPRxSettings->setFmAfLimiterGain((float) settings.m_fmAFLimiterGain); } if (channelSettingsKeys.contains("fmCTCSSNotch")) { swgWDSPRxSettings->setFmCtcssNotch(settings.m_fmCTCSSNotch ? 1 : 0); } if (channelSettingsKeys.contains("fmCTCSSNotchFrequency")) { - swgWDSPRxSettings->setFmCtcssNotchFrequency(settings.m_fmCTCSSNotchFrequency); + swgWDSPRxSettings->setFmCtcssNotchFrequency((float) settings.m_fmCTCSSNotchFrequency); } if (channelSettingsKeys.contains("squelch")) { swgWDSPRxSettings->setSquelch(settings.m_squelch ? 1 : 0); @@ -1059,13 +1062,13 @@ void WDSPRx::webapiFormatChannelSettings( swgWDSPRxSettings->setSquelchMode((int) settings.m_squelchMode); } if (channelSettingsKeys.contains("ssqlTauMute")) { - swgWDSPRxSettings->setSsqlTauMute(settings.m_ssqlTauMute); + swgWDSPRxSettings->setSsqlTauMute((float) settings.m_ssqlTauMute); } if (channelSettingsKeys.contains("ssqlTauUnmute")) { - swgWDSPRxSettings->setSsqlTauUnmute(settings.m_ssqlTauUnmute); + swgWDSPRxSettings->setSsqlTauUnmute((float) settings.m_ssqlTauUnmute); } if (channelSettingsKeys.contains("amsqMaxTail")) { - swgWDSPRxSettings->setAmsqMaxTail(settings.m_amsqMaxTail); + swgWDSPRxSettings->setAmsqMaxTail((float) settings.m_amsqMaxTail); } if (channelSettingsKeys.contains("equalizer")) { swgWDSPRxSettings->setEqualizer(settings.m_equalizer ? 1 : 0); @@ -1101,7 +1104,7 @@ void WDSPRx::webapiFormatChannelSettings( swgWDSPRxSettings->setRit(settings.m_rit ? 1 : 0); } if (channelSettingsKeys.contains("ritFrequency")) { - swgWDSPRxSettings->setRit(settings.m_ritFrequency); + swgWDSPRxSettings->setRit((qint32) settings.m_ritFrequency); } if (channelSettingsKeys.contains("spanLog2") || force) { swgWDSPRxSettings->setSpanLog2(settings.m_profiles[settings.m_profileIndex].m_spanLog2); @@ -1113,7 +1116,7 @@ void WDSPRx::webapiFormatChannelSettings( swgWDSPRxSettings->setLowCutoff(settings.m_profiles[settings.m_profileIndex].m_lowCutoff); } if (channelSettingsKeys.contains("fftWindow") || force) { - swgWDSPRxSettings->setLowCutoff(settings.m_profiles[settings.m_profileIndex].m_fftWindow); + swgWDSPRxSettings->setLowCutoff((float) settings.m_profiles[settings.m_profileIndex].m_fftWindow); } if (channelSettingsKeys.contains("rgbColor") || force) { swgWDSPRxSettings->setRgbColor(settings.m_rgbColor); @@ -1130,27 +1133,27 @@ void WDSPRx::webapiFormatChannelSettings( if (settings.m_spectrumGUI && (channelSettingsKeys.contains("spectrunConfig") || force)) { - SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum(); + auto *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum(); settings.m_spectrumGUI->formatTo(swgGLSpectrum); swgWDSPRxSettings->setSpectrumConfig(swgGLSpectrum); } if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force)) { - SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker(); + auto *swgChannelMarker = new SWGSDRangel::SWGChannelMarker(); settings.m_channelMarker->formatTo(swgChannelMarker); swgWDSPRxSettings->setChannelMarker(swgChannelMarker); } if (settings.m_rollupState && (channelSettingsKeys.contains("rollupState") || force)) { - SWGSDRangel::SWGRollupState *swgRolllupState = new SWGSDRangel::SWGRollupState(); + auto *swgRolllupState = new SWGSDRangel::SWGRollupState(); settings.m_rollupState->formatTo(swgRolllupState); swgWDSPRxSettings->setRollupState(swgRolllupState); } } -void WDSPRx::networkManagerFinished(QNetworkReply *reply) +void WDSPRx::networkManagerFinished(QNetworkReply *reply) const { QNetworkReply::NetworkError replyError = reply->error(); diff --git a/plugins/channelrx/wdsprx/wdsprx.h b/plugins/channelrx/wdsprx/wdsprx.h index cd3c5e44e..b7b7b95c6 100644 --- a/plugins/channelrx/wdsprx/wdsprx.h +++ b/plugins/channelrx/wdsprx/wdsprx.h @@ -67,34 +67,34 @@ public: { } }; - WDSPRx(DeviceAPI *deviceAPI); - virtual ~WDSPRx(); - virtual void destroy() { delete this; } - virtual void setDeviceAPI(DeviceAPI *deviceAPI); - virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; } + explicit WDSPRx(DeviceAPI *deviceAPI); + ~WDSPRx() final; + void destroy() final { delete this; } + void setDeviceAPI(DeviceAPI *deviceAPI) final; + DeviceAPI *getDeviceAPI() final { return m_deviceAPI; } SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } using BasebandSampleSink::feed; - virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); - virtual void start(); - virtual void stop(); - virtual void pushMessage(Message *msg) { m_inputMessageQueue.push(msg); } - virtual QString getSinkName() { return objectName(); } + void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po) final; + void start() final; + void stop() final; + void pushMessage(Message *msg) final { m_inputMessageQueue.push(msg); } + QString getSinkName() final { return objectName(); } - virtual void getIdentifier(QString& id) { id = objectName(); } - virtual QString getIdentifier() const { return objectName(); } - virtual void getTitle(QString& title) { title = m_settings.m_title; } - virtual qint64 getCenterFrequency() const { return m_settings.m_inputFrequencyOffset; } - virtual void setCenterFrequency(qint64 frequency); + void getIdentifier(QString& id) final { id = objectName(); } + QString getIdentifier() const final { return objectName(); } + void getTitle(QString& title) final { title = m_settings.m_title; } + qint64 getCenterFrequency() const final { return m_settings.m_inputFrequencyOffset; } + void setCenterFrequency(qint64 frequency) final; - virtual QByteArray serialize() const; - virtual bool deserialize(const QByteArray& data); + QByteArray serialize() const final; + bool deserialize(const QByteArray& data) final; - virtual int getNbSinkStreams() const { return 1; } - virtual int getNbSourceStreams() const { return 0; } - virtual int getStreamIndex() const { return m_settings.m_streamIndex; } + int getNbSinkStreams() const final { return 1; } + int getNbSourceStreams() const final { return 0; } + int getStreamIndex() const final { return m_settings.m_streamIndex; } - virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const + qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const final { (void) streamIndex; (void) sinkElseSource; @@ -116,32 +116,32 @@ public: } } - virtual int webapiSettingsGet( - SWGSDRangel::SWGChannelSettings& response, - QString& errorMessage); + int webapiSettingsGet( + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) final; - virtual int webapiWorkspaceGet( - SWGSDRangel::SWGWorkspaceInfo& response, - QString& errorMessage); + int webapiWorkspaceGet( + SWGSDRangel::SWGWorkspaceInfo& response, + QString& errorMessage) final; - virtual int webapiSettingsPutPatch( - bool force, - const QStringList& channelSettingsKeys, - SWGSDRangel::SWGChannelSettings& response, - QString& errorMessage); + int webapiSettingsPutPatch( + bool force, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, + QString& errorMessage) final; - virtual int webapiReportGet( - SWGSDRangel::SWGChannelReport& response, - QString& errorMessage); + int webapiReportGet( + SWGSDRangel::SWGChannelReport& response, + QString& errorMessage) final; static void webapiFormatChannelSettings( SWGSDRangel::SWGChannelSettings& response, const WDSPRxSettings& settings); static void webapiUpdateChannelSettings( - WDSPRxSettings& settings, - const QStringList& channelSettingsKeys, - SWGSDRangel::SWGChannelSettings& response); + WDSPRxSettings& settings, + const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response); uint32_t getNumberOfDeviceStreams() const; @@ -161,26 +161,26 @@ private: QNetworkAccessManager *m_networkManager; QNetworkRequest m_networkRequest; - virtual bool handleMessage(const Message& cmd); + bool handleMessage(const Message& cmd) final; void applySettings(const WDSPRxSettings& settings, bool force = false); - void sendSampleRateToDemodAnalyzer(); + void sendSampleRateToDemodAnalyzer() const; void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response); - void webapiReverseSendSettings(QList& channelSettingsKeys, const WDSPRxSettings& settings, bool force); + void webapiReverseSendSettings(const QList& channelSettingsKeys, const WDSPRxSettings& settings, bool force); void sendChannelSettings( const QList& pipes, - QList& channelSettingsKeys, + const QList& channelSettingsKeys, const WDSPRxSettings& settings, bool force - ); + ) const; void webapiFormatChannelSettings( - QList& channelSettingsKeys, + const QList& channelSettingsKeys, SWGSDRangel::SWGChannelSettings *swgChannelSettings, const WDSPRxSettings& settings, bool force - ); + ) const; private slots: - void networkManagerFinished(QNetworkReply *reply); + void networkManagerFinished(QNetworkReply *reply) const; void handleIndexInDeviceSetChanged(int index); }; diff --git a/plugins/channelrx/wdsprx/wdsprxgui.cpp b/plugins/channelrx/wdsprx/wdsprxgui.cpp index bb6cd0717..8a403ac3b 100644 --- a/plugins/channelrx/wdsprx/wdsprxgui.cpp +++ b/plugins/channelrx/wdsprx/wdsprxgui.cpp @@ -53,11 +53,6 @@ WDSPRxGUI* WDSPRxGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas return gui; } -void WDSPRxGUI::destroy() -{ - delete this; -} - void WDSPRxGUI::resetToDefaults() { m_settings.resetToDefaults(); @@ -610,6 +605,7 @@ WDSPRxGUI::WDSPRxGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam WDSPRxGUI::~WDSPRxGUI() { + qDebug("WDSPRxGUI::~WDSPRxGUI"); delete ui; delete m_audioMuteRightClickEnabler; delete m_agcRightClickEnabler; @@ -620,6 +616,7 @@ WDSPRxGUI::~WDSPRxGUI() delete m_equalizerRightClickEnabler; delete m_panRightClickEnabler; delete m_demodRightClickEnabler; + qDebug("WDSPRxGUI::~WDSPRxGUI: end"); } bool WDSPRxGUI::blockApplySettings(bool block) diff --git a/plugins/channelrx/wdsprx/wdsprxgui.h b/plugins/channelrx/wdsprx/wdsprxgui.h index 3f2b59da3..fb354eda7 100644 --- a/plugins/channelrx/wdsprx/wdsprxgui.h +++ b/plugins/channelrx/wdsprx/wdsprxgui.h @@ -56,7 +56,6 @@ class WDSPRxGUI : public ChannelGUI { public: static WDSPRxGUI* create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel); - virtual void destroy(); void resetToDefaults() final; QByteArray serialize() const final; diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp index e640ec5e0..5e0727f5b 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp @@ -43,7 +43,7 @@ RTLSDRGui::RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent) : m_forceSettings(true), m_settings(), m_sampleRateMode(true), - m_sampleSource(0) + m_sampleSource(nullptr) { m_deviceUISet = deviceUISet; setAttribute(Qt::WA_DeleteOnClose, true); @@ -92,11 +92,6 @@ RTLSDRGui::~RTLSDRGui() qDebug("RTLSDRGui::~RTLSDRGui: end"); } -void RTLSDRGui::destroy() -{ - delete this; -} - void RTLSDRGui::resetToDefaults() { m_settings.resetToDefaults(); @@ -145,23 +140,23 @@ bool RTLSDRGui::handleMessage(const Message& message) { if (RTLSDRInput::MsgConfigureRTLSDR::match(message)) { - const RTLSDRInput::MsgConfigureRTLSDR& cfg = (RTLSDRInput::MsgConfigureRTLSDR&) message; + auto& cfg = (const RTLSDRInput::MsgConfigureRTLSDR&) message; if (cfg.getForce()) { - m_settings = cfg.getSettings(); + m_settings = cfg.getSettings(); } else { m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings()); } - blockApplySettings(true); - displayGains(); - displaySettings(); - blockApplySettings(false); - return true; + blockApplySettings(true); + displayGains(); + displaySettings(); + blockApplySettings(false); + return true; } else if (RTLSDRInput::MsgStartStop::match(message)) { - RTLSDRInput::MsgStartStop& notif = (RTLSDRInput::MsgStartStop&) message; + auto& notif = (const RTLSDRInput::MsgStartStop&) message; blockApplySettings(true); ui->startStop->setChecked(notif.getStartStop()); blockApplySettings(false); @@ -178,13 +173,13 @@ void RTLSDRGui::handleInputMessages() { Message* message; - while ((message = m_inputMessageQueue.pop()) != 0) + while ((message = m_inputMessageQueue.pop()) != nullptr) { qDebug("RTLSDRGui::handleInputMessages: message: %s", message->getIdentifier()); if (DSPSignalNotification::match(*message)) { - DSPSignalNotification* notif = (DSPSignalNotification*) message; + auto* notif = (const DSPSignalNotification*) message; m_sampleRate = notif->getSampleRate(); m_deviceCenterFrequency = notif->getCenterFrequency(); qDebug("RTLSDRGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); @@ -213,7 +208,7 @@ void RTLSDRGui::updateFrequencyLimits() { // values in kHz qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0; - qint64 minLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMin : m_sampleSource->m_frequencyHighRangeMin) + deltaFrequency; + qint64 minLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMin : m_sampleSource->getFrequencyHighRangeMin()) + deltaFrequency; qint64 maxLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMax : RTLSDRInput::frequencyHighRangeMax) + deltaFrequency; if (m_settings.m_transverterMode) @@ -233,7 +228,7 @@ void RTLSDRGui::updateFrequencyLimits() void RTLSDRGui::displayGains() { - if (m_gains.size() > 0) + if (!m_gains.empty()) { int dist = abs(m_settings.m_gain - m_gains[0]); int pos = 0; @@ -248,7 +243,7 @@ void RTLSDRGui::displayGains() } ui->gainText->setText(tr("%1.%2").arg(m_gains[pos] / 10).arg(abs(m_gains[pos] % 10))); - ui->gain->setMaximum(m_gains.size() - 1); + ui->gain->setMaximum((int) (m_gains.size() - 1)); ui->gain->setEnabled(true); ui->gain->setValue(pos); } @@ -280,7 +275,7 @@ void RTLSDRGui::displaySampleRate() ui->sampleRate->setToolTip("Device to host sample rate (S/s)"); ui->deviceRateText->setToolTip("Baseband sample rate (S/s)"); uint32_t basebandSampleRate = m_settings.m_devSampleRate/(1<deviceRateText->setText(tr("%1k").arg(QString::number(basebandSampleRate / 1000.0f, 'g', 5))); + ui->deviceRateText->setText(tr("%1k").arg(QString::number((float) basebandSampleRate / 1000.0f, 'g', 5))); } else { @@ -296,7 +291,7 @@ void RTLSDRGui::displaySampleRate() ui->sampleRate->setValue(m_settings.m_devSampleRate/(1<sampleRate->setToolTip("Baseband sample rate (S/s)"); ui->deviceRateText->setToolTip("Device to host sample rate (S/s)"); - ui->deviceRateText->setText(tr("%1k").arg(QString::number(m_settings.m_devSampleRate / 1000.0f, 'g', 5))); + ui->deviceRateText->setText(tr("%1k").arg(QString::number((float) m_settings.m_devSampleRate / 1000.0f, 'g', 5))); } ui->sampleRate->blockSignals(false); @@ -310,7 +305,7 @@ void RTLSDRGui::displayFcTooltip() m_settings.m_devSampleRate, DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD ); - ui->fcPos->setToolTip(tr("Relative position of device center frequency: %1 kHz").arg(QString::number(fShift / 1000.0f, 'g', 5))); + ui->fcPos->setToolTip(tr("Relative position of device center frequency: %1 kHz").arg(QString::number((float) fShift / 1000.0f, 'g', 5))); } void RTLSDRGui::displaySettings() @@ -363,9 +358,9 @@ void RTLSDRGui::on_decim_currentIndexChanged(int index) displaySampleRate(); if (m_sampleRateMode) { - m_settings.m_devSampleRate = ui->sampleRate->getValueNew(); + m_settings.m_devSampleRate = (int) ui->sampleRate->getValueNew(); } else { - m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim); + m_settings.m_devSampleRate = (int) ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim); } m_settingsKeys.append("log2Decim"); @@ -523,9 +518,9 @@ void RTLSDRGui::on_agc_stateChanged(int state) void RTLSDRGui::on_sampleRate_changed(quint64 value) { if (m_sampleRateMode) { - m_settings.m_devSampleRate = value; + m_settings.m_devSampleRate = (int) value; } else { - m_settings.m_devSampleRate = value * (1 << m_settings.m_log2Decim); + m_settings.m_devSampleRate = (int) (value * (1 << m_settings.m_log2Decim)); } displayFcTooltip(); @@ -542,7 +537,7 @@ void RTLSDRGui::on_offsetTuning_toggled(bool checked) void RTLSDRGui::on_rfBW_changed(quint64 value) { - m_settings.m_rfBandwidth = value * 1000; + m_settings.m_rfBandwidth = (quint32) (value * 1000); m_settingsKeys.append("rfBandwidth"); sendSettings(); } @@ -554,9 +549,9 @@ void RTLSDRGui::on_lowSampleRate_toggled(bool checked) displaySampleRate(); if (m_sampleRateMode) { - m_settings.m_devSampleRate = ui->sampleRate->getValueNew(); + m_settings.m_devSampleRate = (int) ui->sampleRate->getValueNew(); } else { - m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim); + m_settings.m_devSampleRate = (int) (ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Decim)); } qDebug("RTLSDRGui::on_lowSampleRate_toggled: %d S/s", m_settings.m_devSampleRate); @@ -611,7 +606,7 @@ void RTLSDRGui::displayReplayLength() if (!replayEnabled) { ui->replayOffset->setMaximum(0); } else { - ui->replayOffset->setMaximum(m_settings.m_replayLength * 10 - 1); + ui->replayOffset->setMaximum((int) (m_settings.m_replayLength * 10 - 1)); } ui->replayLabel->setEnabled(replayEnabled); ui->replayOffset->setEnabled(replayEnabled); @@ -622,10 +617,10 @@ void RTLSDRGui::displayReplayLength() void RTLSDRGui::displayReplayOffset() { bool replayEnabled = m_settings.m_replayLength > 0.0f; - ui->replayOffset->setValue(m_settings.m_replayOffset * 10); + ui->replayOffset->setValue((int) (m_settings.m_replayOffset * 10)); ui->replayOffsetText->setText(QString("%1s").arg(m_settings.m_replayOffset, 0, 'f', 1)); ui->replayNow->setEnabled(replayEnabled && (m_settings.m_replayOffset > 0.0f)); - ui->replayPlus->setEnabled(replayEnabled && (std::round(m_settings.m_replayOffset * 10) < ui->replayOffset->maximum())); + ui->replayPlus->setEnabled(replayEnabled && (std::round(m_settings.m_replayOffset * 10) < (float) ui->replayOffset->maximum())); ui->replayMinus->setEnabled(replayEnabled && (m_settings.m_replayOffset > 0.0f)); } @@ -647,7 +642,7 @@ void RTLSDRGui::displayReplayStep() void RTLSDRGui::on_replayOffset_valueChanged(int value) { - m_settings.m_replayOffset = value / 10.0f; + m_settings.m_replayOffset = (float) value / 10.0f; displayReplayOffset(); m_settingsKeys.append("replayOffset"); sendSettings(); @@ -660,12 +655,12 @@ void RTLSDRGui::on_replayNow_clicked() void RTLSDRGui::on_replayPlus_clicked() { - ui->replayOffset->setValue(ui->replayOffset->value() + m_settings.m_replayStep * 10); + ui->replayOffset->setValue((int) ((float) ui->replayOffset->value() + m_settings.m_replayStep * 10)); } void RTLSDRGui::on_replayMinus_clicked() { - ui->replayOffset->setValue(ui->replayOffset->value() - m_settings.m_replayStep * 10); + ui->replayOffset->setValue((int) ((float) ui->replayOffset->value() - m_settings.m_replayStep * 10)); } void RTLSDRGui::on_replaySave_clicked() @@ -675,7 +670,7 @@ void RTLSDRGui::on_replaySave_clicked() if (fileDialog.exec()) { QStringList fileNames = fileDialog.selectedFiles(); - if (fileNames.size() > 0) + if (!fileNames.empty()) { RTLSDRInput::MsgSaveReplay *message = RTLSDRInput::MsgSaveReplay::create(fileNames[0]); m_sampleSource->getInputMessageQueue()->push(message); @@ -692,10 +687,10 @@ void RTLSDRGui::on_replayLoop_toggled(bool checked) void RTLSDRGui::setReplayTime(float time) { - ui->replayOffset->setValue(std::ceil(time * 10.0f)); + ui->replayOffset->setValue((int) std::ceil(time * 10.0f)); } -void RTLSDRGui::makeUIConnections() +void RTLSDRGui::makeUIConnections() const { QObject::connect(ui->centerFrequency, &ValueDial::changed, this, &RTLSDRGui::on_centerFrequency_changed); QObject::connect(ui->sampleRate, &ValueDial::changed, this, &RTLSDRGui::on_sampleRate_changed); diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.h b/plugins/samplesource/rtlsdr/rtlsdrgui.h index 7abfaeba3..8d2174b36 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.h +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.h @@ -42,14 +42,13 @@ class RTLSDRGui : public DeviceGUI { Q_OBJECT public: - explicit RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent = 0); - virtual ~RTLSDRGui(); - virtual void destroy(); + explicit RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent = nullptr); + ~RTLSDRGui() final; - void resetToDefaults(); - QByteArray serialize() const; - bool deserialize(const QByteArray& data); - virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } + void resetToDefaults() final; + QByteArray serialize() const final; + bool deserialize(const QByteArray& data) final; + MessageQueue *getInputMessageQueue() final { return &m_inputMessageQueue; } void setReplayTime(float time) override; private: @@ -79,7 +78,7 @@ private: void updateFrequencyLimits(); void blockApplySettings(bool block); bool handleMessage(const Message& message); - void makeUIConnections(); + void makeUIConnections() const; private slots: void handleInputMessages(); diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp index d98509fee..0ae70dece 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp @@ -56,7 +56,7 @@ const int RTLSDRInput::sampleRateHighRangeMax = 3200000; RTLSDRInput::RTLSDRInput(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), m_settings(), - m_dev(0), + m_dev(nullptr), m_rtlSDRThread(nullptr), m_deviceDescription("RTLSDR"), m_tunerType(RTLSDR_TUNER_UNKNOWN), @@ -102,7 +102,7 @@ void RTLSDRInput::destroy() bool RTLSDRInput::openDevice() { - if (m_dev != 0) + if (m_dev != nullptr) { closeDevice(); } @@ -110,7 +110,6 @@ bool RTLSDRInput::openDevice() char vendor[256]; char product[256]; char serial[256]; - int res; int numberOfGains; if (!m_sampleFifo.setSize(96000 * 4)) @@ -142,7 +141,7 @@ bool RTLSDRInput::openDevice() return false; } - if ((res = rtlsdr_open(&m_dev, device)) < 0) + if ((rtlsdr_open(&m_dev, device)) < 0) { qCritical("RTLSDRInput::openDevice: could not open RTLSDR #%d: %s", device, strerror(errno)); return false; @@ -153,7 +152,7 @@ bool RTLSDRInput::openDevice() product[0] = '\0'; serial[0] = '\0'; - if ((res = rtlsdr_get_usb_strings(m_dev, vendor, product, serial)) < 0) + if ((rtlsdr_get_usb_strings(m_dev, vendor, product, serial)) < 0) { qCritical("RTLSDRInput::openDevice: error accessing USB device"); stop(); @@ -171,28 +170,28 @@ bool RTLSDRInput::openDevice() m_frequencyHighRangeMin = 24000UL; } - if ((res = rtlsdr_set_sample_rate(m_dev, 1152000)) < 0) + if ((rtlsdr_set_sample_rate(m_dev, 1152000)) < 0) { qCritical("RTLSDRInput::openDevice: could not set sample rate: 1024k S/s"); stop(); return false; } - if ((res = rtlsdr_set_tuner_gain_mode(m_dev, 1)) < 0) + if ((rtlsdr_set_tuner_gain_mode(m_dev, 1)) < 0) { qCritical("RTLSDRInput::openDevice: error setting tuner gain mode"); stop(); return false; } - if ((res = rtlsdr_set_agc_mode(m_dev, 0)) < 0) + if ((rtlsdr_set_agc_mode(m_dev, 0)) < 0) { qCritical("RTLSDRInput::openDevice: error setting agc mode"); stop(); return false; } - numberOfGains = rtlsdr_get_tuner_gains(m_dev, NULL); + numberOfGains = rtlsdr_get_tuner_gains(m_dev, nullptr); if (numberOfGains < 0) { @@ -214,7 +213,7 @@ bool RTLSDRInput::openDevice() qDebug() << "RTLSDRInput::openDevice: " << m_gains.size() << "gains"; } - if ((res = rtlsdr_reset_buffer(m_dev)) < 0) + if ((rtlsdr_reset_buffer(m_dev)) < 0) { qCritical("RTLSDRInput::openDevice: could not reset USB EP buffers: %s", strerror(errno)); stop(); @@ -260,10 +259,10 @@ bool RTLSDRInput::start() void RTLSDRInput::closeDevice() { - if (m_dev != 0) + if (m_dev != nullptr) { rtlsdr_close(m_dev); - m_dev = 0; + m_dev = nullptr; } m_deviceDescription.clear(); @@ -351,7 +350,7 @@ bool RTLSDRInput::handleMessage(const Message& message) { if (MsgConfigureRTLSDR::match(message)) { - MsgConfigureRTLSDR& conf = (MsgConfigureRTLSDR&) message; + auto& conf = (const MsgConfigureRTLSDR&) message; qDebug() << "RTLSDRInput::handleMessage: MsgConfigureRTLSDR"; bool success = applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce()); @@ -365,7 +364,7 @@ bool RTLSDRInput::handleMessage(const Message& message) } else if (MsgStartStop::match(message)) { - MsgStartStop& cmd = (MsgStartStop&) message; + auto& cmd = (const MsgStartStop&) message; qDebug() << "RTLSDRInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop"); if (cmd.getStartStop()) @@ -387,7 +386,7 @@ bool RTLSDRInput::handleMessage(const Message& message) } else if (MsgSaveReplay::match(message)) { - MsgSaveReplay& cmd = (MsgSaveReplay&) message; + auto& cmd = (const MsgSaveReplay&) message; m_replayBuffer.save(cmd.getFilename(), m_settings.m_devSampleRate, getCenterFrequency()); return true; } @@ -419,15 +418,12 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QListsetIQOrder(settings.m_iqOrder); - } + if (m_rtlSDRThread && (settingsKeys.contains("iqOrder") || force)) { + m_rtlSDRThread->setIQOrder(settings.m_iqOrder); } if (settingsKeys.contains("centerFrequency") @@ -500,9 +493,9 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QListgetDeviceEngineInputMessageQueue()->push(notif); } @@ -729,10 +713,10 @@ void RTLSDRInput::webapiUpdateDeviceSettings( settings.m_reverseAPIAddress = *response.getRtlSdrSettings()->getReverseApiAddress(); } if (deviceSettingsKeys.contains("reverseAPIPort")) { - settings.m_reverseAPIPort = response.getRtlSdrSettings()->getReverseApiPort(); + settings.m_reverseAPIPort = (uint16_t) response.getRtlSdrSettings()->getReverseApiPort(); } if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) { - settings.m_reverseAPIDeviceIndex = response.getRtlSdrSettings()->getReverseApiDeviceIndex(); + settings.m_reverseAPIDeviceIndex = (uint16_t) response.getRtlSdrSettings()->getReverseApiDeviceIndex(); } } @@ -807,11 +791,11 @@ int RTLSDRInput::webapiReportGet( return 200; } -void RTLSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response) +void RTLSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response) const { response.getRtlSdrReport()->setGains(new QList); - for (std::vector::const_iterator it = getGains().begin(); it != getGains().end(); ++it) + for (auto it = getGains().begin(); it != getGains().end(); ++it) { response.getRtlSdrReport()->getGains()->append(new SWGSDRangel::SWGGain); response.getRtlSdrReport()->getGains()->back()->setGainCb(*it); @@ -822,7 +806,7 @@ void RTLSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respons void RTLSDRInput::webapiReverseSendSettings(const QList& deviceSettingsKeys, const RTLSDRSettings& settings, bool force) { - SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); + auto *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); swgDeviceSettings->setDirection(0); // single Rx swgDeviceSettings->setDeviceHwType(new QString("RTLSDR")); swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex()); @@ -890,8 +874,8 @@ void RTLSDRInput::webapiReverseSendSettings(const QList& deviceSettings m_networkRequest.setUrl(QUrl(channelSettingsURL)); m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QBuffer *buffer = new QBuffer(); - buffer->open((QBuffer::ReadWrite)); + auto *buffer = new QBuffer(); + buffer->open(QBuffer::ReadWrite); buffer->write(swgDeviceSettings->asJson().toUtf8()); buffer->seek(0); @@ -904,7 +888,7 @@ void RTLSDRInput::webapiReverseSendSettings(const QList& deviceSettings void RTLSDRInput::webapiReverseSendStartStop(bool start) { - SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); + auto *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); swgDeviceSettings->setDirection(0); // single Rx swgDeviceSettings->setDeviceHwType(new QString("RTLSDR")); swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex()); @@ -916,8 +900,8 @@ void RTLSDRInput::webapiReverseSendStartStop(bool start) m_networkRequest.setUrl(QUrl(channelSettingsURL)); m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QBuffer *buffer = new QBuffer(); - buffer->open((QBuffer::ReadWrite)); + auto *buffer = new QBuffer(); + buffer->open(QBuffer::ReadWrite); buffer->write(swgDeviceSettings->asJson().toUtf8()); buffer->seek(0); QNetworkReply *reply; @@ -932,7 +916,7 @@ void RTLSDRInput::webapiReverseSendStartStop(bool start) delete swgDeviceSettings; } -void RTLSDRInput::networkManagerFinished(QNetworkReply *reply) +void RTLSDRInput::networkManagerFinished(QNetworkReply *reply) const { QNetworkReply::NetworkError replyError = reply->error(); diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.h b/plugins/samplesource/rtlsdr/rtlsdrinput.h index c49ff4f3f..59887b2d8 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.h +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.h @@ -75,10 +75,10 @@ public: return new MsgStartStop(startStop); } - protected: + private: bool m_startStop; - MsgStartStop(bool startStop) : + explicit MsgStartStop(bool startStop) : Message(), m_startStop(startStop) { } @@ -94,75 +94,75 @@ public: return new MsgSaveReplay(filename); } - protected: + private: QString m_filename; - MsgSaveReplay(const QString& filename) : + explicit MsgSaveReplay(const QString& filename) : Message(), m_filename(filename) { } }; - RTLSDRInput(DeviceAPI *deviceAPI); - virtual ~RTLSDRInput(); - virtual void destroy(); + explicit RTLSDRInput(DeviceAPI *deviceAPI); + ~RTLSDRInput() final; + void destroy() final; - virtual void init(); - virtual bool start(); - virtual void stop(); + void init() final; + bool start() final; + void stop() final; - virtual QByteArray serialize() const; - virtual bool deserialize(const QByteArray& data); + QByteArray serialize() const final; + bool deserialize(const QByteArray& data) final; - virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; } - virtual const QString& getDeviceDescription() const; - virtual int getSampleRate() const; - virtual void setSampleRate(int sampleRate) { (void) sampleRate; } - virtual quint64 getCenterFrequency() const; - virtual void setCenterFrequency(qint64 centerFrequency); + void setMessageQueueToGUI(MessageQueue *queue) final { m_guiMessageQueue = queue; } + const QString& getDeviceDescription() const final; + int getSampleRate() const final; + void setSampleRate(int sampleRate) final { (void) sampleRate; } + quint64 getCenterFrequency() const final; + void setCenterFrequency(qint64 centerFrequency) final; - virtual bool handleMessage(const Message& message); + bool handleMessage(const Message& message) final; - virtual int webapiSettingsGet( - SWGSDRangel::SWGDeviceSettings& response, - QString& errorMessage); + int webapiSettingsGet( + SWGSDRangel::SWGDeviceSettings& response, + QString& errorMessage) final; - virtual int webapiSettingsPutPatch( - bool force, - const QStringList& deviceSettingsKeys, - SWGSDRangel::SWGDeviceSettings& response, // query + response - QString& errorMessage); + int webapiSettingsPutPatch( + bool force, + const QStringList& deviceSettingsKeys, + SWGSDRangel::SWGDeviceSettings& response, // query + response + QString& errorMessage) final; - virtual int webapiReportGet( - SWGSDRangel::SWGDeviceReport& response, - QString& errorMessage); + int webapiReportGet( + SWGSDRangel::SWGDeviceReport& response, + QString& errorMessage) final; - virtual int webapiRunGet( - SWGSDRangel::SWGDeviceState& response, - QString& errorMessage); + int webapiRunGet( + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage) final; - virtual int webapiRun( - bool run, - SWGSDRangel::SWGDeviceState& response, - QString& errorMessage); + int webapiRun( + bool run, + SWGSDRangel::SWGDeviceState& response, + QString& errorMessage) final; static void webapiFormatDeviceSettings( - SWGSDRangel::SWGDeviceSettings& response, - const RTLSDRSettings& settings); + SWGSDRangel::SWGDeviceSettings& response, + const RTLSDRSettings& settings); static void webapiUpdateDeviceSettings( - RTLSDRSettings& settings, - const QStringList& deviceSettingsKeys, - SWGSDRangel::SWGDeviceSettings& response); + RTLSDRSettings& settings, + const QStringList& deviceSettingsKeys, + SWGSDRangel::SWGDeviceSettings& response); const std::vector& getGains() const { return m_gains; } rtlsdr_tuner getTunerType() const { return m_tunerType; } QString getTunerName() const; void set_ds_mode(int on); + quint64 getFrequencyHighRangeMin() const { return m_frequencyHighRangeMin; } static const quint64 frequencyLowRangeMin; static const quint64 frequencyLowRangeMax; - quint64 m_frequencyHighRangeMin; static const quint64 frequencyHighRangeMax; static const int sampleRateLowRangeMin; static const int sampleRateLowRangeMax; @@ -181,17 +181,18 @@ private: bool m_running; QNetworkAccessManager *m_networkManager; QNetworkRequest m_networkRequest; + quint64 m_frequencyHighRangeMin; ReplayBuffer m_replayBuffer; bool openDevice(); void closeDevice(); bool applySettings(const RTLSDRSettings& settings, const QList& settingsKeys, bool force); - void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response); + void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response) const; void webapiReverseSendSettings(const QList& deviceSettingsKeys, const RTLSDRSettings& settings, bool force); void webapiReverseSendStartStop(bool start); private slots: - void networkManagerFinished(QNetworkReply *reply); + void networkManagerFinished(QNetworkReply *reply) const; }; #endif // INCLUDE_RTLSDRINPUT_H diff --git a/sdrgui/device/devicegui.h b/sdrgui/device/devicegui.h index c376c2c7e..dd624ae86 100644 --- a/sdrgui/device/devicegui.h +++ b/sdrgui/device/devicegui.h @@ -59,9 +59,8 @@ public: ContextMenuDeviceSettings }; - DeviceGUI(QWidget *parent = nullptr); - virtual ~DeviceGUI(); - virtual void destroy() = 0; + explicit DeviceGUI(QWidget *parent = nullptr); + ~DeviceGUI() override; virtual void resetToDefaults() = 0; void setWorkspaceIndex(int index); diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index a417a82eb..ed01dfe64 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -972,7 +972,7 @@ void MainWindow::removeDeviceSet(int deviceSetIndex) // deletes old UI and core object deviceUISet->freeChannels(); // destroys the channel instances deviceUISet->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI - deviceUISet->m_deviceGUI->destroy(); + delete deviceUISet->m_deviceGUI; deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists @@ -993,7 +993,7 @@ void MainWindow::removeDeviceSet(int deviceSetIndex) // deletes old UI and output object deviceUISet->freeChannels(); deviceUISet->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI - deviceUISet->m_deviceGUI->destroy(); + delete deviceUISet->m_deviceGUI; deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists @@ -1013,7 +1013,7 @@ void MainWindow::removeDeviceSet(int deviceSetIndex) // deletes old UI and output object deviceUISet->freeChannels(); deviceUISet->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI - deviceUISet->m_deviceGUI->destroy(); + delete deviceUISet->m_deviceGUI; deviceUISet->m_deviceAPI->resetSamplingDeviceId(); @@ -1068,7 +1068,7 @@ void MainWindow::removeLastDeviceSet() // deletes old UI and input object m_deviceUIs.back()->freeChannels(); // destroys the channel instances m_deviceUIs.back()->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI - m_deviceUIs.back()->m_deviceGUI->destroy(); + delete m_deviceUIs.back()->m_deviceGUI; m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId(); m_deviceUIs.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists @@ -1087,7 +1087,7 @@ void MainWindow::removeLastDeviceSet() // deletes old UI and output object m_deviceUIs.back()->freeChannels(); m_deviceUIs.back()->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI - m_deviceUIs.back()->m_deviceGUI->destroy(); + delete m_deviceUIs.back()->m_deviceGUI; m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId(); m_deviceUIs.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists @@ -1106,7 +1106,7 @@ void MainWindow::removeLastDeviceSet() // deletes old UI and output object m_deviceUIs.back()->freeChannels(); m_deviceUIs.back()->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI - m_deviceUIs.back()->m_deviceGUI->destroy(); + delete m_deviceUIs.back()->m_deviceGUI; m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId(); m_dspEngine->removeLastDeviceMIMOEngine(); @@ -2373,7 +2373,7 @@ void MainWindow::sampleSourceChange(int deviceSetIndex, int newDeviceIndex, Work // deletes old UI and input object deviceUISet->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI - deviceUISet->m_deviceGUI->destroy(); + delete deviceUISet->m_deviceGUI; deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(deviceUISet->m_deviceAPI->getSampleSource()); deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists @@ -2405,7 +2405,7 @@ void MainWindow::sampleSinkChange(int deviceSetIndex, int newDeviceIndex, Worksp // deletes old UI and output object deviceUISet->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI - m_deviceUIs[deviceSetIndex]->m_deviceGUI->destroy(); + delete m_deviceUIs[deviceSetIndex]->m_deviceGUI; deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(deviceUISet->m_deviceAPI->getSampleSink()); deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists @@ -2437,7 +2437,7 @@ void MainWindow::sampleMIMOChange(int deviceSetIndex, int newDeviceIndex, Worksp // deletes old UI and output object deviceUISet->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI - deviceUISet->m_deviceGUI->destroy(); + delete deviceUISet->m_deviceGUI; deviceUISet->m_deviceAPI->resetSamplingDeviceId(); deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceMIMO(deviceUISet->m_deviceAPI->getSampleMIMO());