1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-14 04:11:48 -05:00

Multi device support: access DSPDeviceEngine from the channel plugins using the plubgin API and not a direct access

This commit is contained in:
f4exb 2016-05-11 18:29:01 +02:00
parent 33e5e781c0
commit 66daf9fa4e
14 changed files with 95 additions and 65 deletions

View File

@ -324,7 +324,7 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_channelizer = new Channelizer(m_channelAnalyzer);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_pluginAPI->addThreadedSink(m_threadedChannelizer);
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->deltaFrequency->setValueRange(7, 0U, 9999999U);
@ -358,7 +358,7 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, QWidget* parent) :
ChannelAnalyzerGUI::~ChannelAnalyzerGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
m_pluginAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_channelAnalyzer;

View File

@ -218,7 +218,8 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_amDemod = new AMDemod();
m_channelizer = new Channelizer(m_amDemod);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_pluginAPI->addThreadedSink(m_threadedChannelizer);
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
@ -237,7 +238,7 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
AMDemodGUI::~AMDemodGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
m_pluginAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_amDemod;

View File

@ -379,7 +379,7 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_channelizer = new Channelizer(m_bfmDemod);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
connect(m_channelizer, SIGNAL(inputSampleRateChanged()), this, SLOT(channelSampleRateChanged()));
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_pluginAPI->addThreadedSink(m_threadedChannelizer);
ui->glSpectrum->setCenterFrequency(m_rate / 4);
ui->glSpectrum->setSampleRate(m_rate / 2);
@ -413,7 +413,7 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
BFMDemodGUI::~BFMDemodGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
m_pluginAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_bfmDemod;

View File

@ -276,7 +276,7 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_channelizer = new Channelizer(m_dsdDemod);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_pluginAPI->addThreadedSink(m_threadedChannelizer);
//m_channelMarker = new ChannelMarker(this);
m_channelMarker.setColor(Qt::cyan);
@ -296,7 +296,7 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
DSDDemodGUI::~DSDDemodGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
m_pluginAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_dsdDemod;

View File

@ -163,7 +163,7 @@ LoRaDemodGUI::LoRaDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_LoRaDemod = new LoRaDemod(m_spectrumVis);
m_channelizer = new Channelizer(m_LoRaDemod);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_pluginAPI->addThreadedSink(m_threadedChannelizer);
ui->glSpectrum->setCenterFrequency(16000);
ui->glSpectrum->setSampleRate(32000);
@ -188,7 +188,7 @@ LoRaDemodGUI::LoRaDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
LoRaDemodGUI::~LoRaDemodGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
m_pluginAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_LoRaDemod;

View File

@ -289,7 +289,7 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_channelizer = new Channelizer(m_nfmDemod);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_pluginAPI->addThreadedSink(m_threadedChannelizer);
//m_channelMarker = new ChannelMarker(this);
m_channelMarker.setColor(Qt::red);
@ -307,7 +307,7 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
NFMDemodGUI::~NFMDemodGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
m_pluginAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_nfmDemod;

View File

@ -338,7 +338,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_ssbDemod = new SSBDemod(m_spectrumVis);
m_channelizer = new Channelizer(m_ssbDemod);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_pluginAPI->addThreadedSink(m_threadedChannelizer);
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
@ -369,7 +369,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
SSBDemodGUI::~SSBDemodGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
m_pluginAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_ssbDemod;

View File

@ -232,7 +232,7 @@ WFMDemodGUI::WFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_wfmDemod = new WFMDemod(0);
m_channelizer = new Channelizer(m_wfmDemod);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_pluginAPI->addThreadedSink(m_threadedChannelizer);
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
@ -250,7 +250,7 @@ WFMDemodGUI::WFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
WFMDemodGUI::~WFMDemodGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
m_pluginAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_wfmDemod;

View File

@ -199,7 +199,7 @@ TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_tcpSrc = new TCPSrc(m_pluginAPI->getMainWindowMessageQueue(), this, m_spectrumVis);
m_channelizer = new Channelizer(m_tcpSrc);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_pluginAPI->addThreadedSink(m_threadedChannelizer);
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->deltaFrequency->setValueRange(7, 0U, 9999999U);
@ -229,7 +229,7 @@ TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
TCPSrcGUI::~TCPSrcGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
m_pluginAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_tcpSrc;

View File

@ -237,7 +237,7 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_udpSrc = new UDPSrc(m_pluginAPI->getMainWindowMessageQueue(), this, m_spectrumVis);
m_channelizer = new Channelizer(m_udpSrc);
m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
m_pluginAPI->addThreadedSink(m_threadedChannelizer);
ui->fmDeviation->setEnabled(false);
@ -270,7 +270,7 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
UDPSrcGUI::~UDPSrcGUI()
{
m_pluginAPI->removeChannelInstance(this);
DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
m_pluginAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_udpSrc;

View File

@ -59,6 +59,16 @@ void PluginAPI::registerSampleSource(const QString& sourceName, PluginInterface*
m_pluginManager->registerSampleSource(sourceName, plugin);
}
void PluginAPI::addThreadedSink(ThreadedSampleSink* sink)
{
m_pluginManager->addThreadedSink(sink);
}
void PluginAPI::removeThreadedSink(ThreadedSampleSink* sink)
{
m_pluginManager->removeThreadedSink(sink);
}
PluginAPI::PluginAPI(PluginManager* pluginManager, MainWindow* mainWindow) :
QObject(mainWindow),
m_pluginManager(pluginManager),

View File

@ -16,6 +16,7 @@ class AudioFifo;
class MessageQueue;
class MainWindow;
class ChannelMarker;
class ThreadedSampleSink;
class PluginGUI;
class SDRANGEL_API PluginAPI : public QObject {
@ -39,6 +40,10 @@ public:
// Sample Source stuff
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
// Device engine stuff
void addThreadedSink(ThreadedSampleSink* sink);
void removeThreadedSink(ThreadedSampleSink* sink);
// R/O access to main window
const MainWindow* getMainWindow() const { return m_mainWindow; }

View File

@ -86,6 +86,16 @@ void PluginManager::registerSampleSource(const QString& sourceName, PluginInterf
m_sampleSourceRegistrations.append(SampleSourceRegistration(sourceName, plugin));
}
void PluginManager::addThreadedSink(ThreadedSampleSink* sink)
{
m_dspDeviceEngine->addThreadedSink(sink);
}
void PluginManager::removeThreadedSink(ThreadedSampleSink* sink)
{
m_dspDeviceEngine->removeThreadedSink(sink);
}
void PluginManager::loadSettings(const Preset* preset)
{
fprintf(stderr, "PluginManager::loadSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));

View File

@ -15,6 +15,7 @@ class MainWindow;
class SampleSource;
class Message;
class DSPDeviceEngine;
class ThreadedSampleSink;
class SDRANGEL_API PluginManager : public QObject {
Q_OBJECT
@ -48,6 +49,9 @@ public:
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
void addThreadedSink(ThreadedSampleSink* sink);
void removeThreadedSink(ThreadedSampleSink* sink);
void loadSettings(const Preset* preset);
void loadSourceSettings(const Preset* preset);
void saveSettings(Preset* preset);