diff --git a/plugins/channelrx/demoddsd/dsddemod.cpp b/plugins/channelrx/demoddsd/dsddemod.cpp index 5c6debe93..b61ced5d0 100644 --- a/plugins/channelrx/demoddsd/dsddemod.cpp +++ b/plugins/channelrx/demoddsd/dsddemod.cpp @@ -718,17 +718,16 @@ void DSDDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& resp void DSDDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) { + if (!m_running) { + return; + } + double magsqAvg, magsqPeak; int nbMagsqSamples; getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples); - - if (m_running) - { - response.getDsdDemodReport()->setAudioSampleRate(m_basebandSink->getAudioSampleRate()); - response.getDsdDemodReport()->setChannelSampleRate(m_basebandSink->getChannelSampleRate()); - response.getDsdDemodReport()->setSquelch(m_basebandSink->getSquelchOpen() ? 1 : 0); - } - + response.getDsdDemodReport()->setAudioSampleRate(m_basebandSink->getAudioSampleRate()); + response.getDsdDemodReport()->setChannelSampleRate(m_basebandSink->getChannelSampleRate()); + response.getDsdDemodReport()->setSquelch(m_basebandSink->getSquelchOpen() ? 1 : 0); response.getDsdDemodReport()->setChannelPowerDb(CalcDb::dbPower(magsqAvg)); response.getDsdDemodReport()->setPllLocked(getDecoder().getSymbolPLLLocked() ? 1 : 0); response.getDsdDemodReport()->setSlot1On(getDecoder().getVoice1On() ? 1 : 0); diff --git a/plugins/channelrx/demoddsd/dsddemod.h b/plugins/channelrx/demoddsd/dsddemod.h index 100527e1c..498605905 100644 --- a/plugins/channelrx/demoddsd/dsddemod.h +++ b/plugins/channelrx/demoddsd/dsddemod.h @@ -155,14 +155,24 @@ public: SWGSDRangel::SWGChannelSettings& response); uint32_t getNumberOfDeviceStreams() const; - void setScopeXYSink(BasebandSampleSink* sampleSink) { m_basebandSink->setScopeXYSink(sampleSink); } - void configureMyPosition(float myLatitude, float myLongitude) { m_basebandSink->configureMyPosition(myLatitude, myLongitude); } - double getMagSq() { return m_basebandSink->getMagSq(); } - bool getSquelchOpen() const { return m_basebandSink->getSquelchOpen(); } + void setScopeXYSink(BasebandSampleSink* sampleSink) { if (m_running) { m_basebandSink->setScopeXYSink(sampleSink); } } + void configureMyPosition(float myLatitude, float myLongitude) { if (m_running) { m_basebandSink->configureMyPosition(myLatitude, myLongitude); } } + double getMagSq() { return m_running ? m_basebandSink->getMagSq() : 0.0; } + bool getSquelchOpen() const { return m_running && m_basebandSink->getSquelchOpen(); } const DSDDecoder& getDecoder() const { return m_basebandSink->getDecoder(); } - void getMagSqLevels(double& avg, double& peak, int& nbSamples) { m_basebandSink->getMagSqLevels(avg, peak, nbSamples); } - const char *updateAndGetStatusText() { return m_basebandSink->updateAndGetStatusText(); } - int getAudioSampleRate() const { return m_basebandSink->getAudioSampleRate(); } + + void getMagSqLevels(double& avg, double& peak, int& nbSamples) + { + if (m_running) { + m_basebandSink->getMagSqLevels(avg, peak, nbSamples); + } else { + avg = 0.0; peak = 0.0; nbSamples = 1; + } + } + + const char *updateAndGetStatusText() { return m_running ? m_basebandSink->updateAndGetStatusText() : nullptr; } + int getAudioSampleRate() const { return m_running ? m_basebandSink->getAudioSampleRate() : 0; } + bool isRunning() { return m_running; } static const char* const m_channelIdURI; static const char* const m_channelId; diff --git a/plugins/channelrx/demoddsd/dsddemodgui.cpp b/plugins/channelrx/demoddsd/dsddemodgui.cpp index 1ea16f926..767d4ff3f 100644 --- a/plugins/channelrx/demoddsd/dsddemodgui.cpp +++ b/plugins/channelrx/demoddsd/dsddemodgui.cpp @@ -651,7 +651,7 @@ void DSDDemodGUI::tick() // "slow" updates - if (m_tickCount % 10 == 0) + if (m_dsdDemod->isRunning() & (m_tickCount % 10 == 0)) { ui->inLevelText->setText(QString::number(m_dsdDemod->getDecoder().getInLevel())); ui->inCarrierPosText->setText(QString::number(m_dsdDemod->getDecoder().getCarrierPos()));