1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-22 17:45:48 -05:00

SSB demod: fixed GUI and returned to previous threading model. Fixes #2273

This commit is contained in:
f4exb 2024-10-12 18:47:27 +02:00
parent 141d0c1e6f
commit 4a9b1c3bbe
3 changed files with 30 additions and 33 deletions

View File

@ -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;
}

View File

@ -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<<spanLog2);
m_spectrumRate = getValidAudioSampleRate() / (1<<spanLog2);
int bw = ui->BW->value();
int lw = ui->lowCut->value();
int bwMax = m_ssbMod->getAudioSampleRate() / (100*(1<<spanLog2));
int bwMax = getValidAudioSampleRate() / (100*(1<<spanLog2));
int tickInterval = m_spectrumRate / 1200;
tickInterval = tickInterval == 0 ? 1 : tickInterval;
@ -897,6 +913,7 @@ void SSBModGUI::makeUIConnections()
QObject::connect(ui->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()

View File

@ -107,6 +107,7 @@ private:
bool handleMessage(const Message& message);
void makeUIConnections();
void updateAbsoluteCenterFrequency();
uint32_t getValidAudioSampleRate() const;
void leaveEvent(QEvent*);
void enterEvent(EnterEventType*);