From 8814fda178274c68c1abe2dded532e501aa6a493 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Sun, 22 Oct 2023 23:24:34 +0100 Subject: [PATCH 1/2] Fix race condition that can result in a crash or hang --- plugins/channelrx/demodais/aisdemodbaseband.cpp | 1 + plugins/channelrx/demodais/aisdemodgui.cpp | 1 - plugins/channelrx/demoddsc/dscdemodbaseband.cpp | 7 ++++--- plugins/channelrx/demoddsc/dscdemodbaseband.h | 2 +- plugins/channelrx/demoddsc/dscdemodgui.cpp | 1 - plugins/channelrx/demoddsc/dscdemodsink.h | 2 +- plugins/channelrx/demodnavtex/navtexdemodbaseband.cpp | 6 +++--- plugins/channelrx/demodnavtex/navtexdemodbaseband.h | 2 +- plugins/channelrx/demodrtty/rttydemodbaseband.cpp | 6 +++--- plugins/channelrx/demodrtty/rttydemodbaseband.h | 2 +- plugins/channelrx/radioclock/radioclockbaseband.cpp | 1 + plugins/channelrx/radioclock/radioclockgui.cpp | 1 - 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/channelrx/demodais/aisdemodbaseband.cpp b/plugins/channelrx/demodais/aisdemodbaseband.cpp index 9dfc12669b..dc5c2c457e 100644 --- a/plugins/channelrx/demodais/aisdemodbaseband.cpp +++ b/plugins/channelrx/demodais/aisdemodbaseband.cpp @@ -32,6 +32,7 @@ AISDemodBaseband::AISDemodBaseband(AISDemod *aisDemod) : { qDebug("AISDemodBaseband::AISDemodBaseband"); + m_scopeSink.setNbStreams(AISDemodSettings::m_scopeStreams); m_sink.setScopeSink(&m_scopeSink); m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000)); m_channelizer = new DownChannelizer(&m_sink); diff --git a/plugins/channelrx/demodais/aisdemodgui.cpp b/plugins/channelrx/demodais/aisdemodgui.cpp index 99418b65eb..8de67e1bbb 100644 --- a/plugins/channelrx/demodais/aisdemodgui.cpp +++ b/plugins/channelrx/demodais/aisdemodgui.cpp @@ -744,7 +744,6 @@ AISDemodGUI::AISDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban m_scopeVis = m_aisDemod->getScopeSink(); m_scopeVis->setGLScope(ui->glScope); - m_scopeVis->setNbStreams(AISDemodSettings::m_scopeStreams); ui->glScope->connectTimer(MainCore::instance()->getMasterTimer()); ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope); ui->scopeGUI->setStreams(QStringList({"IQ", "MagSq", "FM demod", "Gaussian", "RX buf", "Correlation", "Threshold met", "DC offset", "CRC"})); diff --git a/plugins/channelrx/demoddsc/dscdemodbaseband.cpp b/plugins/channelrx/demoddsc/dscdemodbaseband.cpp index c154aa2a0d..bf4481173b 100644 --- a/plugins/channelrx/demoddsc/dscdemodbaseband.cpp +++ b/plugins/channelrx/demoddsc/dscdemodbaseband.cpp @@ -26,12 +26,13 @@ MESSAGE_CLASS_DEFINITION(DSCDemodBaseband::MsgConfigureDSCDemodBaseband, Message) -DSCDemodBaseband::DSCDemodBaseband(DSCDemod *packetDemod) : - m_sink(packetDemod), +DSCDemodBaseband::DSCDemodBaseband(DSCDemod *dscDemod) : + m_sink(dscDemod), m_running(false) { qDebug("DSCDemodBaseband::DSCDemodBaseband"); + m_scopeSink.setNbStreams(DSCDemodSettings::m_scopeStreams); m_sink.setScopeSink(&m_scopeSink); m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000)); m_channelizer = new DownChannelizer(&m_sink); @@ -92,7 +93,7 @@ void DSCDemodBaseband::handleData() { QMutexLocker mutexLocker(&m_mutex); - while ((m_sampleFifo.fill() > 0) && (m_inputMessageQueue.size() == 0)) + while ((m_sampleFifo.fill() > 0) && (m_inputMessageQueue.size() == 0) && m_channelizer->getBasebandSampleRate()) { SampleVector::iterator part1begin; SampleVector::iterator part1end; diff --git a/plugins/channelrx/demoddsc/dscdemodbaseband.h b/plugins/channelrx/demoddsc/dscdemodbaseband.h index c1dc622d46..c5f6619438 100644 --- a/plugins/channelrx/demoddsc/dscdemodbaseband.h +++ b/plugins/channelrx/demoddsc/dscdemodbaseband.h @@ -61,7 +61,7 @@ class DSCDemodBaseband : public QObject { } }; - DSCDemodBaseband(DSCDemod *packetDemod); + DSCDemodBaseband(DSCDemod *dscDemod); ~DSCDemodBaseband(); void reset(); void startWork(); diff --git a/plugins/channelrx/demoddsc/dscdemodgui.cpp b/plugins/channelrx/demoddsc/dscdemodgui.cpp index 9f4e3b400c..b8a48cc1d6 100644 --- a/plugins/channelrx/demoddsc/dscdemodgui.cpp +++ b/plugins/channelrx/demoddsc/dscdemodgui.cpp @@ -576,7 +576,6 @@ DSCDemodGUI::DSCDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban m_scopeVis = m_dscDemod->getScopeSink(); m_scopeVis->setGLScope(ui->glScope); - m_scopeVis->setNbStreams(DSCDemodSettings::m_scopeStreams); ui->glScope->connectTimer(MainCore::instance()->getMasterTimer()); ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope); ui->scopeGUI->setStreams(QStringList({"IQ", "MagSq", "abs1", "abs2", "Unbiased", "Biased", "Data", "Clock", "Bit", "GotSOP"})); diff --git a/plugins/channelrx/demoddsc/dscdemodsink.h b/plugins/channelrx/demoddsc/dscdemodsink.h index 3cce471c51..dedf6db7bf 100644 --- a/plugins/channelrx/demoddsc/dscdemodsink.h +++ b/plugins/channelrx/demoddsc/dscdemodsink.h @@ -41,7 +41,7 @@ class ScopeVis; class DSCDemodSink : public ChannelSampleSink { public: - DSCDemodSink(DSCDemod *packetDemod); + DSCDemodSink(DSCDemod *dscDemod); ~DSCDemodSink(); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end); diff --git a/plugins/channelrx/demodnavtex/navtexdemodbaseband.cpp b/plugins/channelrx/demodnavtex/navtexdemodbaseband.cpp index 19bc98476f..a22cebdedf 100644 --- a/plugins/channelrx/demodnavtex/navtexdemodbaseband.cpp +++ b/plugins/channelrx/demodnavtex/navtexdemodbaseband.cpp @@ -26,8 +26,8 @@ MESSAGE_CLASS_DEFINITION(NavtexDemodBaseband::MsgConfigureNavtexDemodBaseband, Message) -NavtexDemodBaseband::NavtexDemodBaseband(NavtexDemod *packetDemod) : - m_sink(packetDemod), +NavtexDemodBaseband::NavtexDemodBaseband(NavtexDemod *navtexDemod) : + m_sink(navtexDemod), m_running(false) { qDebug("NavtexDemodBaseband::NavtexDemodBaseband"); @@ -92,7 +92,7 @@ void NavtexDemodBaseband::handleData() { QMutexLocker mutexLocker(&m_mutex); - while ((m_sampleFifo.fill() > 0) && (m_inputMessageQueue.size() == 0)) + while ((m_sampleFifo.fill() > 0) && (m_inputMessageQueue.size() == 0) && m_channelizer->getBasebandSampleRate()) { SampleVector::iterator part1begin; SampleVector::iterator part1end; diff --git a/plugins/channelrx/demodnavtex/navtexdemodbaseband.h b/plugins/channelrx/demodnavtex/navtexdemodbaseband.h index d8ab73ff97..db80d8ef57 100644 --- a/plugins/channelrx/demodnavtex/navtexdemodbaseband.h +++ b/plugins/channelrx/demodnavtex/navtexdemodbaseband.h @@ -61,7 +61,7 @@ class NavtexDemodBaseband : public QObject { } }; - NavtexDemodBaseband(NavtexDemod *packetDemod); + NavtexDemodBaseband(NavtexDemod *navtexDemod); ~NavtexDemodBaseband(); void reset(); void startWork(); diff --git a/plugins/channelrx/demodrtty/rttydemodbaseband.cpp b/plugins/channelrx/demodrtty/rttydemodbaseband.cpp index 3cd28f59bb..aeb5b41930 100644 --- a/plugins/channelrx/demodrtty/rttydemodbaseband.cpp +++ b/plugins/channelrx/demodrtty/rttydemodbaseband.cpp @@ -26,8 +26,8 @@ MESSAGE_CLASS_DEFINITION(RttyDemodBaseband::MsgConfigureRttyDemodBaseband, Message) -RttyDemodBaseband::RttyDemodBaseband(RttyDemod *packetDemod) : - m_sink(packetDemod), +RttyDemodBaseband::RttyDemodBaseband(RttyDemod *rttyDemod) : + m_sink(rttyDemod), m_running(false) { qDebug("RttyDemodBaseband::RttyDemodBaseband"); @@ -92,7 +92,7 @@ void RttyDemodBaseband::handleData() { QMutexLocker mutexLocker(&m_mutex); - while ((m_sampleFifo.fill() > 0) && (m_inputMessageQueue.size() == 0)) + while ((m_sampleFifo.fill() > 0) && (m_inputMessageQueue.size() == 0) && m_channelizer->getBasebandSampleRate()) { SampleVector::iterator part1begin; SampleVector::iterator part1end; diff --git a/plugins/channelrx/demodrtty/rttydemodbaseband.h b/plugins/channelrx/demodrtty/rttydemodbaseband.h index d45b1eb5d2..864bac32d6 100644 --- a/plugins/channelrx/demodrtty/rttydemodbaseband.h +++ b/plugins/channelrx/demodrtty/rttydemodbaseband.h @@ -61,7 +61,7 @@ class RttyDemodBaseband : public QObject { } }; - RttyDemodBaseband(RttyDemod *packetDemod); + RttyDemodBaseband(RttyDemod *rttyDemod); ~RttyDemodBaseband(); void reset(); void startWork(); diff --git a/plugins/channelrx/radioclock/radioclockbaseband.cpp b/plugins/channelrx/radioclock/radioclockbaseband.cpp index 02c9c9c00a..6c94f019b0 100644 --- a/plugins/channelrx/radioclock/radioclockbaseband.cpp +++ b/plugins/channelrx/radioclock/radioclockbaseband.cpp @@ -33,6 +33,7 @@ RadioClockBaseband::RadioClockBaseband(RadioClock *radioClock) : { qDebug("RadioClockBaseband::RadioClockBaseband"); + m_scopeSink.setNbStreams(RadioClockSettings::m_scopeStreams); m_sink.setScopeSink(&m_scopeSink); m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000)); m_channelizer = new DownChannelizer(&m_sink); diff --git a/plugins/channelrx/radioclock/radioclockgui.cpp b/plugins/channelrx/radioclock/radioclockgui.cpp index b6f14c252b..032d6c34c9 100644 --- a/plugins/channelrx/radioclock/radioclockgui.cpp +++ b/plugins/channelrx/radioclock/radioclockgui.cpp @@ -292,7 +292,6 @@ RadioClockGUI::RadioClockGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas m_scopeVis = m_radioClock->getScopeSink(); m_scopeVis->setGLScope(ui->glScope); - m_scopeVis->setNbStreams(RadioClockSettings::m_scopeStreams); m_scopeVis->setLiveRate(RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE); ui->glScope->connectTimer(MainCore::instance()->getMasterTimer()); ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope); From 7dca35ac2420c940ac067d6ed829c6baf51637e9 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Sun, 22 Oct 2023 23:25:12 +0100 Subject: [PATCH 2/2] Initialise m_scopeSink --- plugins/channelrx/demoddsc/dscdemodsink.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/channelrx/demoddsc/dscdemodsink.cpp b/plugins/channelrx/demoddsc/dscdemodsink.cpp index 0eae78418e..9f8fa5ee71 100644 --- a/plugins/channelrx/demoddsc/dscdemodsink.cpp +++ b/plugins/channelrx/demoddsc/dscdemodsink.cpp @@ -29,8 +29,9 @@ #include "dscdemod.h" #include "dscdemodsink.h" -DSCDemodSink::DSCDemodSink(DSCDemod *packetDemod) : - m_dscDemod(packetDemod), +DSCDemodSink::DSCDemodSink(DSCDemod *dscDemod) : + m_scopeSink(nullptr), + m_dscDemod(dscDemod), m_channelSampleRate(DSCDemodSettings::DSCDEMOD_CHANNEL_SAMPLE_RATE), m_channelFrequencyOffset(0), m_magsqSum(0.0f),