From 1359aac9b67defeae56c71523e69013807d5c653 Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 13 Dec 2019 00:34:27 +0100 Subject: [PATCH] Removed ThreadedBasebandSampleSink --- plugins/channelrx/chanalyzer/chanalyzer.cpp | 1 - .../channelrx/chanalyzer/chanalyzergui.cpp | 1 - plugins/channelrx/demodam/amdemodgui.cpp | 1 - plugins/channelrx/demodatv/atvdemodgui.cpp | 1 - plugins/channelrx/demodbfm/bfmdemodgui.cpp | 1 - plugins/channelrx/demoddatv/datvdemodgui.cpp | 1 - plugins/channelrx/demoddatv/datvdemodsink.cpp | 1 - plugins/channelrx/demoddsd/dsddemodgui.cpp | 1 - plugins/channelrx/demodlora/lorademod.cpp | 1 - plugins/channelrx/demodwfm/wfmdemod.cpp | 1 - plugins/channelrx/freqtracker/freqtracker.cpp | 1 - plugins/channelrx/localsink/localsink.cpp | 1 - plugins/channelrx/udpsink/udpsink.cpp | 1 - sdrbase/CMakeLists.txt | 2 - sdrbase/device/deviceapi.cpp | 20 --- sdrbase/device/deviceapi.h | 3 - sdrbase/dsp/dspcommands.cpp | 2 - sdrbase/dsp/dspcommands.h | 25 ---- sdrbase/dsp/dspdevicemimoengine.cpp | 104 +------------- sdrbase/dsp/dspdevicemimoengine.h | 36 ----- sdrbase/dsp/dspdevicesourceengine.cpp | 86 ------------ sdrbase/dsp/dspdevicesourceengine.h | 7 - sdrbase/dsp/threadedbasebandsamplesink.cpp | 130 ------------------ sdrbase/dsp/threadedbasebandsamplesink.h | 79 ----------- 24 files changed, 1 insertion(+), 506 deletions(-) delete mode 100644 sdrbase/dsp/threadedbasebandsamplesink.cpp delete mode 100644 sdrbase/dsp/threadedbasebandsamplesink.h diff --git a/plugins/channelrx/chanalyzer/chanalyzer.cpp b/plugins/channelrx/chanalyzer/chanalyzer.cpp index ef682d2eb..96ff80006 100644 --- a/plugins/channelrx/chanalyzer/chanalyzer.cpp +++ b/plugins/channelrx/chanalyzer/chanalyzer.cpp @@ -23,7 +23,6 @@ #include "device/deviceapi.h" #include "audio/audiooutput.h" -#include "dsp/threadedbasebandsamplesink.h" #include "dsp/downchannelizer.h" #include "dsp/dspcommands.h" #include "chanalyzer.h" diff --git a/plugins/channelrx/chanalyzer/chanalyzergui.cpp b/plugins/channelrx/chanalyzer/chanalyzergui.cpp index f1715ad1b..5599e6f18 100644 --- a/plugins/channelrx/chanalyzer/chanalyzergui.cpp +++ b/plugins/channelrx/chanalyzer/chanalyzergui.cpp @@ -20,7 +20,6 @@ #include "device/deviceuiset.h" #include "dsp/downchannelizer.h" -#include "dsp/threadedbasebandsamplesink.h" #include "dsp/spectrumscopecombovis.h" #include "dsp/spectrumvis.h" #include "dsp/dspengine.h" diff --git a/plugins/channelrx/demodam/amdemodgui.cpp b/plugins/channelrx/demodam/amdemodgui.cpp index c9154c093..523bb4a79 100644 --- a/plugins/channelrx/demodam/amdemodgui.cpp +++ b/plugins/channelrx/demodam/amdemodgui.cpp @@ -25,7 +25,6 @@ #include "device/deviceuiset.h" #include "dsp/downchannelizer.h" #include "dsp/dspengine.h" -#include "dsp/threadedbasebandsamplesink.h" #include "ui_amdemodgui.h" #include "plugin/pluginapi.h" #include "util/simpleserializer.h" diff --git a/plugins/channelrx/demodatv/atvdemodgui.cpp b/plugins/channelrx/demodatv/atvdemodgui.cpp index d618fe767..832c59994 100644 --- a/plugins/channelrx/demodatv/atvdemodgui.cpp +++ b/plugins/channelrx/demodatv/atvdemodgui.cpp @@ -24,7 +24,6 @@ #include "device/deviceuiset.h" #include "dsp/downchannelizer.h" -#include "dsp/threadedbasebandsamplesink.h" #include "dsp/scopevis.h" #include "ui_atvdemodgui.h" #include "plugin/pluginapi.h" diff --git a/plugins/channelrx/demodbfm/bfmdemodgui.cpp b/plugins/channelrx/demodbfm/bfmdemodgui.cpp index 6bffc1d04..c7414c26f 100644 --- a/plugins/channelrx/demodbfm/bfmdemodgui.cpp +++ b/plugins/channelrx/demodbfm/bfmdemodgui.cpp @@ -28,7 +28,6 @@ #include #include -#include "dsp/threadedbasebandsamplesink.h" #include "dsp/dspengine.h" #include "dsp/spectrumvis.h" #include "gui/glspectrum.h" diff --git a/plugins/channelrx/demoddatv/datvdemodgui.cpp b/plugins/channelrx/demoddatv/datvdemodgui.cpp index cfd67354c..a1bdeb7ac 100644 --- a/plugins/channelrx/demoddatv/datvdemodgui.cpp +++ b/plugins/channelrx/demoddatv/datvdemodgui.cpp @@ -23,7 +23,6 @@ #include "device/deviceuiset.h" #include "dsp/downchannelizer.h" -#include "dsp/threadedbasebandsamplesink.h" #include "dsp/dspengine.h" #include "plugin/pluginapi.h" #include "util/simpleserializer.h" diff --git a/plugins/channelrx/demoddatv/datvdemodsink.cpp b/plugins/channelrx/demoddatv/datvdemodsink.cpp index a7f5b8e1c..7b08a3bea 100644 --- a/plugins/channelrx/demoddatv/datvdemodsink.cpp +++ b/plugins/channelrx/demoddatv/datvdemodsink.cpp @@ -25,7 +25,6 @@ #include "audio/audiooutput.h" #include "dsp/dspengine.h" #include "dsp/downchannelizer.h" -#include "dsp/threadedbasebandsamplesink.h" #include "device/deviceapi.h" #include "datvdemodreport.h" diff --git a/plugins/channelrx/demoddsd/dsddemodgui.cpp b/plugins/channelrx/demoddsd/dsddemodgui.cpp index 532cc0532..213bd9179 100644 --- a/plugins/channelrx/demoddsd/dsddemodgui.cpp +++ b/plugins/channelrx/demoddsd/dsddemodgui.cpp @@ -21,7 +21,6 @@ #include "device/deviceuiset.h" #include "dsp/downchannelizer.h" -#include "dsp/threadedbasebandsamplesink.h" #include "ui_dsddemodgui.h" #include "dsp/scopevisxy.h" #include "plugin/pluginapi.h" diff --git a/plugins/channelrx/demodlora/lorademod.cpp b/plugins/channelrx/demodlora/lorademod.cpp index 6d93d46e4..758f0cdd0 100644 --- a/plugins/channelrx/demodlora/lorademod.cpp +++ b/plugins/channelrx/demodlora/lorademod.cpp @@ -24,7 +24,6 @@ #include #include "dsp/downchannelizer.h" -#include "dsp/threadedbasebandsamplesink.h" #include "dsp/dspcommands.h" #include "device/deviceapi.h" diff --git a/plugins/channelrx/demodwfm/wfmdemod.cpp b/plugins/channelrx/demodwfm/wfmdemod.cpp index 48864e0a6..5d0d62e8b 100644 --- a/plugins/channelrx/demodwfm/wfmdemod.cpp +++ b/plugins/channelrx/demodwfm/wfmdemod.cpp @@ -33,7 +33,6 @@ #include "SWGWFMDemodReport.h" #include -#include "dsp/threadedbasebandsamplesink.h" #include "device/deviceapi.h" #include "audio/audiooutput.h" #include "dsp/dspengine.h" diff --git a/plugins/channelrx/freqtracker/freqtracker.cpp b/plugins/channelrx/freqtracker/freqtracker.cpp index 8954f997f..221014168 100644 --- a/plugins/channelrx/freqtracker/freqtracker.cpp +++ b/plugins/channelrx/freqtracker/freqtracker.cpp @@ -36,7 +36,6 @@ #include "dsp/downchannelizer.h" #include "audio/audiooutput.h" #include "dsp/dspengine.h" -#include "dsp/threadedbasebandsamplesink.h" #include "dsp/dspcommands.h" #include "dsp/fftfilt.h" #include "dsp/devicesamplemimo.h" diff --git a/plugins/channelrx/localsink/localsink.cpp b/plugins/channelrx/localsink/localsink.cpp index cc7d653f6..162d0edc8 100644 --- a/plugins/channelrx/localsink/localsink.cpp +++ b/plugins/channelrx/localsink/localsink.cpp @@ -26,7 +26,6 @@ #include "SWGChannelSettings.h" #include "util/simpleserializer.h" -#include "dsp/threadedbasebandsamplesink.h" #include "dsp/downchannelizer.h" #include "dsp/dspcommands.h" #include "dsp/dspdevicesourceengine.h" diff --git a/plugins/channelrx/udpsink/udpsink.cpp b/plugins/channelrx/udpsink/udpsink.cpp index c0f727017..a146b8b13 100644 --- a/plugins/channelrx/udpsink/udpsink.cpp +++ b/plugins/channelrx/udpsink/udpsink.cpp @@ -31,7 +31,6 @@ #include "dsp/dspengine.h" #include "util/db.h" #include "dsp/downchannelizer.h" -#include "dsp/threadedbasebandsamplesink.h" #include "dsp/dspcommands.h" #include "dsp/devicesamplemimo.h" #include "device/deviceapi.h" diff --git a/sdrbase/CMakeLists.txt b/sdrbase/CMakeLists.txt index 087f70ca8..6c67935fb 100644 --- a/sdrbase/CMakeLists.txt +++ b/sdrbase/CMakeLists.txt @@ -108,7 +108,6 @@ set(sdrbase_SOURCES dsp/basebandsamplesource.cpp dsp/nullsink.cpp dsp/recursivefilters.cpp - dsp/threadedbasebandsamplesink.cpp dsp/wfir.cpp dsp/devicesamplesource.cpp dsp/devicesamplesink.cpp @@ -248,7 +247,6 @@ set(sdrbase_HEADERS dsp/basebandsamplesink.h dsp/basebandsamplesource.h dsp/nullsink.h - dsp/threadedbasebandsamplesink.h dsp/wfir.h dsp/devicesamplesource.h dsp/devicesamplesink.h diff --git a/sdrbase/device/deviceapi.cpp b/sdrbase/device/deviceapi.cpp index 7ce06727e..a3ce2c558 100644 --- a/sdrbase/device/deviceapi.cpp +++ b/sdrbase/device/deviceapi.cpp @@ -87,26 +87,6 @@ void DeviceAPI::setSpectrumSinkInput(bool sourceElseSink, unsigned int index) } } -void DeviceAPI::addChannelSink(ThreadedBasebandSampleSink* sink, int streamIndex) -{ - if (m_deviceSourceEngine) { - m_deviceSourceEngine->addThreadedSink(sink); - } else if (m_deviceMIMOEngine) { - m_deviceMIMOEngine->addChannelSink(sink, streamIndex); - } -} - -void DeviceAPI::removeChannelSink(ThreadedBasebandSampleSink* sink, int streamIndex) -{ - (void) streamIndex; - - if (m_deviceSourceEngine) { - m_deviceSourceEngine->removeThreadedSink(sink); - } else if (m_deviceMIMOEngine) { - m_deviceMIMOEngine->removeChannelSink(sink, streamIndex); - } -} - void DeviceAPI::addChannelSink(BasebandSampleSink* sink, int streamIndex) { if (m_deviceSourceEngine) { diff --git a/sdrbase/device/deviceapi.h b/sdrbase/device/deviceapi.h index fd006b45f..ba8fbebf3 100644 --- a/sdrbase/device/deviceapi.h +++ b/sdrbase/device/deviceapi.h @@ -25,7 +25,6 @@ #include "export.h" class BasebandSampleSink; -class ThreadedBasebandSampleSink; class BasebandSampleSource; class MIMOChannel; class ChannelAPI; @@ -71,8 +70,6 @@ public: void removeAncillarySink(BasebandSampleSink* sink, unsigned int index = 0); //!< Removes it void setSpectrumSinkInput(bool sourceElseSink = true, unsigned int index = 0); //!< Used in the MIMO case to select which stream is used as input to main spectrum - void addChannelSink(ThreadedBasebandSampleSink* sink, int streamIndex = 0); //!< Add a channel sink (Rx) - void removeChannelSink(ThreadedBasebandSampleSink* sink, int streamIndex = 0); //!< Remove a channel sink (Rx) void addChannelSink(BasebandSampleSink* sink, int streamIndex = 0); //!< Add a channel sink (Rx) void removeChannelSink(BasebandSampleSink* sink, int streamIndex = 0); //!< Remove a channel sink (Rx) void addChannelSource(BasebandSampleSource* sink, int streamIndex = 0); //!< Add a channel source (Tx) diff --git a/sdrbase/dsp/dspcommands.cpp b/sdrbase/dsp/dspcommands.cpp index 5ecd58e0c..1ef8bbe9a 100644 --- a/sdrbase/dsp/dspcommands.cpp +++ b/sdrbase/dsp/dspcommands.cpp @@ -35,8 +35,6 @@ MESSAGE_CLASS_DEFINITION(DSPAddBasebandSampleSource, Message) MESSAGE_CLASS_DEFINITION(DSPRemoveBasebandSampleSink, Message) MESSAGE_CLASS_DEFINITION(DSPRemoveSpectrumSink, Message) MESSAGE_CLASS_DEFINITION(DSPRemoveBasebandSampleSource, Message) -MESSAGE_CLASS_DEFINITION(DSPAddThreadedBasebandSampleSink, Message) -MESSAGE_CLASS_DEFINITION(DSPRemoveThreadedBasebandSampleSink, Message) MESSAGE_CLASS_DEFINITION(DSPAddAudioSink, Message) MESSAGE_CLASS_DEFINITION(DSPRemoveAudioSink, Message) MESSAGE_CLASS_DEFINITION(DSPConfigureCorrection, Message) diff --git a/sdrbase/dsp/dspcommands.h b/sdrbase/dsp/dspcommands.h index 6824007af..eda9ccc0e 100644 --- a/sdrbase/dsp/dspcommands.h +++ b/sdrbase/dsp/dspcommands.h @@ -26,7 +26,6 @@ class DeviceSampleSource; class BasebandSampleSink; -class ThreadedBasebandSampleSink; class DeviceSampleSink; class BasebandSampleSource; class AudioFifo; @@ -184,30 +183,6 @@ private: BasebandSampleSource* m_sampleSource; }; -class SDRBASE_API DSPAddThreadedBasebandSampleSink : public Message { - MESSAGE_CLASS_DECLARATION - -public: - DSPAddThreadedBasebandSampleSink(ThreadedBasebandSampleSink* threadedSampleSink) : Message(), m_threadedSampleSink(threadedSampleSink) { } - - ThreadedBasebandSampleSink* getThreadedSampleSink() const { return m_threadedSampleSink; } - -private: - ThreadedBasebandSampleSink* m_threadedSampleSink; -}; - -class SDRBASE_API DSPRemoveThreadedBasebandSampleSink : public Message { - MESSAGE_CLASS_DECLARATION - -public: - DSPRemoveThreadedBasebandSampleSink(ThreadedBasebandSampleSink* threadedSampleSink) : Message(), m_threadedSampleSink(threadedSampleSink) { } - - ThreadedBasebandSampleSink* getThreadedSampleSink() const { return m_threadedSampleSink; } - -private: - ThreadedBasebandSampleSink* m_threadedSampleSink; -}; - class SDRBASE_API DSPAddAudioSink : public Message { MESSAGE_CLASS_DECLARATION diff --git a/sdrbase/dsp/dspdevicemimoengine.cpp b/sdrbase/dsp/dspdevicemimoengine.cpp index 27d130a63..ad2c5da39 100644 --- a/sdrbase/dsp/dspdevicemimoengine.cpp +++ b/sdrbase/dsp/dspdevicemimoengine.cpp @@ -19,7 +19,7 @@ #include #include "dspcommands.h" -#include "threadedbasebandsamplesink.h" +#include "basebandsamplesink.h" #include "basebandsamplesource.h" #include "devicesamplemimo.h" #include "mimochannel.h" @@ -29,8 +29,6 @@ MESSAGE_CLASS_DEFINITION(DSPDeviceMIMOEngine::SetSampleMIMO, Message) MESSAGE_CLASS_DEFINITION(DSPDeviceMIMOEngine::AddBasebandSampleSource, Message) MESSAGE_CLASS_DEFINITION(DSPDeviceMIMOEngine::RemoveBasebandSampleSource, Message) -MESSAGE_CLASS_DEFINITION(DSPDeviceMIMOEngine::AddThreadedBasebandSampleSink, Message) -MESSAGE_CLASS_DEFINITION(DSPDeviceMIMOEngine::RemoveThreadedBasebandSampleSink, Message) MESSAGE_CLASS_DEFINITION(DSPDeviceMIMOEngine::AddMIMOChannel, Message) MESSAGE_CLASS_DEFINITION(DSPDeviceMIMOEngine::RemoveMIMOChannel, Message) MESSAGE_CLASS_DEFINITION(DSPDeviceMIMOEngine::AddBasebandSampleSink, Message) @@ -171,26 +169,6 @@ void DSPDeviceMIMOEngine::removeChannelSource(BasebandSampleSource* source, int m_syncMessenger.sendWait(cmd); } -void DSPDeviceMIMOEngine::addChannelSink(ThreadedBasebandSampleSink* sink, int index) -{ - qDebug() << "DSPDeviceMIMOEngine::addThreadedSink: " - << sink->objectName().toStdString().c_str() - << " at: " - << index; - AddThreadedBasebandSampleSink cmd(sink, index); - m_syncMessenger.sendWait(cmd); -} - -void DSPDeviceMIMOEngine::removeChannelSink(ThreadedBasebandSampleSink* sink, int index) -{ - qDebug() << "DSPDeviceMIMOEngine::removeThreadedSink: " - << sink->objectName().toStdString().c_str() - << " at: " - << index; - RemoveThreadedBasebandSampleSink cmd(sink, index); - m_syncMessenger.sendWait(cmd); -} - void DSPDeviceMIMOEngine::addChannelSink(BasebandSampleSink* sink, int index) { qDebug() << "DSPDeviceMIMOEngine::addChannelSink: " @@ -442,12 +420,6 @@ void DSPDeviceMIMOEngine::workSamplesSink(const SampleVector::const_iterator& vb m_spectrumSink->feed(vbegin, vend, positiveOnly); } - // feed data to threaded sinks - for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks[streamIndex].begin(); it != m_threadedBasebandSampleSinks[streamIndex].end(); ++it) - { - (*it)->feed(vbegin, vend, positiveOnly); - } - // feed data to MIMO channels for (MIMOChannels::const_iterator it = m_mimoChannels.begin(); it != m_mimoChannels.end(); ++it) { (*it)->feed(vbegin, vend, streamIndex); @@ -559,17 +531,6 @@ DSPDeviceMIMOEngine::State DSPDeviceMIMOEngine::gotoIdle(int subsystemIndex) } } - std::vector::const_iterator vtSinkIt = m_threadedBasebandSampleSinks.begin(); - - for (; vtSinkIt != m_threadedBasebandSampleSinks.end(); vtSinkIt++) - { - for (ThreadedBasebandSampleSinks::const_iterator it = vtSinkIt->begin(); it != vtSinkIt->end(); ++it) - { - qDebug() << "DSPDeviceMIMOEngine::gotoIdle: stopping ThreadedBasebandSampleSink(" << (*it)->getSampleSinkObjectName().toStdString().c_str() << ")"; - (*it)->stop(); - } - } - for (MIMOChannels::const_iterator it = m_mimoChannels.begin(); it != m_mimoChannels.end(); ++it) { qDebug() << "DSPDeviceMIMOEngine::gotoIdle: stopping MIMOChannel sinks: " << (*it)->objectName().toStdString().c_str(); @@ -676,15 +637,6 @@ DSPDeviceMIMOEngine::State DSPDeviceMIMOEngine::gotoInit(int subsystemIndex) (*it)->handleMessage(notif); } } - - if (isource < m_threadedBasebandSampleSinks.size()) - { - for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks[isource].begin(); it != m_threadedBasebandSampleSinks[isource].end(); ++it) - { - qDebug() << "DSPDeviceMIMOEngine::gotoInit: initializing ThreadedSampleSink(" << (*it)->getSampleSinkObjectName().toStdString().c_str() << ")"; - (*it)->handleSinkMessage(notif); - } - } } } else if (subsystemIndex == 1) // Tx @@ -771,17 +723,6 @@ DSPDeviceMIMOEngine::State DSPDeviceMIMOEngine::gotoRunning(int subsystemIndex) } } - std::vector::const_iterator vtSinkIt = m_threadedBasebandSampleSinks.begin(); - - for (; vtSinkIt != m_threadedBasebandSampleSinks.end(); vtSinkIt++) - { - for (ThreadedBasebandSampleSinks::const_iterator it = vtSinkIt->begin(); it != vtSinkIt->end(); ++it) - { - qDebug() << "DSPDeviceMIMOEngine::gotoRunning: starting ThreadedBasebandSampleSink(" << (*it)->getSampleSinkObjectName().toStdString().c_str() << ")"; - (*it)->start(); - } - } - for (MIMOChannels::const_iterator it = m_mimoChannels.begin(); it != m_mimoChannels.end(); ++it) { qDebug() << "DSPDeviceMIMOEngine::gotoRunning: starting MIMOChannel sinks: " << (*it)->objectName().toStdString().c_str(); @@ -893,7 +834,6 @@ void DSPDeviceMIMOEngine::handleSetMIMO(DeviceSampleMIMO* mimo) for (int i = 0; i < m_deviceSampleMIMO->getNbSinkFifos(); i++) { m_basebandSampleSinks.push_back(BasebandSampleSinks()); - m_threadedBasebandSampleSinks.push_back(ThreadedBasebandSampleSinks()); m_sourcesCorrections.push_back(SourceCorrection()); } @@ -1060,38 +1000,6 @@ void DSPDeviceMIMOEngine::handleSynchronousMessages() m_basebandSampleSinks[isource].remove(sink); } } - else if (AddThreadedBasebandSampleSink::match(*message)) - { - const AddThreadedBasebandSampleSink *msg = (AddThreadedBasebandSampleSink *) message; - ThreadedBasebandSampleSink *threadedSink = msg->getThreadedSampleSink(); - unsigned int isource = msg->getIndex(); - - if (isource < m_threadedBasebandSampleSinks.size()) - { - m_threadedBasebandSampleSinks[isource].push_back(threadedSink); - // initialize sample rate and center frequency in the sink: - int sourceStreamSampleRate = m_deviceSampleMIMO->getSourceSampleRate(isource); - quint64 sourceCenterFrequency = m_deviceSampleMIMO->getSourceCenterFrequency(isource); - DSPSignalNotification msg(sourceStreamSampleRate, sourceCenterFrequency); - threadedSink->handleSinkMessage(msg); - // start the sink: - if (m_stateRx == StRunning) { - threadedSink->start(); - } - } - } - else if (RemoveThreadedBasebandSampleSink::match(*message)) - { - const RemoveThreadedBasebandSampleSink *msg = (RemoveThreadedBasebandSampleSink *) message; - ThreadedBasebandSampleSink* threadedSink = msg->getThreadedSampleSink(); - unsigned int isource = msg->getIndex(); - - if (isource < m_threadedBasebandSampleSinks.size()) - { - threadedSink->stop(); - m_threadedBasebandSampleSinks[isource].remove(threadedSink); - } - } else if (AddBasebandSampleSource::match(*message)) { const AddBasebandSampleSource *msg = (AddBasebandSampleSource *) message; @@ -1313,16 +1221,6 @@ void DSPDeviceMIMOEngine::handleInputMessages() } } - // forward source changes to channel sinks with immediate execution (no queuing) - if (istream < m_threadedBasebandSampleSinks.size()) - { - for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks[istream].begin(); it != m_threadedBasebandSampleSinks[istream].end(); ++it) - { - qDebug() << "DSPDeviceMIMOEngine::handleSourceMessages: forward message to ThreadedSampleSink(" << (*it)->getSampleSinkObjectName().toStdString().c_str() << ")"; - (*it)->handleSinkMessage(*message); - } - } - // forward changes to MIMO GUI input queue MessageQueue *guiMessageQueue = m_deviceSampleMIMO->getMessageQueueToGUI(); qDebug("DeviceMIMOEngine::handleInputMessages: DSPMIMOSignalNotification: guiMessageQueue: %p", guiMessageQueue); diff --git a/sdrbase/dsp/dspdevicemimoengine.h b/sdrbase/dsp/dspdevicemimoengine.h index 760d99aa0..32e795779 100644 --- a/sdrbase/dsp/dspdevicemimoengine.h +++ b/sdrbase/dsp/dspdevicemimoengine.h @@ -30,7 +30,6 @@ #include "export.h" class DeviceSampleMIMO; -class ThreadedBasebandSampleSink; class BasebandSampleSink; class MIMOChannel; @@ -78,36 +77,6 @@ public: unsigned int m_index; }; - class AddThreadedBasebandSampleSink : public Message { - MESSAGE_CLASS_DECLARATION - public: - AddThreadedBasebandSampleSink(ThreadedBasebandSampleSink* threadedSampleSink, unsigned int index) : - Message(), - m_threadedSampleSink(threadedSampleSink), - m_index(index) - { } - ThreadedBasebandSampleSink* getThreadedSampleSink() const { return m_threadedSampleSink; } - unsigned int getIndex() const { return m_index; } - private: - ThreadedBasebandSampleSink* m_threadedSampleSink; - unsigned int m_index; - }; - - class RemoveThreadedBasebandSampleSink : public Message { - MESSAGE_CLASS_DECLARATION - public: - RemoveThreadedBasebandSampleSink(ThreadedBasebandSampleSink* threadedSampleSink, unsigned int index) : - Message(), - m_threadedSampleSink(threadedSampleSink), - m_index(index) - { } - ThreadedBasebandSampleSink* getThreadedSampleSink() const { return m_threadedSampleSink; } - unsigned int getIndex() const { return m_index; } - private: - ThreadedBasebandSampleSink* m_threadedSampleSink; - unsigned int m_index; - }; - class AddMIMOChannel : public Message { MESSAGE_CLASS_DECLARATION public: @@ -264,8 +233,6 @@ public: void removeChannelSource(BasebandSampleSource* source, int index = 0); //!< Remove a channel source void addChannelSink(BasebandSampleSink* sink, int index = 0); //!< Add a channel sink void removeChannelSink(BasebandSampleSink* sink, int index = 0); //!< Remove a channel sink - void addChannelSink(ThreadedBasebandSampleSink* sink, int index = 0); //!< Add a channel sink that will run on its own thread - void removeChannelSink(ThreadedBasebandSampleSink* sink, int index = 0); //!< Remove a channel sink that runs on its own thread void addMIMOChannel(MIMOChannel *channel); //!< Add a MIMO channel void removeMIMOChannel(MIMOChannel *channel); //!< Remove a MIMO channel @@ -359,9 +326,6 @@ private: typedef std::list BasebandSampleSinks; std::vector m_basebandSampleSinks; //!< ancillary sample sinks on main thread (per input stream) - typedef std::list ThreadedBasebandSampleSinks; - std::vector m_threadedBasebandSampleSinks; //!< channel sample sinks on their own thread (per input stream) - typedef std::list BasebandSampleSources; std::vector m_basebandSampleSources; //!< channel sample sources (per output stream) std::vector> m_sourceSampleBuffers; diff --git a/sdrbase/dsp/dspdevicesourceengine.cpp b/sdrbase/dsp/dspdevicesourceengine.cpp index bfe69202a..2c252f162 100644 --- a/sdrbase/dsp/dspdevicesourceengine.cpp +++ b/sdrbase/dsp/dspdevicesourceengine.cpp @@ -26,7 +26,6 @@ #include "dsp/dspcommands.h" #include "util/fixed.h" #include "samplesinkfifo.h" -#include "threadedbasebandsamplesink.h" DSPDeviceSourceEngine::DSPDeviceSourceEngine(uint uid, QObject* parent) : QThread(parent), @@ -136,20 +135,6 @@ void DSPDeviceSourceEngine::removeSink(BasebandSampleSink* sink) m_syncMessenger.sendWait(cmd); } -void DSPDeviceSourceEngine::addThreadedSink(ThreadedBasebandSampleSink* sink) -{ - qDebug() << "DSPDeviceSourceEngine::addThreadedSink: " << sink->objectName().toStdString().c_str(); - DSPAddThreadedBasebandSampleSink cmd(sink); - m_syncMessenger.sendWait(cmd); -} - -void DSPDeviceSourceEngine::removeThreadedSink(ThreadedBasebandSampleSink* sink) -{ - qDebug() << "DSPDeviceSourceEngine::removeThreadedSink: " << sink->objectName().toStdString().c_str(); - DSPRemoveThreadedBasebandSampleSink cmd(sink); - m_syncMessenger.sendWait(cmd); -} - void DSPDeviceSourceEngine::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection) { qDebug() << "DSPDeviceSourceEngine::configureCorrections"; @@ -347,27 +332,12 @@ void DSPDeviceSourceEngine::work() iqCorrections(part1begin, part1end, m_iqImbalanceCorrection); } -// if (m_dcOffsetCorrection) -// { -// dcOffset(part1begin, part1end); -// } -// -// if (m_iqImbalanceCorrection) -// { -// imbalance(part1begin, part1end); -// } - // feed data to direct sinks for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); ++it) { (*it)->feed(part1begin, part1end, positiveOnly); } - // feed data to threaded sinks - for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks.begin(); it != m_threadedBasebandSampleSinks.end(); ++it) - { - (*it)->feed(part1begin, part1end, positiveOnly); - } } // second part of FIFO data (used when block wraps around) @@ -379,27 +349,12 @@ void DSPDeviceSourceEngine::work() iqCorrections(part2begin, part2end, m_iqImbalanceCorrection); } -// if (m_dcOffsetCorrection) -// { -// dcOffset(part2begin, part2end); -// } -// -// if (m_iqImbalanceCorrection) -// { -// imbalance(part2begin, part2end); -// } - // feed data to direct sinks for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); it++) { (*it)->feed(part2begin, part2end, positiveOnly); } - // feed data to threaded sinks - for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks.begin(); it != m_threadedBasebandSampleSinks.end(); ++it) - { - (*it)->feed(part2begin, part2end, positiveOnly); - } } // adjust FIFO pointers @@ -442,11 +397,6 @@ DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoIdle() (*it)->stop(); } - for(ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks.begin(); it != m_threadedBasebandSampleSinks.end(); it++) - { - (*it)->stop(); - } - m_deviceDescription.clear(); m_sampleRate = 0; @@ -499,12 +449,6 @@ DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoInit() (*it)->handleMessage(notif); } - for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks.begin(); it != m_threadedBasebandSampleSinks.end(); ++it) - { - qDebug() << "DSPDeviceSourceEngine::gotoInit: initializing ThreadedSampleSink(" << (*it)->getSampleSinkObjectName().toStdString().c_str() << ")"; - (*it)->handleSinkMessage(notif); - } - // pass data to listeners if (m_deviceSampleSource->getMessageQueueToGUI()) { @@ -554,12 +498,6 @@ DSPDeviceSourceEngine::State DSPDeviceSourceEngine::gotoRunning() (*it)->start(); } - for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks.begin(); it != m_threadedBasebandSampleSinks.end(); ++it) - { - qDebug() << "DSPDeviceSourceEngine::gotoRunning: starting ThreadedSampleSink(" << (*it)->getSampleSinkObjectName().toStdString().c_str() << ")"; - (*it)->start(); - } - qDebug() << "DSPDeviceSourceEngine::gotoRunning:input message queue pending: " << m_inputMessageQueue.size(); return StRunning; @@ -661,24 +599,6 @@ void DSPDeviceSourceEngine::handleSynchronousMessages() m_basebandSampleSinks.remove(sink); } - else if (DSPAddThreadedBasebandSampleSink::match(*message)) - { - ThreadedBasebandSampleSink *threadedSink = ((DSPAddThreadedBasebandSampleSink*) message)->getThreadedSampleSink(); - m_threadedBasebandSampleSinks.push_back(threadedSink); - // initialize sample rate and center frequency in the sink: - DSPSignalNotification msg(m_sampleRate, m_centerFrequency); - threadedSink->handleSinkMessage(msg); - // start the sink: - if(m_state == StRunning) { - threadedSink->start(); - } - } - else if (DSPRemoveThreadedBasebandSampleSink::match(*message)) - { - ThreadedBasebandSampleSink* threadedSink = ((DSPRemoveThreadedBasebandSampleSink*) message)->getThreadedSampleSink(); - threadedSink->stop(); - m_threadedBasebandSampleSinks.remove(threadedSink); - } m_syncMessenger.done(m_state); } @@ -743,12 +663,6 @@ void DSPDeviceSourceEngine::handleInputMessages() (*it)->handleMessage(*message); } - for (ThreadedBasebandSampleSinks::const_iterator it = m_threadedBasebandSampleSinks.begin(); it != m_threadedBasebandSampleSinks.end(); ++it) - { - qDebug() << "DSPDeviceSourceEngine::handleSourceMessages: forward message to ThreadedSampleSink(" << (*it)->getSampleSinkObjectName().toStdString().c_str() << ")"; - (*it)->handleSinkMessage(*message); - } - // forward changes to source GUI input queue MessageQueue *guiMessageQueue = m_deviceSampleSource->getMessageQueueToGUI(); diff --git a/sdrbase/dsp/dspdevicesourceengine.h b/sdrbase/dsp/dspdevicesourceengine.h index a6fe57879..83a92c582 100644 --- a/sdrbase/dsp/dspdevicesourceengine.h +++ b/sdrbase/dsp/dspdevicesourceengine.h @@ -32,7 +32,6 @@ class DeviceSampleSource; class BasebandSampleSink; -class ThreadedBasebandSampleSink; class SDRBASE_API DSPDeviceSourceEngine : public QThread { Q_OBJECT @@ -67,9 +66,6 @@ public: void addSink(BasebandSampleSink* sink); //!< Add a sample sink void removeSink(BasebandSampleSink* sink); //!< Remove a sample sink - void addThreadedSink(ThreadedBasebandSampleSink* sink); //!< Add a sample sink that will run on its own thread - void removeThreadedSink(ThreadedBasebandSampleSink* sink); //!< Remove a sample sink that runs on its own thread - void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure DSP corrections State state() const { return m_state; } //!< Return DSP engine current state @@ -94,9 +90,6 @@ private: typedef std::list BasebandSampleSinks; BasebandSampleSinks m_basebandSampleSinks; //!< sample sinks within main thread (usually spectrum, file output) - typedef std::list ThreadedBasebandSampleSinks; - ThreadedBasebandSampleSinks m_threadedBasebandSampleSinks; //!< sample sinks on their own threads (usually channels) - uint m_sampleRate; quint64 m_centerFrequency; diff --git a/sdrbase/dsp/threadedbasebandsamplesink.cpp b/sdrbase/dsp/threadedbasebandsamplesink.cpp deleted file mode 100644 index cce47ec6a..000000000 --- a/sdrbase/dsp/threadedbasebandsamplesink.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "threadedbasebandsamplesink.h" - -#include -#include -#include "dsp/dspcommands.h" -#include "util/message.h" - -ThreadedBasebandSampleSinkFifo::ThreadedBasebandSampleSinkFifo(BasebandSampleSink *sampleSink, std::size_t size) : - m_sampleSink(sampleSink) -{ - connect(&m_sampleFifo, SIGNAL(dataReady()), this, SLOT(handleFifoData())); - m_sampleFifo.setSize(size); -} - -ThreadedBasebandSampleSinkFifo::~ThreadedBasebandSampleSinkFifo() -{ - m_sampleFifo.readCommit(m_sampleFifo.fill()); -} - -void ThreadedBasebandSampleSinkFifo::writeToFifo(SampleVector::const_iterator& begin, SampleVector::const_iterator& end) -{ - m_sampleFifo.write(begin, end); -} - -void ThreadedBasebandSampleSinkFifo::handleFifoData() // FIXME: Fixed? Move it to the new threadable sink class -{ - bool positiveOnly = false; - - while ((m_sampleFifo.fill() > 0) && (m_sampleSink->getInputMessageQueue()->size() == 0)) - { - SampleVector::iterator part1begin; - SampleVector::iterator part1end; - SampleVector::iterator part2begin; - SampleVector::iterator part2end; - - std::size_t count = m_sampleFifo.readBegin(m_sampleFifo.fill(), &part1begin, &part1end, &part2begin, &part2end); - - // first part of FIFO data - - if (count > 0) - { - // handle data - if(m_sampleSink != NULL) - { - m_sampleSink->feed(part1begin, part1end, positiveOnly); - } - - m_sampleFifo.readCommit(part1end - part1begin); - } - - // second part of FIFO data (used when block wraps around) - - if(part2begin != part2end) - { - // handle data - if(m_sampleSink != NULL) - { - m_sampleSink->feed(part2begin, part2end, positiveOnly); - } - - m_sampleFifo.readCommit(part2end - part2begin); - } - } -} - -ThreadedBasebandSampleSink::ThreadedBasebandSampleSink(BasebandSampleSink* sampleSink, QObject *parent) : - m_basebandSampleSink(sampleSink) -{ - QString name = "ThreadedBasebandSampleSink(" + m_basebandSampleSink->objectName() + ")"; - setObjectName(name); - - qDebug() << "ThreadedBasebandSampleSink::ThreadedBasebandSampleSink: " << name; - - m_thread = new QThread(parent); - m_threadedBasebandSampleSinkFifo = new ThreadedBasebandSampleSinkFifo(m_basebandSampleSink); - //moveToThread(m_thread); // FIXME: Fixed? the intermediate FIFO should be handled within the sink. Define a new type of sink that is compatible with threading - m_basebandSampleSink->moveToThread(m_thread); - m_threadedBasebandSampleSinkFifo->moveToThread(m_thread); - BasebandSampleSink::MsgThreadedSink *msg = BasebandSampleSink::MsgThreadedSink::create(m_thread); // inform of the new thread - m_basebandSampleSink->handleMessage(*msg); - delete msg; - //m_sampleFifo.moveToThread(m_thread); - //connect(&m_sampleFifo, SIGNAL(dataReady()), this, SLOT(handleData())); - //m_sampleFifo.setSize(262144); - - qDebug() << "ThreadedBasebandSampleSink::ThreadedBasebandSampleSink: thread: " << thread() << " m_thread: " << m_thread; -} - -ThreadedBasebandSampleSink::~ThreadedBasebandSampleSink() -{ - if (m_thread->isRunning()) { - stop(); - } - - delete m_threadedBasebandSampleSinkFifo; // Valgrind memcheck - delete m_thread; -} - -void ThreadedBasebandSampleSink::start() -{ - qDebug() << "ThreadedBasebandSampleSink::start"; - m_thread->start(); - m_basebandSampleSink->start(); -} - -void ThreadedBasebandSampleSink::stop() -{ - qDebug() << "ThreadedBasebandSampleSink::stop"; - m_basebandSampleSink->stop(); - m_thread->exit(); - m_thread->wait(); -} - -void ThreadedBasebandSampleSink::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) -{ - (void) positiveOnly; - //m_sampleSink->feed(begin, end, positiveOnly); - //m_sampleFifo.write(begin, end); - m_threadedBasebandSampleSinkFifo->writeToFifo(begin, end); -} - -bool ThreadedBasebandSampleSink::handleSinkMessage(const Message& cmd) -{ - return m_basebandSampleSink->handleMessage(cmd); -} - -QString ThreadedBasebandSampleSink::getSampleSinkObjectName() const -{ - return m_basebandSampleSink->objectName(); -} diff --git a/sdrbase/dsp/threadedbasebandsamplesink.h b/sdrbase/dsp/threadedbasebandsamplesink.h deleted file mode 100644 index d398a0da0..000000000 --- a/sdrbase/dsp/threadedbasebandsamplesink.h +++ /dev/null @@ -1,79 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2015 F4EXB // -// written by Edouard Griffiths // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation as version 3 of the License, or // -// (at your option) any later version. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License V3 for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program. If not, see . // -/////////////////////////////////////////////////////////////////////////////////// - -#ifndef INCLUDE_THREADEDSAMPLESINK_H -#define INCLUDE_THREADEDSAMPLESINK_H - -#include -#include - -#include "samplesinkfifo.h" -#include "util/messagequeue.h" -#include "export.h" - -class BasebandSampleSink; -class QThread; - -/** - * Because Qt is a piece of shit this class cannot be a nested protected class of ThreadedSampleSink - * So let's make everything public - */ -class SDRBASE_API ThreadedBasebandSampleSinkFifo : public QObject { - Q_OBJECT - -public: - ThreadedBasebandSampleSinkFifo(BasebandSampleSink* sampleSink, std::size_t size = 1<<18); - ~ThreadedBasebandSampleSinkFifo(); - void writeToFifo(SampleVector::const_iterator& begin, SampleVector::const_iterator& end); - - BasebandSampleSink* m_sampleSink; - SampleSinkFifo m_sampleFifo; - -public slots: - void handleFifoData(); -}; - -/** - * This class is a wrapper for SampleSink that runs the SampleSink object in its own thread - */ -class SDRBASE_API ThreadedBasebandSampleSink : public QObject { - Q_OBJECT - -public: - ThreadedBasebandSampleSink(BasebandSampleSink* sampleSink, QObject *parent = 0); - ~ThreadedBasebandSampleSink(); - - const BasebandSampleSink *getSink() const { return m_basebandSampleSink; } - - void start(); //!< this thread start() - void stop(); //!< this thread exit() and wait() - - bool handleSinkMessage(const Message& cmd); //!< Send message to sink synchronously - void feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly); //!< Feed sink with samples - - QString getSampleSinkObjectName() const; - const QThread *getThread() const { return m_thread; } - -protected: - - QThread *m_thread; //!< The thead object - ThreadedBasebandSampleSinkFifo *m_threadedBasebandSampleSinkFifo; - BasebandSampleSink* m_basebandSampleSink; -}; - -#endif // INCLUDE_THREADEDSAMPLESINK_H