Skip to content

Commit

Permalink
Sonar fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
f4exb committed Aug 27, 2024
1 parent 585d806 commit b85419c
Show file tree
Hide file tree
Showing 43 changed files with 1,708 additions and 1,971 deletions.
1 change: 1 addition & 0 deletions plugins/channelrx/wdsprx/wdsprxbaseband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void WDSPRxBaseband::reset()
{
QMutexLocker mutexLocker(&m_mutex);
m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate());
mutexLocker.unlock();
m_sampleFifo.reset();
m_channelSampleRate = 0;
}
Expand Down
58 changes: 25 additions & 33 deletions plugins/channelrx/wdsprx/wdsprxgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

WDSPRxGUI* WDSPRxGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel)
{
WDSPRxGUI* gui = new WDSPRxGUI(pluginAPI, deviceUISet, rxChannel);
auto* gui = new WDSPRxGUI(pluginAPI, deviceUISet, rxChannel);
return gui;
}

Expand Down Expand Up @@ -98,7 +98,7 @@ bool WDSPRxGUI::handleMessage(const Message& message)
if (WDSPRx::MsgConfigureWDSPRx::match(message))
{
qDebug("WDSPRxGUI::handleMessage: WDSPRx::MsgConfigureWDSPRx");
const WDSPRx::MsgConfigureWDSPRx& cfg = (WDSPRx::MsgConfigureWDSPRx&) message;
auto& cfg = (const WDSPRx::MsgConfigureWDSPRx&) message;
m_settings = cfg.getSettings();
blockApplySettings(true);
ui->spectrumGUI->updateSettings();
Expand All @@ -118,7 +118,7 @@ bool WDSPRxGUI::handleMessage(const Message& message)
}
else if (DSPSignalNotification::match(message))
{
const DSPSignalNotification& notif = (const DSPSignalNotification&) message;
auto& notif = (const DSPSignalNotification&) message;
m_deviceCenterFrequency = notif.getCenterFrequency();
m_basebandSampleRate = notif.getSampleRate();
qDebug("WDSPRxGUI::handleMessage: DSPSignalNotification: centerFrequency: %lld sampleRate: %d",
Expand All @@ -138,7 +138,7 @@ void WDSPRxGUI::handleInputMessages()
{
Message* message;

while ((message = getInputMessageQueue()->pop()) != 0)
while ((message = getInputMessageQueue()->pop()) != nullptr)
{
if (handleMessage(*message))
{
Expand Down Expand Up @@ -183,7 +183,7 @@ void WDSPRxGUI::on_dsb_toggled(bool dsb)

void WDSPRxGUI::on_deltaFrequency_changed(qint64 value)
{
m_channelMarker.setCenterFrequency(value);
m_channelMarker.setCenterFrequency((int) value);
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
updateAbsoluteCenterFrequency();
applySettings();
Expand All @@ -205,7 +205,7 @@ void WDSPRxGUI::on_lowCut_valueChanged(int value)
void WDSPRxGUI::on_volume_valueChanged(int value)
{
ui->volumeText->setText(QString("%1").arg(value));
m_settings.m_volume = CalcDb::powerFromdB(value);
m_settings.m_volume = (Real) CalcDb::powerFromdB(value);
applySettings();
}

Expand Down Expand Up @@ -279,7 +279,7 @@ void WDSPRxGUI::on_rit_toggled(bool checked)
{
m_settings.m_rit = checked;
m_settings.m_profiles[m_settings.m_profileIndex].m_rit = m_settings.m_rit;
m_channelMarker.setShift(checked ? m_settings.m_ritFrequency: 0);
m_channelMarker.setShift(checked ? (int) m_settings.m_ritFrequency: 0);
applySettings();
}

Expand Down Expand Up @@ -406,7 +406,7 @@ void WDSPRxGUI::on_profileIndex_valueChanged(int value)

void WDSPRxGUI::on_demod_currentIndexChanged(int index)
{
WDSPRxProfile::WDSPRxDemod demod = (WDSPRxProfile::WDSPRxDemod) index;
auto demod = (WDSPRxProfile::WDSPRxDemod) index;

if ((m_settings.m_demod != WDSPRxProfile::DemodSSB) && (demod == WDSPRxProfile::DemodSSB)) {
m_settings.m_dsb = false;
Expand Down Expand Up @@ -480,7 +480,7 @@ void WDSPRxGUI::onMenuDialogCalled(const QPoint &p)
resetContextMenuType();
}

void WDSPRxGUI::onWidgetRolled(QWidget* widget, bool rollDown)
void WDSPRxGUI::onWidgetRolled(const QWidget* widget, bool rollDown)
{
(void) widget;
(void) rollDown;
Expand Down Expand Up @@ -524,7 +524,7 @@ WDSPRxGUI::WDSPRxGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
m_wdspRx = (WDSPRx*) rxChannel;
m_spectrumVis = m_wdspRx->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_wdspRx->setMessageQueueToGUI(getInputMessageQueue());
m_wdspRx->setMessageQueueToGUI(WDSPRxGUI::getInputMessageQueue());

m_audioMuteRightClickEnabler = new CRightClickEnabler(ui->audioMute);
connect(m_audioMuteRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(audioSelect(const QPoint &)));
Expand Down Expand Up @@ -588,7 +588,7 @@ WDSPRxGUI::WDSPRxGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
m_deviceUISet->addChannelMarker(&m_channelMarker);
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
connect(WDSPRxGUI::getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));


m_iconDSBUSB.addPixmap(QPixmap("://dsb.png"), QIcon::Normal, QIcon::On);
Expand Down Expand Up @@ -654,7 +654,7 @@ uint32_t WDSPRxGUI::getValidAudioSampleRate() const
return sr;
}

unsigned int WDSPRxGUI::spanLog2Max()
unsigned int WDSPRxGUI::spanLog2Max() const
{
unsigned int spanLog2 = 0;
for (; getValidAudioSampleRate() / (1<<spanLog2) >= 1000; spanLog2++);
Expand All @@ -668,7 +668,6 @@ void WDSPRxGUI::applyBandwidths(unsigned int spanLog2, bool force)
unsigned int limit = s2max < 1 ? 0 : s2max - 1;
ui->spanLog2->setMaximum(limit);
bool dsb = ui->dsb->isChecked();
//int spanLog2 = ui->spanLog2->value();
m_spectrumRate = getValidAudioSampleRate() / (1<<spanLog2);
int bw = ui->BW->value();
int lw = ui->lowCut->value();
Expand Down Expand Up @@ -764,8 +763,8 @@ void WDSPRxGUI::applyBandwidths(unsigned int spanLog2, bool force)
m_settings.m_dsb = dsb;
m_settings.m_profiles[m_settings.m_profileIndex].m_dsb = dsb;
m_settings.m_profiles[m_settings.m_profileIndex].m_spanLog2 = spanLog2;
m_settings.m_profiles[m_settings.m_profileIndex].m_highCutoff = bw * 100;
m_settings.m_profiles[m_settings.m_profileIndex].m_lowCutoff = lw * 100;
m_settings.m_profiles[m_settings.m_profileIndex].m_highCutoff = (Real) (bw * 100);
m_settings.m_profiles[m_settings.m_profileIndex].m_lowCutoff = (Real) (lw * 100);

applySettings(force);

Expand All @@ -785,11 +784,11 @@ void WDSPRxGUI::displaySettings()
{
m_channelMarker.blockSignals(true);
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
m_channelMarker.setBandwidth(m_settings.m_profiles[m_settings.m_profileIndex].m_highCutoff * 2);
m_channelMarker.setBandwidth((int) (m_settings.m_profiles[m_settings.m_profileIndex].m_highCutoff * 2));
m_channelMarker.setTitle(m_settings.m_title);
m_channelMarker.setLowCutoff(m_settings.m_profiles[m_settings.m_profileIndex].m_lowCutoff);
m_channelMarker.setLowCutoff((int) m_settings.m_profiles[m_settings.m_profileIndex].m_lowCutoff);
int shift = m_settings.m_profiles[m_settings.m_profileIndex].m_rit ?
m_settings.m_profiles[m_settings.m_profileIndex].m_ritFrequency :
(int) m_settings.m_profiles[m_settings.m_profileIndex].m_ritFrequency :
0;
m_channelMarker.setShift(shift);

Expand Down Expand Up @@ -880,7 +879,7 @@ void WDSPRxGUI::displaySettings()
ui->dsb->setChecked(m_settings.m_dsb);
ui->spanLog2->setValue(1 + ui->spanLog2->maximum() - m_settings.m_profiles[m_settings.m_profileIndex].m_spanLog2);

ui->BW->setValue(m_settings.m_profiles[m_settings.m_profileIndex].m_highCutoff / 100.0);
ui->BW->setValue((int) (m_settings.m_profiles[m_settings.m_profileIndex].m_highCutoff / 100.0));
s = QString::number(m_settings.m_profiles[m_settings.m_profileIndex].m_highCutoff/1000.0, 'f', 1);

if (m_settings.m_dsb) {
Expand All @@ -899,10 +898,10 @@ void WDSPRxGUI::displaySettings()

// The only one of the four signals triggering applyBandwidths will trigger it once only with all other values
// set correctly and therefore validate the settings and apply them to dependent widgets
ui->lowCut->setValue(m_settings.m_profiles[m_settings.m_profileIndex].m_lowCutoff / 100.0);
ui->lowCut->setValue((int) (m_settings.m_profiles[m_settings.m_profileIndex].m_lowCutoff / 100.0));
ui->lowCutText->setText(tr("%1k").arg(m_settings.m_profiles[m_settings.m_profileIndex].m_lowCutoff / 1000.0));

int volume = CalcDb::dbPower(m_settings.m_volume);
auto volume = (int) CalcDb::dbPower(m_settings.m_volume);
ui->volume->setValue(volume);
ui->volumeText->setText(QString("%1").arg(volume));

Expand Down Expand Up @@ -1199,15 +1198,11 @@ void WDSPRxGUI::amSetup(int iValueChanged)

auto valueChanged = (WDSPRxAMDialog::ValueChanged) iValueChanged;

switch (valueChanged)
if (valueChanged == WDSPRxAMDialog::ChangedFadeLevel)
{
case WDSPRxAMDialog::ChangedFadeLevel:
m_settings.m_amFadeLevel = m_amDialog->getFadeLevel();
m_settings.m_profiles[m_settings.m_profileIndex].m_amFadeLevel = m_settings.m_amFadeLevel;
applySettings();
break;
default:
break;
}
}

Expand Down Expand Up @@ -1369,21 +1364,18 @@ void WDSPRxGUI::panSetup(int iValueChanged)

auto valueChanged = (WDSPRxPanDialog::ValueChanged) iValueChanged;

switch (valueChanged)
if (valueChanged == WDSPRxPanDialog::ChangedPan)
{
case WDSPRxPanDialog::ChangedPan:
m_settings.m_audioPan = m_panDialog->getPan();
m_settings.m_profiles[m_settings.m_profileIndex].m_audioPan = m_settings.m_audioPan;
applySettings();
break;
default:
break;
}
}

void WDSPRxGUI::tick()
{
double powDbAvg, powDbPeak;
double powDbAvg;
double powDbPeak;
int nbMagsqSamples;
m_wdspRx->getMagSqLevels(powDbAvg, powDbPeak, nbMagsqSamples); // powers directly in dB

Expand Down Expand Up @@ -1416,7 +1408,7 @@ void WDSPRxGUI::tick()
m_tickCount++;
}

void WDSPRxGUI::makeUIConnections()
void WDSPRxGUI::makeUIConnections() const
{
QObject::connect(ui->deltaFrequency, &ValueDialZ::changed, this, &WDSPRxGUI::on_deltaFrequency_changed);
QObject::connect(ui->audioBinaural, &QToolButton::toggled, this, &WDSPRxGUI::on_audioBinaural_toggled);
Expand Down
44 changes: 22 additions & 22 deletions plugins/channelrx/wdsprx/wdsprxgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ class WDSPRxGUI : public ChannelGUI {
static WDSPRxGUI* create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel);
virtual void destroy();

void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual void setWorkspaceIndex(int index) { m_settings.m_workspaceIndex = index; };
virtual int getWorkspaceIndex() const { return m_settings.m_workspaceIndex; };
virtual void setGeometryBytes(const QByteArray& blob) { m_settings.m_geometryBytes = blob; };
virtual QByteArray getGeometryBytes() const { return m_settings.m_geometryBytes; };
virtual QString getTitle() const { return m_settings.m_title; };
virtual QColor getTitleColor() const { return m_settings.m_rgbColor; };
virtual void zetHidden(bool hidden) { m_settings.m_hidden = hidden; }
virtual bool getHidden() const { return m_settings.m_hidden; }
virtual ChannelMarker& getChannelMarker() { return m_channelMarker; }
virtual int getStreamIndex() const { return m_settings.m_streamIndex; }
virtual void setStreamIndex(int streamIndex) { m_settings.m_streamIndex = streamIndex; }
void resetToDefaults() final;
QByteArray serialize() const final;
bool deserialize(const QByteArray& data) final;
MessageQueue *getInputMessageQueue() final { return &m_inputMessageQueue; }
void setWorkspaceIndex(int index) final { m_settings.m_workspaceIndex = index; };
int getWorkspaceIndex() const final { return m_settings.m_workspaceIndex; };
void setGeometryBytes(const QByteArray& blob) final { m_settings.m_geometryBytes = blob; };
QByteArray getGeometryBytes() const final { return m_settings.m_geometryBytes; };
QString getTitle() const final { return m_settings.m_title; };
QColor getTitleColor() const final { return m_settings.m_rgbColor; };
void zetHidden(bool hidden) final { m_settings.m_hidden = hidden; }
bool getHidden() const final { return m_settings.m_hidden; }
ChannelMarker& getChannelMarker() final { return m_channelMarker; }
int getStreamIndex() const final { return m_settings.m_streamIndex; }
void setStreamIndex(int streamIndex) final { m_settings.m_streamIndex = streamIndex; }

public slots:
void channelMarkerChangedByCursor();
Expand Down Expand Up @@ -122,21 +122,21 @@ public slots:
QIcon m_iconDSBUSB;
QIcon m_iconDSBLSB;

explicit WDSPRxGUI(PluginAPI* pluginAPI, DeviceUISet* deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent = 0);
virtual ~WDSPRxGUI();
explicit WDSPRxGUI(PluginAPI* pluginAPI, DeviceUISet* deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent = nullptr);
~WDSPRxGUI() final;

bool blockApplySettings(bool block);
void applySettings(bool force = false);
void applyBandwidths(unsigned int spanLog2, bool force = false);
unsigned int spanLog2Max();
unsigned int spanLog2Max() const;
void displaySettings();
bool handleMessage(const Message& message);
void makeUIConnections();
void makeUIConnections() const;
void updateAbsoluteCenterFrequency();
uint32_t getValidAudioSampleRate() const;

void leaveEvent(QEvent*);
void enterEvent(EnterEventType*);
void leaveEvent(QEvent*) final;
void enterEvent(EnterEventType*) final;

private slots:
void on_deltaFrequency_changed(qint64 value);
Expand Down Expand Up @@ -164,7 +164,7 @@ private slots:
void on_rit_toggled(bool checked);
void on_ritFrequency_valueChanged(int value);
void on_dbOrS_toggled(bool checked);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onWidgetRolled(const QWidget* widget, bool rollDown);
void onMenuDialogCalled(const QPoint& p);
void handleInputMessages();
void audioSelect(const QPoint& p);
Expand Down
Loading

0 comments on commit b85419c

Please sign in to comment.