1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-13 03:41:47 -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

@ -69,11 +69,11 @@ void ChannelAnalyzerGUI::setCenterFrequency(qint64 centerFrequency)
void ChannelAnalyzerGUI::resetToDefaults()
{
blockApplySettings(true);
ui->BW->setValue(30);
ui->deltaFrequency->setValue(0);
ui->spanLog2->setValue(3);
blockApplySettings(false);
applySettings();
}
@ -96,22 +96,22 @@ bool ChannelAnalyzerGUI::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid())
if(!d.isValid())
{
resetToDefaults();
return false;
}
if(d.getVersion() == 1)
if(d.getVersion() == 1)
{
QByteArray bytetmp;
quint32 u32tmp;
qint32 tmp, bw, lowCut;
bool tmpBool;
blockApplySettings(true);
m_channelMarker.blockSignals(true);
d.readS32(1, &tmp, 0);
m_channelMarker.setCenterFrequency(tmp);
d.readS32(2, &bw, 30);
@ -133,16 +133,16 @@ bool ChannelAnalyzerGUI::deserialize(const QByteArray& data)
ui->ssb->setChecked(tmpBool);
d.readBlob(8, &bytetmp);
ui->scopeGUI->deserialize(bytetmp);
blockApplySettings(false);
m_channelMarker.blockSignals(false);
ui->BW->setValue(bw);
ui->lowCut->setValue(lowCut); // does applySettings();
return true;
}
else
}
else
{
resetToDefaults();
return false;
@ -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;
@ -380,7 +380,7 @@ bool ChannelAnalyzerGUI::setNewRate(int spanLog2)
m_spanLog2 = spanLog2;
//m_rate = 48000 / (1<<spanLog2);
m_rate = m_channelAnalyzer->getSampleRate() / (1<<spanLog2);
if (ui->BW->value() < -m_rate/200) {
ui->BW->setValue(-m_rate/200);
m_channelMarker.setBandwidth(-m_rate*2);

View File

@ -52,7 +52,7 @@ void AMDemodGUI::setCenterFrequency(qint64 centerFrequency)
void AMDemodGUI::resetToDefaults()
{
blockApplySettings(true);
ui->rfBW->setValue(4);
ui->afBW->setValue(3);
ui->volume->setValue(20);
@ -79,21 +79,21 @@ bool AMDemodGUI::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid())
if(!d.isValid())
{
resetToDefaults();
return false;
}
if(d.getVersion() == 1)
if(d.getVersion() == 1)
{
QByteArray bytetmp;
quint32 u32tmp;
qint32 tmp;
blockApplySettings(true);
m_channelMarker.blockSignals(true);
d.readS32(1, &tmp, 0);
m_channelMarker.setCenterFrequency(tmp);
d.readS32(2, &tmp, 4);
@ -104,19 +104,19 @@ bool AMDemodGUI::deserialize(const QByteArray& data)
ui->volume->setValue(tmp);
d.readS32(5, &tmp, -40);
ui->squelch->setValue(tmp);
if(d.readU32(7, &u32tmp))
{
m_channelMarker.setColor(u32tmp);
}
blockApplySettings(false);
m_channelMarker.blockSignals(false);
applySettings();
return true;
}
else
}
else
{
resetToDefaults();
return false;
@ -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

@ -48,10 +48,10 @@ void LoRaDemodGUI::setCenterFrequency(qint64 centerFrequency)
void LoRaDemodGUI::resetToDefaults()
{
blockApplySettings(true);
ui->BW->setValue(0);
ui->Spread->setValue(0);
blockApplySettings(false);
applySettings();
}
@ -70,20 +70,20 @@ bool LoRaDemodGUI::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid())
if(!d.isValid())
{
resetToDefaults();
return false;
}
if(d.getVersion() == 1)
if(d.getVersion() == 1)
{
QByteArray bytetmp;
qint32 tmp;
blockApplySettings(true);
m_channelMarker.blockSignals(true);
d.readS32(1, &tmp, 0);
m_channelMarker.setCenterFrequency(tmp);
d.readS32(2, &tmp, 0);
@ -92,14 +92,14 @@ bool LoRaDemodGUI::deserialize(const QByteArray& data)
ui->Spread->setValue(tmp);
d.readBlob(4, &bytetmp);
ui->spectrumGUI->deserialize(bytetmp);
blockApplySettings(false);
m_channelMarker.blockSignals(false);
applySettings();
return true;
}
else
}
else
{
resetToDefaults();
return false;
@ -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

@ -51,7 +51,7 @@ void SSBDemodGUI::setCenterFrequency(qint64 centerFrequency)
void SSBDemodGUI::resetToDefaults()
{
blockApplySettings(true);
ui->BW->setValue(30);
ui->volume->setValue(40);
ui->deltaFrequency->setValue(0);
@ -92,10 +92,10 @@ bool SSBDemodGUI::deserialize(const QByteArray& data)
QByteArray bytetmp;
quint32 u32tmp;
qint32 tmp;
blockApplySettings(true);
m_channelMarker.blockSignals(true);
d.readS32(1, &tmp, 0);
m_channelMarker.setCenterFrequency(tmp);
d.readS32(2, &tmp, 30);
@ -117,10 +117,10 @@ bool SSBDemodGUI::deserialize(const QByteArray& data)
ui->audioFlipChannels->setChecked(m_audioFlipChannels);
d.readBool(10, &m_dsb);
ui->dsb->setChecked(m_dsb);
blockApplySettings(false);
m_channelMarker.blockSignals(false);
applySettings();
return true;
}
@ -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

@ -46,7 +46,7 @@ QString TCPSrcGUI::getName() const
void TCPSrcGUI::resetToDefaults()
{
blockApplySettings(true);
ui->sampleFormat->setCurrentIndex(0);
ui->sampleRate->setText("48000");
ui->rfBandwidth->setText("32000");
@ -88,10 +88,10 @@ bool TCPSrcGUI::deserialize(const QByteArray& data)
QByteArray bytetmp;
qint32 s32tmp;
Real realtmp;
blockApplySettings(true);
m_channelMarker.blockSignals(true);
d.readBlob(1, &bytetmp);
restoreState(bytetmp);
d.readS32(2, &s32tmp, 0);
@ -123,10 +123,10 @@ bool TCPSrcGUI::deserialize(const QByteArray& data)
ui->boost->setValue(s32tmp);
d.readS32(9, &s32tmp, 0);
m_channelMarker.setCenterFrequency(s32tmp);
blockApplySettings(false);
m_channelMarker.blockSignals(false);
applySettings();
return true;
}
@ -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

@ -64,7 +64,7 @@ QString UDPSrcGUI::getName() const
void UDPSrcGUI::resetToDefaults()
{
blockApplySettings(true);
ui->sampleFormat->setCurrentIndex(0);
ui->sampleRate->setText("48000");
ui->rfBandwidth->setText("32000");
@ -121,10 +121,10 @@ bool UDPSrcGUI::deserialize(const QByteArray& data)
qint32 s32tmp;
Real realtmp;
bool booltmp;
blockApplySettings(true);
m_channelMarker.blockSignals(true);
d.readBlob(1, &bytetmp);
restoreState(bytetmp);
d.readS32(2, &s32tmp, 0);
@ -183,10 +183,10 @@ bool UDPSrcGUI::deserialize(const QByteArray& data)
ui->audioStereo->setChecked(booltmp);
d.readS32(15, &s32tmp, 2500);
ui->fmDeviation->setText(QString("%1").arg(s32tmp));
blockApplySettings(false);
m_channelMarker.blockSignals(false);
applySettingsImmediate();
applySettings();
return true;
@ -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);