From 4a9b1c3bbead39d9262cd7dcfbed74355cfd3a62 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 12 Oct 2024 18:47:27 +0200 Subject: [PATCH] SSB demod: fixed GUI and returned to previous threading model. Fixes #2273 --- plugins/channeltx/modssb/ssbmod.cpp | 41 +++++++------------------- plugins/channeltx/modssb/ssbmodgui.cpp | 21 +++++++++++-- plugins/channeltx/modssb/ssbmodgui.h | 1 + 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/plugins/channeltx/modssb/ssbmod.cpp b/plugins/channeltx/modssb/ssbmod.cpp index 7fd668786..6fadd20f3 100644 --- a/plugins/channeltx/modssb/ssbmod.cpp +++ b/plugins/channeltx/modssb/ssbmod.cpp @@ -60,6 +60,14 @@ SSBMod::SSBMod(DeviceAPI *deviceAPI) : m_spectrumVis(SDR_TX_SCALEF) { setObjectName(m_channelId); + + m_thread = new QThread(this); + m_basebandSource = new SSBModBaseband(); + m_basebandSource->setSpectrumSink(&m_spectrumVis); + m_basebandSource->setInputFileStream(&m_ifstream); + m_basebandSource->setChannel(this); + m_basebandSource->moveToThread(m_thread); + applySettings(m_settings, true); m_deviceAPI->addChannelSource(this); @@ -85,8 +93,8 @@ SSBMod::~SSBMod() delete m_networkManager; m_deviceAPI->removeChannelSourceAPI(this); m_deviceAPI->removeChannelSource(this); - - SSBMod::stop(); + delete m_basebandSource; + delete m_thread; } void SSBMod::setDeviceAPI(DeviceAPI *deviceAPI) @@ -108,37 +116,8 @@ void SSBMod::start() } qDebug("SSBMod::start"); - m_thread = new QThread(this); - m_basebandSource = new SSBModBaseband(); - m_basebandSource->setSpectrumSink(&m_spectrumVis); - m_basebandSource->setInputFileStream(&m_ifstream); - m_basebandSource->setChannel(this); m_basebandSource->reset(); - m_basebandSource->setCWKeyer(&m_cwKeyer); - m_basebandSource->moveToThread(m_thread); - - QObject::connect( - m_thread, - &QThread::finished, - m_basebandSource, - &QObject::deleteLater - ); - QObject::connect( - m_thread, - &QThread::finished, - m_thread, - &QThread::deleteLater - ); - m_thread->start(); - - SSBModBaseband::MsgConfigureSSBModBaseband *msg = SSBModBaseband::MsgConfigureSSBModBaseband::create(m_settings, true); - m_basebandSource->getInputMessageQueue()->push(msg); - - if (m_levelMeter) { - connect(m_basebandSource, SIGNAL(levelChanged(qreal, qreal, int)), m_levelMeter, SLOT(levelChanged(qreal, qreal, int))); - } - m_running = true; } diff --git a/plugins/channeltx/modssb/ssbmodgui.cpp b/plugins/channeltx/modssb/ssbmodgui.cpp index c24e9615d..eda497cfb 100644 --- a/plugins/channeltx/modssb/ssbmodgui.cpp +++ b/plugins/channeltx/modssb/ssbmodgui.cpp @@ -547,13 +547,29 @@ void SSBModGUI::applySettings(bool force) } } +uint32_t SSBModGUI::getValidAudioSampleRate() const +{ + // When not running, m_ssbDemod->getAudioSampleRate() will return 0, but we + // want a valid value to initialise the GUI, to allow a user to preselect settings + int sr = m_ssbMod->getAudioSampleRate(); + if (sr == 0) + { + if (m_audioSampleRate > 0) { + sr = m_audioSampleRate; + } else { + sr = 48000; + } + } + return sr; +} + void SSBModGUI::applyBandwidths(int spanLog2, bool force) { bool dsb = ui->dsb->isChecked(); - m_spectrumRate = m_ssbMod->getAudioSampleRate() / (1<BW->value(); int lw = ui->lowCut->value(); - int bwMax = m_ssbMod->getAudioSampleRate() / (100*(1<showFileDialog, &QPushButton::clicked, this, &SSBModGUI::on_showFileDialog_clicked); QObject::connect(ui->feedbackEnable, &QToolButton::toggled, this, &SSBModGUI::on_feedbackEnable_toggled); QObject::connect(ui->feedbackVolume, &QDial::valueChanged, this, &SSBModGUI::on_feedbackVolume_valueChanged); + QObject::connect(ui->spanLog2, &QSlider::valueChanged, this, &SSBModGUI::on_spanLog2_valueChanged); } void SSBModGUI::updateAbsoluteCenterFrequency() diff --git a/plugins/channeltx/modssb/ssbmodgui.h b/plugins/channeltx/modssb/ssbmodgui.h index 4028c5122..ecd59f75a 100644 --- a/plugins/channeltx/modssb/ssbmodgui.h +++ b/plugins/channeltx/modssb/ssbmodgui.h @@ -107,6 +107,7 @@ private: bool handleMessage(const Message& message); void makeUIConnections(); void updateAbsoluteCenterFrequency(); + uint32_t getValidAudioSampleRate() const; void leaveEvent(QEvent*); void enterEvent(EnterEventType*);