From 60db324abca43dee50117b5d7321bbb367ec42cd Mon Sep 17 00:00:00 2001 From: srcejon Date: Wed, 8 May 2024 18:43:19 +0100 Subject: [PATCH] Bring BFM demod closer to AM demod design. --- plugins/channelrx/demodbfm/bfmdemod.cpp | 15 +++++++++------ plugins/channelrx/demodbfm/bfmdemod.h | 1 - plugins/channelrx/demodbfm/bfmdemodbaseband.cpp | 3 +-- plugins/channelrx/demodbfm/bfmdemodgui.cpp | 1 - plugins/channelrx/demodbfm/bfmdemodsink.cpp | 4 +++- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/plugins/channelrx/demodbfm/bfmdemod.cpp b/plugins/channelrx/demodbfm/bfmdemod.cpp index 679dc1765..f3dfd3d5e 100644 --- a/plugins/channelrx/demodbfm/bfmdemod.cpp +++ b/plugins/channelrx/demodbfm/bfmdemod.cpp @@ -76,7 +76,6 @@ BFMDemod::BFMDemod(DeviceAPI *deviceAPI) : this, &BFMDemod::handleIndexInDeviceSetChanged ); - start(); } BFMDemod::~BFMDemod() @@ -129,21 +128,25 @@ void BFMDemod::start() m_basebandSink->setSpectrumSink(&m_spectrumVis); m_basebandSink->setChannel(this); m_basebandSink->moveToThread(m_thread); + m_basebandSink->setMessageQueueToGUI(getMessageQueueToGUI()); QObject::connect(m_thread, &QThread::finished, m_basebandSink, &QObject::deleteLater); QObject::connect(m_thread, &QThread::finished, m_thread, &QThread::deleteLater); - if (m_basebandSampleRate != 0) { - m_basebandSink->setBasebandSampleRate(m_basebandSampleRate); - } m_basebandSink->reset(); m_basebandSink->startWork(); m_thread->start(); + DSPSignalNotification *dspMsg = new DSPSignalNotification(m_basebandSampleRate, 0); + m_basebandSink->getInputMessageQueue()->push(dspMsg); + + BFMDemodBaseband::MsgConfigureBFMDemodBaseband *msg = BFMDemodBaseband::MsgConfigureBFMDemodBaseband::create(m_settings, true); + m_basebandSink->getInputMessageQueue()->push(msg); + SpectrumSettings spectrumSettings = m_spectrumVis.getSettings(); spectrumSettings.m_ssb = true; - SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false); - m_spectrumVis.getInputMessageQueue()->push(msg); + SpectrumVis::MsgConfigureSpectrumVis *visMsg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false); + m_spectrumVis.getInputMessageQueue()->push(visMsg); m_running = true; } diff --git a/plugins/channelrx/demodbfm/bfmdemod.h b/plugins/channelrx/demodbfm/bfmdemod.h index 321d48c2e..6580e6ed3 100644 --- a/plugins/channelrx/demodbfm/bfmdemod.h +++ b/plugins/channelrx/demodbfm/bfmdemod.h @@ -76,7 +76,6 @@ public: virtual void setDeviceAPI(DeviceAPI *deviceAPI); virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; } SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } - void setBasebandMessageQueueToGUI(MessageQueue *messageQueue) { m_basebandSink->setMessageQueueToGUI(messageQueue); } using BasebandSampleSink::feed; virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); diff --git a/plugins/channelrx/demodbfm/bfmdemodbaseband.cpp b/plugins/channelrx/demodbfm/bfmdemodbaseband.cpp index c27ffced8..f0f6d5466 100644 --- a/plugins/channelrx/demodbfm/bfmdemodbaseband.cpp +++ b/plugins/channelrx/demodbfm/bfmdemodbaseband.cpp @@ -43,8 +43,6 @@ BFMDemodBaseband::BFMDemodBaseband() : DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue()); m_sink.applyAudioSampleRate(DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate()); m_channelSampleRate = 0; - - connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); } BFMDemodBaseband::~BFMDemodBaseband() @@ -56,6 +54,7 @@ BFMDemodBaseband::~BFMDemodBaseband() void BFMDemodBaseband::reset() { QMutexLocker mutexLocker(&m_mutex); + m_inputMessageQueue.clear(); m_sampleFifo.reset(); m_channelSampleRate = 0; } diff --git a/plugins/channelrx/demodbfm/bfmdemodgui.cpp b/plugins/channelrx/demodbfm/bfmdemodgui.cpp index 18f4f7c66..516132209 100644 --- a/plugins/channelrx/demodbfm/bfmdemodgui.cpp +++ b/plugins/channelrx/demodbfm/bfmdemodgui.cpp @@ -413,7 +413,6 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban m_spectrumVis = m_bfmDemod->getSpectrumVis(); m_spectrumVis->setGLSpectrum(ui->glSpectrum); m_bfmDemod->setMessageQueueToGUI(getInputMessageQueue()); - m_bfmDemod->setBasebandMessageQueueToGUI(getInputMessageQueue()); ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum); diff --git a/plugins/channelrx/demodbfm/bfmdemodsink.cpp b/plugins/channelrx/demodbfm/bfmdemodsink.cpp index da4ebcdf3..c339e00ca 100644 --- a/plugins/channelrx/demodbfm/bfmdemodsink.cpp +++ b/plugins/channelrx/demodbfm/bfmdemodsink.cpp @@ -222,8 +222,10 @@ void BFMDemodSink::feed(const SampleVector::const_iterator& begin, const SampleV { std::size_t res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], std::min(m_audioBufferFill, m_audioBuffer.size())); - if(res != m_audioBufferFill) { + if (res != m_audioBufferFill) + { qDebug("BFMDemodSink::feed: %lu/%lu audio samples written", res, m_audioBufferFill); + m_audioFifo.clear(); } m_audioBufferFill = 0;