1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-04 16:01:14 -05:00

ATV demod: fixed initialization issues. Fixes #560

This commit is contained in:
f4exb 2020-07-11 21:01:32 +02:00
parent dadf51b6d7
commit 99586c7be6
6 changed files with 33 additions and 55 deletions

View File

@ -36,6 +36,7 @@ const QString ATVDemod::m_channelId = "ATVDemod";
ATVDemod::ATVDemod(DeviceAPI *deviceAPI) : ATVDemod::ATVDemod(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink), ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
m_deviceAPI(deviceAPI), m_deviceAPI(deviceAPI),
m_centerFrequency(0),
m_basebandSampleRate(0) m_basebandSampleRate(0)
{ {
qDebug("ATVDemod::ATVDemod"); qDebug("ATVDemod::ATVDemod");
@ -64,12 +65,16 @@ void ATVDemod::start()
{ {
qDebug("ATVDemod::start"); qDebug("ATVDemod::start");
if (m_basebandSampleRate != 0) {
m_basebandSink->setBasebandSampleRate(m_basebandSampleRate);
}
m_basebandSink->reset(); m_basebandSink->reset();
m_thread->start(); m_thread->start();
// re-apply essential messages
DSPSignalNotification* notifToSink = new DSPSignalNotification(m_basebandSampleRate, m_centerFrequency);
m_basebandSink->getInputMessageQueue()->push(notifToSink);
ATVDemodBaseband::MsgConfigureATVDemodBaseband *msg = ATVDemodBaseband::MsgConfigureATVDemodBaseband::create(m_settings, true);
m_basebandSink->getInputMessageQueue()->push(msg);
} }
void ATVDemod::stop() void ATVDemod::stop()
@ -97,6 +102,7 @@ bool ATVDemod::handleMessage(const Message& cmd)
else if (DSPSignalNotification::match(cmd)) else if (DSPSignalNotification::match(cmd))
{ {
DSPSignalNotification& notif = (DSPSignalNotification&) cmd; DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
m_centerFrequency = notif.getCenterFrequency();
m_basebandSampleRate = notif.getSampleRate(); // store for init at start m_basebandSampleRate = notif.getSampleRate(); // store for init at start
qDebug() << "ATVDemod::handleMessage: DSPSignalNotification" << m_basebandSampleRate; qDebug() << "ATVDemod::handleMessage: DSPSignalNotification" << m_basebandSampleRate;

View File

@ -100,7 +100,8 @@ private:
QThread *m_thread; QThread *m_thread;
ATVDemodBaseband* m_basebandSink; ATVDemodBaseband* m_basebandSink;
ATVDemodSettings m_settings; ATVDemodSettings m_settings;
int m_basebandSampleRate; //!< stored from device message used when starting baseband sink qint64 m_centerFrequency; //!< center frequency stored from device message used when starting baseband sink
int m_basebandSampleRate; //!< sample rate stored from device message used when starting baseband sink
void applySettings(const ATVDemodSettings& settings, bool force = false); void applySettings(const ATVDemodSettings& settings, bool force = false);
}; };

View File

@ -24,7 +24,6 @@
#include "atvdemodbaseband.h" #include "atvdemodbaseband.h"
MESSAGE_CLASS_DEFINITION(ATVDemodBaseband::MsgConfigureATVDemodBaseband, Message) MESSAGE_CLASS_DEFINITION(ATVDemodBaseband::MsgConfigureATVDemodBaseband, Message)
MESSAGE_CLASS_DEFINITION(ATVDemodBaseband::MsgConfigureChannelizer, Message)
ATVDemodBaseband::ATVDemodBaseband() : ATVDemodBaseband::ATVDemodBaseband() :
m_mutex(QMutex::Recursive) m_mutex(QMutex::Recursive)
@ -52,6 +51,7 @@ ATVDemodBaseband::~ATVDemodBaseband()
void ATVDemodBaseband::reset() void ATVDemodBaseband::reset()
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
m_inputMessageQueue.clear();
m_sampleFifo.reset(); m_sampleFifo.reset();
} }
@ -111,18 +111,6 @@ bool ATVDemodBaseband::handleMessage(const Message& cmd)
return true; return true;
} }
else if (MsgConfigureChannelizer::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
qDebug() << "ATVDemodBaseband::handleMessage: MsgConfigureChannelizer"
<< "(requested) sinkSampleRate: " << cfg.getSinkSampleRate()
<< "(requested) sinkCenterFrequency: " << cfg.getSinkCenterFrequency();
m_channelizer->setChannelization(cfg.getSinkSampleRate(), cfg.getSinkCenterFrequency());
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
return true;
}
else if (DSPSignalNotification::match(cmd)) else if (DSPSignalNotification::match(cmd))
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);

