From 414e69512198063fe92f3dd0032c2c0e04e5e332 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 27 Jul 2022 08:58:24 +0200 Subject: [PATCH] DATV demod: allocate DATVDemodSink dynamically --- .../channelrx/demoddatv/datvdemodbaseband.cpp | 16 +++--- .../channelrx/demoddatv/datvdemodbaseband.h | 51 ++++++++++--------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/plugins/channelrx/demoddatv/datvdemodbaseband.cpp b/plugins/channelrx/demoddatv/datvdemodbaseband.cpp index 69c132ce6..c065b8ecf 100644 --- a/plugins/channelrx/demoddatv/datvdemodbaseband.cpp +++ b/plugins/channelrx/demoddatv/datvdemodbaseband.cpp @@ -31,12 +31,14 @@ DATVDemodBaseband::DATVDemodBaseband() : { qDebug("DATVDemodBaseband::DATVDemodBaseband"); m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000)); - m_channelizer = new DownChannelizer(&m_sink); + m_sink = new DATVDemodSink(); + m_channelizer = new DownChannelizer(m_sink); } DATVDemodBaseband::~DATVDemodBaseband() { delete m_channelizer; + delete m_sink; } void DATVDemodBaseband::reset() @@ -62,7 +64,7 @@ void DATVDemodBaseband::startWork() void DATVDemodBaseband::stopWork() { QMutexLocker mutexLocker(&m_mutex); - m_sink.stopVideo(); + m_sink->stopVideo(); disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); QObject::disconnect( &m_sampleFifo, @@ -136,7 +138,7 @@ bool DATVDemodBaseband::handleMessage(const Message& cmd) qDebug() << "DATVDemodBaseband::handleMessage: DSPSignalNotification: basebandSampleRate: " << notif.getSampleRate(); m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getSampleRate())); m_channelizer->setBasebandSampleRate(notif.getSampleRate()); - m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset()); + m_sink->applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset()); return true; } @@ -156,17 +158,17 @@ void DATVDemodBaseband::applySettings(const DATVDemodSettings& settings, bool fo unsigned int desiredSampleRate = 2 * settings.m_symbolRate; // m_channelizer->getBasebandSampleRate(); m_channelizer->setChannelization(desiredSampleRate, settings.m_centerFrequency); m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(m_channelizer->getBasebandSampleRate())); - m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset()); + m_sink->applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset()); } if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) { AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager(); int audioDeviceIndex = audioDeviceManager->getOutputDeviceIndex(settings.m_audioDeviceName); - audioDeviceManager->addAudioSink(m_sink.getAudioFifo(), getInputMessageQueue(), audioDeviceIndex); + audioDeviceManager->addAudioSink(m_sink->getAudioFifo(), getInputMessageQueue(), audioDeviceIndex); } - m_sink.applySettings(settings, force); + m_sink->applySettings(settings, force); m_settings = settings; } @@ -180,5 +182,5 @@ void DATVDemodBaseband::setBasebandSampleRate(int sampleRate) { qDebug("DATVDemodBaseband::setBasebandSampleRate: %d", sampleRate); m_channelizer->setBasebandSampleRate(sampleRate); - m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset()); + m_sink->applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset()); } diff --git a/plugins/channelrx/demoddatv/datvdemodbaseband.h b/plugins/channelrx/demoddatv/datvdemodbaseband.h index b06b3345f..ad7c60ce2 100644 --- a/plugins/channelrx/demoddatv/datvdemodbaseband.h +++ b/plugins/channelrx/demoddatv/datvdemodbaseband.h @@ -25,6 +25,7 @@ #include "util/message.h" #include "util/messagequeue.h" +#include "datvdemodsettings.h" #include "datvdemodsink.h" class DownChannelizer; @@ -64,39 +65,39 @@ public: void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end); MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication int getChannelSampleRate() const; - double getMagSq() const { return m_sink.getMagSq(); } - void setTVScreen(TVScreen *tvScreen) { m_sink.setTVScreen(tvScreen); } - float getMERAvg() const { return m_sink.getMERAvg(); } - float getMERRMS() const { return m_sink.getMERRMS(); } - float getMERPeak() const { return m_sink.getMERPeak(); } - int getMERNbAvg() const { return m_sink.getMERNbAvg(); } - float getCNRAvg() const { return m_sink.getCNRAvg(); } - float getCNRRMS() const { return m_sink.getCNRRMS(); } - float getCNRPeak() const { return m_sink.getCNRPeak(); } - int getCNRNbAvg() const { return m_sink.getCNRNbAvg(); } - void setMessageQueueToGUI(MessageQueue *messageQueue) { m_sink.setMessageQueueToGUI(messageQueue); } + double getMagSq() const { return m_sink->getMagSq(); } + void setTVScreen(TVScreen *tvScreen) { m_sink->setTVScreen(tvScreen); } + float getMERAvg() const { return m_sink->getMERAvg(); } + float getMERRMS() const { return m_sink->getMERRMS(); } + float getMERPeak() const { return m_sink->getMERPeak(); } + int getMERNbAvg() const { return m_sink->getMERNbAvg(); } + float getCNRAvg() const { return m_sink->getCNRAvg(); } + float getCNRRMS() const { return m_sink->getCNRRMS(); } + float getCNRPeak() const { return m_sink->getCNRPeak(); } + int getCNRNbAvg() const { return m_sink->getCNRNbAvg(); } + void setMessageQueueToGUI(MessageQueue *messageQueue) { m_sink->setMessageQueueToGUI(messageQueue); } void setBasebandSampleRate(int sampleRate); //!< To be used when supporting thread is stopped - void SetVideoRender(DATVideoRender *objScreen) { m_sink.SetVideoRender(objScreen); } - DATVideostream *getVideoStream() { return m_sink.getVideoStream(); } - DATVUDPStream *getUDPStream() { return m_sink.getUDPStream(); } - bool audioActive() { return m_sink.audioActive(); } - bool audioDecodeOK() { return m_sink.audioDecodeOK(); } - bool videoActive() { return m_sink.videoActive(); } - bool videoDecodeOK() { return m_sink.videoDecodeOK(); } - bool udpRunning() { return m_sink.udpRunning(); } - bool playVideo() { return m_sink.playVideo(); } + void SetVideoRender(DATVideoRender *objScreen) { m_sink->SetVideoRender(objScreen); } + DATVideostream *getVideoStream() { return m_sink->getVideoStream(); } + DATVUDPStream *getUDPStream() { return m_sink->getUDPStream(); } + bool audioActive() { return m_sink->audioActive(); } + bool audioDecodeOK() { return m_sink->audioDecodeOK(); } + bool videoActive() { return m_sink->videoActive(); } + bool videoDecodeOK() { return m_sink->videoDecodeOK(); } + bool udpRunning() { return m_sink->udpRunning(); } + bool playVideo() { return m_sink->playVideo(); } - int getModcodModulation() const { return m_sink.getModcodModulation(); } - int getModcodCodeRate() const { return m_sink.getModcodCodeRate(); } - bool isCstlnSetByModcod() const { return m_sink.isCstlnSetByModcod(); } + int getModcodModulation() const { return m_sink->getModcodModulation(); } + int getModcodCodeRate() const { return m_sink->getModcodCodeRate(); } + bool isCstlnSetByModcod() const { return m_sink->isCstlnSetByModcod(); } bool isRunning() const { return m_running; } void setFifoLabel(const QString& label) { m_sampleFifo.setLabel(label); } - void setAudioFifoLabel(const QString& label) { m_sink.setAudioFifoLabel(label); } + void setAudioFifoLabel(const QString& label) { m_sink->setAudioFifoLabel(label); } private: SampleSinkFifo m_sampleFifo; DownChannelizer *m_channelizer; - DATVDemodSink m_sink; + DATVDemodSink *m_sink; MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication DATVDemodSettings m_settings; bool m_running;