View File

@ -56,28 +56,6 @@ public:
{ } { }
}; };
class MsgConfigureChannelizer : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getSinkSampleRate() const { return m_sinkSampleRate; }
int getSinkCenterFrequency() const { return m_sinkCenterFrequency; }
static MsgConfigureChannelizer* create(int sinkSampleRate, int sinkCenterFrequency) {
return new MsgConfigureChannelizer(sinkSampleRate, sinkCenterFrequency);
}
private:
int m_sinkSampleRate;
int m_sinkCenterFrequency;
MsgConfigureChannelizer(int sinkSampleRate, int sinkCenterFrequency) :
Message(),
m_sinkSampleRate(sinkSampleRate),
m_sinkCenterFrequency(sinkCenterFrequency)
{ }
};
ATVDemodBaseband(); ATVDemodBaseband();
~ATVDemodBaseband(); ~ATVDemodBaseband();
void reset(); void reset();

View File

@ -109,7 +109,7 @@ void ATVDemodGUI::displaySettings()
setWindowTitle(m_channelMarker.getTitle()); setWindowTitle(m_channelMarker.getTitle());
displayStreamIndex(); displayStreamIndex();
blockApplySettings(true); m_doApplySettings = false;
//********** ATV values ********** //********** ATV values **********
ui->synchLevel->setValue((int) (m_settings.m_levelSynchroTop * 1000.0f)); ui->synchLevel->setValue((int) (m_settings.m_levelSynchroTop * 1000.0f));
@ -130,6 +130,7 @@ void ATVDemodGUI::displaySettings()
topTimeUpdate(); topTimeUpdate();
//********** RF values ********** //********** RF values **********
ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset);
ui->decimatorEnable->setChecked(m_settings.m_forceDecimator); ui->decimatorEnable->setChecked(m_settings.m_forceDecimator);
ui->rfFiltering->setChecked(m_settings.m_fftFiltering); ui->rfFiltering->setChecked(m_settings.m_fftFiltering);
ui->bfo->setValue(m_settings.m_bfoFrequency); ui->bfo->setValue(m_settings.m_bfoFrequency);
@ -140,9 +141,10 @@ void ATVDemodGUI::displaySettings()
ui->amScaleFactorText->setText(QString("%1").arg(m_settings.m_amScalingFactor)); ui->amScaleFactorText->setText(QString("%1").arg(m_settings.m_amScalingFactor));
ui->amScaleOffset->setValue(m_settings.m_amOffsetFactor); ui->amScaleOffset->setValue(m_settings.m_amOffsetFactor);
ui->amScaleOffsetText->setText(QString("%1").arg(m_settings.m_amOffsetFactor)); ui->amScaleOffsetText->setText(QString("%1").arg(m_settings.m_amOffsetFactor));
blockApplySettings(false);
applyTVSampleRate(); applyTVSampleRate();
m_doApplySettings = true;
} }
void ATVDemodGUI::displayStreamIndex() void ATVDemodGUI::displayStreamIndex()
@ -168,7 +170,7 @@ void ATVDemodGUI::displayRFBandwidths()
void ATVDemodGUI::applyTVSampleRate() void ATVDemodGUI::applyTVSampleRate()
{ {
blockApplySettings(true); qDebug("TVDemodGUI::applyTVSampleRate");
unsigned int nbPointsPerLine; unsigned int nbPointsPerLine;
ATVDemodSettings::getBaseValues(m_basebandSampleRate, m_settings.m_fps*m_settings.m_nbLines, m_tvSampleRate, nbPointsPerLine); ATVDemodSettings::getBaseValues(m_basebandSampleRate, m_settings.m_fps*m_settings.m_nbLines, m_tvSampleRate, nbPointsPerLine);
ui->tvSampleRateText->setText(tr("%1k").arg(m_tvSampleRate/1000.0f, 0, 'f', 2)); ui->tvSampleRateText->setText(tr("%1k").arg(m_tvSampleRate/1000.0f, 0, 'f', 2));
@ -178,7 +180,6 @@ void ATVDemodGUI::applyTVSampleRate()
displayRFBandwidths(); displayRFBandwidths();
lineTimeUpdate(); lineTimeUpdate();
topTimeUpdate(); topTimeUpdate();
blockApplySettings(false);
} }
bool ATVDemodGUI::handleMessage(const Message& message) bool ATVDemodGUI::handleMessage(const Message& message)
@ -235,7 +236,7 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Base
m_pluginAPI(objPluginAPI), m_pluginAPI(objPluginAPI),
m_deviceUISet(deviceUISet), m_deviceUISet(deviceUISet),
m_channelMarker(this), m_channelMarker(this),
m_blnDoApplySettings(true), m_doApplySettings(false),
m_intTickCount(0), m_intTickCount(0),
m_basebandSampleRate(48000), m_basebandSampleRate(48000),
m_tvSampleRate(48000) m_tvSampleRate(48000)
@ -306,14 +307,11 @@ ATVDemodGUI::~ATVDemodGUI()
delete ui; delete ui;
} }
void ATVDemodGUI::blockApplySettings(bool blnBlock)
{
m_blnDoApplySettings = !blnBlock;
}
void ATVDemodGUI::applySettings(bool force) void ATVDemodGUI::applySettings(bool force)
{ {
if (m_blnDoApplySettings) qDebug() << "ATVDemodGUI::applySettings: " << force << " m_doApplySettings: " << m_doApplySettings;
if (m_doApplySettings)
{ {
ATVDemod::MsgConfigureATVDemod *msg = ATVDemod::MsgConfigureATVDemod::create(m_settings, force); ATVDemod::MsgConfigureATVDemod *msg = ATVDemod::MsgConfigureATVDemod::create(m_settings, force);
m_atvDemod->getInputMessageQueue()->push(msg); m_atvDemod->getInputMessageQueue()->push(msg);
@ -322,8 +320,12 @@ void ATVDemodGUI::applySettings(bool force)
void ATVDemodGUI::setChannelMarkerBandwidth() void ATVDemodGUI::setChannelMarkerBandwidth()
{ {
m_blnDoApplySettings = false; // avoid infinite recursion // avoid infinite recursion
m_channelMarker.blockSignals(true); m_channelMarker.blockSignals(true);
ui->rfFiltering->blockSignals(true);
ui->rfBW->blockSignals(true);
ui->rfOppBW->blockSignals(true);
ui->modulation->blockSignals(true);
if (ui->rfFiltering->isChecked()) // FFT filter if (ui->rfFiltering->isChecked()) // FFT filter
{ {
@ -351,7 +353,11 @@ void ATVDemodGUI::setChannelMarkerBandwidth()
m_channelMarker.blockSignals(false); m_channelMarker.blockSignals(false);
m_channelMarker.emitChangedByAPI(); m_channelMarker.emitChangedByAPI();
m_blnDoApplySettings = true;
ui->rfFiltering->blockSignals(false);
ui->rfBW->blockSignals(false);
ui->rfOppBW->blockSignals(false);
ui->modulation->blockSignals(false);
} }
void ATVDemodGUI::setRFFiltersSlidersRange(int sampleRate) void ATVDemodGUI::setRFFiltersSlidersRange(int sampleRate)

View File

@ -69,7 +69,7 @@ private:
ATVDemod* m_atvDemod; ATVDemod* m_atvDemod;
ATVDemodSettings m_settings; ATVDemodSettings m_settings;
bool m_blnDoApplySettings; bool m_doApplySettings;
MovingAverageUtil<double, double, 4> m_objMagSqAverage; MovingAverageUtil<double, double, 4> m_objMagSqAverage;
int m_intTickCount; int m_intTickCount;
@ -85,7 +85,6 @@ private:
explicit ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* objParent = 0); explicit ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* objParent = 0);
virtual ~ATVDemodGUI(); virtual ~ATVDemodGUI();
void blockApplySettings(bool blnBlock);
void applySettings(bool force = false); void applySettings(bool force = false);
void displaySettings(); void displaySettings();
void displayStreamIndex(); void displayStreamIndex();