mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-18 07:35:47 -05:00
Multi device support: code cleanup and fixed lock on exit
This commit is contained in:
parent
3f2b3cdea3
commit
86b04a4d62
@ -196,18 +196,19 @@ void DeviceAPI::freeAll()
|
|||||||
|
|
||||||
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
|
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
|
||||||
{
|
{
|
||||||
qDebug("PluginManager::loadSettings: destroying channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelName));
|
qDebug("DeviceAPI::freeAll: destroying channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelName));
|
||||||
m_channelInstanceRegistrations[i].m_gui->destroy();
|
m_channelInstanceRegistrations[i].m_gui->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if(m_sampleSourcePluginGUI != 0)
|
if(m_sampleSourcePluginGUI != 0)
|
||||||
// {
|
{
|
||||||
// m_deviceEngine->setSource(0);
|
qDebug("DeviceAPI::freeAll: destroying m_sampleSourcePluginGUI");
|
||||||
// m_sampleSourcePluginGUI->destroy();
|
m_deviceEngine->setSource(0);
|
||||||
// m_sampleSourcePluginGUI = 0;
|
m_sampleSourcePluginGUI->destroy();
|
||||||
// m_sampleSourceId.clear();
|
m_sampleSourcePluginGUI = 0;
|
||||||
// }
|
m_sampleSourceId.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceAPI::loadSourceSettings(const Preset* preset)
|
void DeviceAPI::loadSourceSettings(const Preset* preset)
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
SamplingDeviceControl::SamplingDeviceControl(QWidget* parent) :
|
SamplingDeviceControl::SamplingDeviceControl(QWidget* parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::SamplingDeviceControl),
|
ui(new Ui::SamplingDeviceControl),
|
||||||
m_pluginManager(0)
|
m_pluginManager(0),
|
||||||
|
m_deviceAPI(0)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,9 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||||||
"QTabWidget::pane { border: 1px solid #C06900; } "
|
"QTabWidget::pane { border: 1px solid #C06900; } "
|
||||||
"QTabBar::tab:selected { background: rgb(128,70,0); }");
|
"QTabBar::tab:selected { background: rgb(128,70,0); }");
|
||||||
|
|
||||||
|
m_pluginManager = new PluginManager(this);
|
||||||
|
m_pluginManager->loadPlugins();
|
||||||
|
|
||||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||||
@ -116,43 +119,28 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||||||
|
|
||||||
m_masterTimer.start(50);
|
m_masterTimer.start(50);
|
||||||
|
|
||||||
qDebug() << "MainWindow::MainWindow: m_pluginManager->loadPlugins ...";
|
qDebug() << "MainWindow::MainWindow: add the first device...";
|
||||||
|
|
||||||
addDevice(); // add the first device
|
addDevice(); // add the first device
|
||||||
|
|
||||||
// DSPDeviceEngine *dspDeviceEngine = m_dspEngine->addDeviceEngine();
|
qDebug() << "MainWindow::MainWindow: load settings...";
|
||||||
// dspDeviceEngine->start();
|
|
||||||
//
|
|
||||||
// m_deviceUIs.push_back(new DeviceUISet(m_masterTimer));
|
|
||||||
//
|
|
||||||
// m_pluginManager = new PluginManager(this, dspDeviceEngine, m_deviceUIs.back()->m_spectrum);
|
|
||||||
// m_pluginManager->loadPlugins();
|
|
||||||
//
|
|
||||||
// ui->tabSpectra->addTab(m_deviceUIs.back()->m_spectrum, "X0");
|
|
||||||
// ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, "X0");
|
|
||||||
// dspDeviceEngine->addSink(m_deviceUIs.back()->m_spectrumVis);
|
|
||||||
// ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, "X0");
|
|
||||||
// bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_sampleSource->blockSignals(true);
|
|
||||||
// m_pluginManager->fillSampleSourceSelector(m_deviceUIs.back()->m_sampleSource);
|
|
||||||
// connect(m_deviceUIs.back()->m_sampleSource, SIGNAL(currentIndexChanged(int)), this, SLOT(on_sampleSource_currentIndexChanged(int)));
|
|
||||||
// m_deviceUIs.back()->m_sampleSource->blockSignals(sampleSourceSignalsBlocked);
|
|
||||||
// ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_sampleSource, "X0");
|
|
||||||
|
|
||||||
qDebug() << "MainWindow::MainWindow: loadSettings...";
|
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
qDebug() << "MainWindow::MainWindow: select SampleSource from settings...";
|
qDebug() << "MainWindow::MainWindow: select SampleSource from settings...";
|
||||||
|
|
||||||
int sampleSourceIndex = m_settings.getSourceIndex();
|
int sampleSourceIndex = m_settings.getSourceIndex();
|
||||||
sampleSourceIndex = m_deviceUIs.back()->m_pluginManager->selectSampleSourceByIndex(sampleSourceIndex, m_deviceUIs.back()->m_deviceAPI);
|
sampleSourceIndex = m_pluginManager->selectSampleSourceByIndex(sampleSourceIndex, m_deviceUIs.back()->m_deviceAPI);
|
||||||
|
|
||||||
if (sampleSourceIndex >= 0)
|
if (sampleSourceIndex < 0)
|
||||||
{
|
{
|
||||||
|
qCritical("MainWindow::MainWindow: no sample source. Exit");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true);
|
bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true);
|
||||||
m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->setCurrentIndex(sampleSourceIndex);
|
m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->setCurrentIndex(sampleSourceIndex);
|
||||||
m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked);
|
m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked);
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "MainWindow::MainWindow: load current preset settings...";
|
qDebug() << "MainWindow::MainWindow: load current preset settings...";
|
||||||
|
|
||||||
@ -166,9 +154,9 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||||||
|
|
||||||
updatePresetControls();
|
updatePresetControls();
|
||||||
|
|
||||||
qDebug() << "MainWindow::MainWindow: end";
|
|
||||||
|
|
||||||
connect(ui->tabInputsView, SIGNAL(currentChanged(int)), this, SLOT(tabInputViewIndexChanged()));
|
connect(ui->tabInputsView, SIGNAL(currentChanged(int)), this, SLOT(tabInputViewIndexChanged()));
|
||||||
|
|
||||||
|
qDebug() << "MainWindow::MainWindow: end";
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -180,6 +168,7 @@ MainWindow::~MainWindow()
|
|||||||
removeLastDevice();
|
removeLastDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete m_pluginManager;
|
||||||
delete m_dateTimeWidget;
|
delete m_dateTimeWidget;
|
||||||
delete m_showSystemWidget;
|
delete m_showSystemWidget;
|
||||||
|
|
||||||
@ -199,16 +188,10 @@ void MainWindow::addDevice()
|
|||||||
m_deviceUIs.back()->m_deviceEngine = dspDeviceEngine;
|
m_deviceUIs.back()->m_deviceEngine = dspDeviceEngine;
|
||||||
|
|
||||||
DeviceAPI *deviceAPI = new DeviceAPI(this, m_deviceUIs.size()-1, dspDeviceEngine, m_deviceUIs.back()->m_spectrum, m_deviceUIs.back()->m_channelWindow);
|
DeviceAPI *deviceAPI = new DeviceAPI(this, m_deviceUIs.size()-1, dspDeviceEngine, m_deviceUIs.back()->m_spectrum, m_deviceUIs.back()->m_channelWindow);
|
||||||
|
|
||||||
m_deviceUIs.back()->m_deviceAPI = deviceAPI;
|
m_deviceUIs.back()->m_deviceAPI = deviceAPI;
|
||||||
|
|
||||||
// TODO: do not create one plugin manager per device. Use device API instead
|
|
||||||
PluginManager *pluginManager = new PluginManager(this, m_deviceUIs.size()-1, dspDeviceEngine);
|
|
||||||
m_deviceUIs.back()->m_pluginManager = pluginManager;
|
|
||||||
|
|
||||||
pluginManager->loadPlugins();
|
|
||||||
|
|
||||||
m_deviceUIs.back()->m_samplingDeviceControl->setDeviceAPI(deviceAPI);
|
m_deviceUIs.back()->m_samplingDeviceControl->setDeviceAPI(deviceAPI);
|
||||||
m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(pluginManager);
|
m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(m_pluginManager);
|
||||||
m_deviceUIs.back()->m_samplingDeviceControl->populateChannelSelector();
|
m_deviceUIs.back()->m_samplingDeviceControl->populateChannelSelector();
|
||||||
|
|
||||||
dspDeviceEngine->addSink(m_deviceUIs.back()->m_spectrumVis);
|
dspDeviceEngine->addSink(m_deviceUIs.back()->m_spectrumVis);
|
||||||
@ -217,7 +200,7 @@ void MainWindow::addDevice()
|
|||||||
ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr);
|
ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr);
|
||||||
|
|
||||||
bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true);
|
bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true);
|
||||||
pluginManager->fillSampleSourceSelector(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector());
|
m_pluginManager->fillSampleSourceSelector(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector());
|
||||||
connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector(), SIGNAL(currentIndexChanged(int)), this, SLOT(on_sampleSource_currentIndexChanged(int)));
|
connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector(), SIGNAL(currentIndexChanged(int)), this, SLOT(on_sampleSource_currentIndexChanged(int)));
|
||||||
m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked);
|
m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked);
|
||||||
ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_samplingDeviceControl, tabNameCStr);
|
ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_samplingDeviceControl, tabNameCStr);
|
||||||
@ -235,21 +218,19 @@ void MainWindow::removeLastDevice()
|
|||||||
// PluginManager destructor does freeAll() which does stopAcquistion() but stopAcquistion()
|
// PluginManager destructor does freeAll() which does stopAcquistion() but stopAcquistion()
|
||||||
// can be done several times only the first is active so it is fine to do it here
|
// can be done several times only the first is active so it is fine to do it here
|
||||||
// On the other hand freeAll() must be executed only once
|
// On the other hand freeAll() must be executed only once
|
||||||
//delete m_deviceUIs.back()->m_pluginManager;
|
|
||||||
//m_deviceUIs.back()->m_pluginManager->freeAll();
|
|
||||||
//delete m_deviceUIs.back()->m_deviceAPI; // TODO: reinstate when plugin manager is not created for each device
|
|
||||||
|
|
||||||
m_deviceUIs.back()->m_deviceAPI->freeAll();
|
m_deviceUIs.back()->m_deviceAPI->freeAll();
|
||||||
|
|
||||||
ui->tabChannels->removeTab(ui->tabChannels->count() - 1);
|
ui->tabChannels->removeTab(ui->tabChannels->count() - 1);
|
||||||
|
|
||||||
lastDeviceEngine->stop();
|
|
||||||
m_dspEngine->removeLastDeviceEngine();
|
|
||||||
|
|
||||||
ui->tabInputsView->removeTab(ui->tabInputsView->count() - 1);
|
ui->tabInputsView->removeTab(ui->tabInputsView->count() - 1);
|
||||||
ui->tabInputsSelect->removeTab(ui->tabInputsSelect->count() - 1);
|
ui->tabInputsSelect->removeTab(ui->tabInputsSelect->count() - 1);
|
||||||
|
|
||||||
delete m_deviceUIs.back();
|
delete m_deviceUIs.back();
|
||||||
|
|
||||||
|
lastDeviceEngine->stop();
|
||||||
|
m_dspEngine->removeLastDeviceEngine();
|
||||||
|
|
||||||
m_deviceUIs.pop_back();
|
m_deviceUIs.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,9 +295,8 @@ void MainWindow::loadPresetSettings(const Preset* preset)
|
|||||||
if (currentSourceTabIndex >= 0)
|
if (currentSourceTabIndex >= 0)
|
||||||
{
|
{
|
||||||
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
||||||
PluginAPI pluginAPI(deviceUI->m_pluginManager, this);
|
|
||||||
deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
|
deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
|
||||||
deviceUI->m_deviceAPI->loadChannelSettings(preset, &pluginAPI);
|
deviceUI->m_deviceAPI->loadChannelSettings(preset, &(m_pluginManager->m_pluginAPI));
|
||||||
deviceUI->m_deviceAPI->loadSourceSettings(preset);
|
deviceUI->m_deviceAPI->loadSourceSettings(preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,11 +408,6 @@ void MainWindow::handleMessages()
|
|||||||
{
|
{
|
||||||
qDebug("MainWindow::handleMessages: message: %s", message->getIdentifier());
|
qDebug("MainWindow::handleMessages: message: %s", message->getIdentifier());
|
||||||
delete message;
|
delete message;
|
||||||
//
|
|
||||||
// if (!m_pluginManager->handleMessage(*message))
|
|
||||||
// {
|
|
||||||
// delete message;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,7 +652,7 @@ void MainWindow::on_sampleSource_currentIndexChanged(int index)
|
|||||||
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
||||||
deviceUI->m_deviceAPI->saveSourceSettings(m_settings.getWorkingPreset());
|
deviceUI->m_deviceAPI->saveSourceSettings(m_settings.getWorkingPreset());
|
||||||
//deviceUI->m_pluginManager->saveSourceSettings(m_settings.getWorkingPreset());
|
//deviceUI->m_pluginManager->saveSourceSettings(m_settings.getWorkingPreset());
|
||||||
deviceUI->m_pluginManager->selectSampleSourceByIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(), deviceUI->m_deviceAPI);
|
m_pluginManager->selectSampleSourceByIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(), deviceUI->m_deviceAPI);
|
||||||
m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex());
|
m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex());
|
||||||
|
|
||||||
//deviceUI->m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset());
|
//deviceUI->m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset());
|
||||||
@ -729,7 +704,8 @@ MainWindow::DeviceUISet::DeviceUISet(QTimer& timer)
|
|||||||
m_channelWindow = new ChannelWindow;
|
m_channelWindow = new ChannelWindow;
|
||||||
m_samplingDeviceControl = new SamplingDeviceControl;
|
m_samplingDeviceControl = new SamplingDeviceControl;
|
||||||
m_deviceEngine = 0;
|
m_deviceEngine = 0;
|
||||||
m_pluginManager = 0;
|
m_deviceAPI = 0;
|
||||||
|
// m_pluginManager = 0;
|
||||||
|
|
||||||
// m_spectrum needs to have its font to be set since it cannot be inherited from the main window
|
// m_spectrum needs to have its font to be set since it cannot be inherited from the main window
|
||||||
QFont font;
|
QFont font;
|
||||||
|
@ -61,7 +61,6 @@ public:
|
|||||||
ChannelWindow *m_channelWindow;
|
ChannelWindow *m_channelWindow;
|
||||||
SamplingDeviceControl *m_samplingDeviceControl;
|
SamplingDeviceControl *m_samplingDeviceControl;
|
||||||
DSPDeviceEngine *m_deviceEngine;
|
DSPDeviceEngine *m_deviceEngine;
|
||||||
PluginManager *m_pluginManager;
|
|
||||||
DeviceAPI *m_deviceAPI;
|
DeviceAPI *m_deviceAPI;
|
||||||
|
|
||||||
DeviceUISet(QTimer& timer);
|
DeviceUISet(QTimer& timer);
|
||||||
@ -87,16 +86,13 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
|
|
||||||
AudioDeviceInfo* m_audioDeviceInfo;
|
AudioDeviceInfo* m_audioDeviceInfo;
|
||||||
|
|
||||||
MessageQueue m_inputMessageQueue;
|
MessageQueue m_inputMessageQueue;
|
||||||
|
|
||||||
MainSettings m_settings;
|
MainSettings m_settings;
|
||||||
|
|
||||||
std::vector<DeviceUISet*> m_deviceUIs;
|
std::vector<DeviceUISet*> m_deviceUIs;
|
||||||
|
|
||||||
DSPEngine* m_dspEngine;
|
DSPEngine* m_dspEngine;
|
||||||
|
PluginManager* m_pluginManager;
|
||||||
|
|
||||||
QTimer m_masterTimer;
|
QTimer m_masterTimer;
|
||||||
QTimer m_statusTimer;
|
QTimer m_statusTimer;
|
||||||
|
@ -13,16 +13,6 @@ void PluginAPI::registerChannel(const QString& channelName, PluginInterface* plu
|
|||||||
m_pluginManager->registerChannel(channelName, plugin);
|
m_pluginManager->registerChannel(channelName, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void PluginAPI::registerChannelInstance(const QString& channelName, PluginGUI* pluginGUI)
|
|
||||||
//{
|
|
||||||
// m_pluginManager->registerChannelInstance(channelName, pluginGUI);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void PluginAPI::removeChannelInstance(PluginGUI* pluginGUI)
|
|
||||||
//{
|
|
||||||
// m_pluginManager->removeChannelInstance(pluginGUI);
|
|
||||||
//}
|
|
||||||
|
|
||||||
void PluginAPI::registerSampleSource(const QString& sourceName, PluginInterface* plugin)
|
void PluginAPI::registerSampleSource(const QString& sourceName, PluginInterface* plugin)
|
||||||
{
|
{
|
||||||
m_pluginManager->registerSampleSource(sourceName, plugin);
|
m_pluginManager->registerSampleSource(sourceName, plugin);
|
||||||
|
@ -35,8 +35,6 @@ public:
|
|||||||
|
|
||||||
// Channel stuff
|
// Channel stuff
|
||||||
void registerChannel(const QString& channelName, PluginInterface* plugin);
|
void registerChannel(const QString& channelName, PluginInterface* plugin);
|
||||||
// void registerChannelInstance(const QString& channelName, PluginGUI* pluginGUI);
|
|
||||||
// void removeChannelInstance(PluginGUI* pluginGUI);
|
|
||||||
ChannelRegistrations *getChannelRegistrations();
|
ChannelRegistrations *getChannelRegistrations();
|
||||||
|
|
||||||
// Sample Source stuff
|
// Sample Source stuff
|
||||||
@ -53,7 +51,6 @@ protected:
|
|||||||
~PluginAPI();
|
~PluginAPI();
|
||||||
|
|
||||||
friend class PluginManager;
|
friend class PluginManager;
|
||||||
friend class MainWindow;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_PLUGINAPI_H
|
#endif // INCLUDE_PLUGINAPI_H
|
||||||
|
@ -14,12 +14,10 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
PluginManager::PluginManager(MainWindow* mainWindow, uint deviceTabIndex, DSPDeviceEngine* dspDeviceEngine, QObject* parent) :
|
PluginManager::PluginManager(MainWindow* mainWindow, QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_pluginAPI(this, mainWindow),
|
m_pluginAPI(this, mainWindow),
|
||||||
m_mainWindow(mainWindow),
|
m_mainWindow(mainWindow),
|
||||||
m_deviceTabIndex(deviceTabIndex),
|
|
||||||
m_dspDeviceEngine(dspDeviceEngine),
|
|
||||||
m_sampleSourceId(),
|
m_sampleSourceId(),
|
||||||
m_sampleSourceSerial(),
|
m_sampleSourceSerial(),
|
||||||
m_sampleSourceSequence(0),
|
m_sampleSourceSequence(0),
|
||||||
@ -29,7 +27,7 @@ PluginManager::PluginManager(MainWindow* mainWindow, uint deviceTabIndex, DSPDev
|
|||||||
|
|
||||||
PluginManager::~PluginManager()
|
PluginManager::~PluginManager()
|
||||||
{
|
{
|
||||||
freeAll();
|
// freeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManager::loadPlugins()
|
void PluginManager::loadPlugins()
|
||||||
@ -59,23 +57,6 @@ void PluginManager::registerChannel(const QString& channelName, PluginInterface*
|
|||||||
m_channelRegistrations.append(PluginAPI::ChannelRegistration(channelName, plugin));
|
m_channelRegistrations.append(PluginAPI::ChannelRegistration(channelName, plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
//void PluginManager::registerChannelInstance(const QString& channelName, PluginGUI* pluginGUI)
|
|
||||||
//{
|
|
||||||
// m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, pluginGUI));
|
|
||||||
// renameChannelInstances();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void PluginManager::removeChannelInstance(PluginGUI* pluginGUI)
|
|
||||||
//{
|
|
||||||
// for(ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it) {
|
|
||||||
// if(it->m_gui == pluginGUI) {
|
|
||||||
// m_channelInstanceRegistrations.erase(it);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// renameChannelInstances();
|
|
||||||
//}
|
|
||||||
|
|
||||||
void PluginManager::registerSampleSource(const QString& sourceName, PluginInterface* plugin)
|
void PluginManager::registerSampleSource(const QString& sourceName, PluginInterface* plugin)
|
||||||
{
|
{
|
||||||
qDebug() << "PluginManager::registerSampleSource "
|
qDebug() << "PluginManager::registerSampleSource "
|
||||||
@ -85,169 +66,6 @@ void PluginManager::registerSampleSource(const QString& sourceName, PluginInterf
|
|||||||
m_sampleSourceRegistrations.append(SampleSourceRegistration(sourceName, plugin));
|
m_sampleSourceRegistrations.append(SampleSourceRegistration(sourceName, plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
//void PluginManager::loadChannelSettings(const Preset* preset, DeviceAPI *deviceAPI)
|
|
||||||
//{
|
|
||||||
// fprintf(stderr, "PluginManager::loadSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
|
||||||
//
|
|
||||||
// // copy currently open channels and clear list
|
|
||||||
// ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
|
|
||||||
// m_channelInstanceRegistrations.clear();
|
|
||||||
//
|
|
||||||
// for(int i = 0; i < preset->getChannelCount(); i++)
|
|
||||||
// {
|
|
||||||
// const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
|
||||||
// ChannelInstanceRegistration reg;
|
|
||||||
//
|
|
||||||
// // if we have one instance available already, use it
|
|
||||||
//
|
|
||||||
// for(int i = 0; i < openChannels.count(); i++)
|
|
||||||
// {
|
|
||||||
// qDebug("PluginManager::loadSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
|
||||||
//
|
|
||||||
// if(openChannels[i].m_channelName == channelConfig.m_channel)
|
|
||||||
// {
|
|
||||||
// qDebug("PluginManager::loadSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
|
||||||
// reg = openChannels.takeAt(i);
|
|
||||||
// m_channelInstanceRegistrations.append(reg);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // if we haven't one already, create one
|
|
||||||
//
|
|
||||||
// if(reg.m_gui == NULL)
|
|
||||||
// {
|
|
||||||
// for(int i = 0; i < m_channelRegistrations.count(); i++)
|
|
||||||
// {
|
|
||||||
// if(m_channelRegistrations[i].m_channelName == channelConfig.m_channel)
|
|
||||||
// {
|
|
||||||
// qDebug("PluginManager::loadSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel));
|
|
||||||
// reg = ChannelInstanceRegistration(channelConfig.m_channel, m_channelRegistrations[i].m_plugin->createChannel(channelConfig.m_channel, deviceAPI));
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(reg.m_gui != NULL)
|
|
||||||
// {
|
|
||||||
// qDebug("PluginManager::loadSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channel));
|
|
||||||
// reg.m_gui->deserialize(channelConfig.m_config);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // everything, that is still "available" is not needed anymore
|
|
||||||
// for(int i = 0; i < openChannels.count(); i++)
|
|
||||||
// {
|
|
||||||
// qDebug("PluginManager::loadSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
|
||||||
// openChannels[i].m_gui->destroy();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// renameChannelInstances();
|
|
||||||
//
|
|
||||||
//// loadSourceSettings(preset); // FIXME
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void PluginManager::loadSourceSettings(const Preset* preset)
|
|
||||||
//{
|
|
||||||
// fprintf(stderr, "PluginManager::loadSourceSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
|
||||||
//
|
|
||||||
// if(m_sampleSourcePluginGUI != 0)
|
|
||||||
// {
|
|
||||||
// const QByteArray* sourceConfig = preset->findBestSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence);
|
|
||||||
//
|
|
||||||
// if (sourceConfig != 0)
|
|
||||||
// {
|
|
||||||
// qDebug() << "PluginManager::loadSettings: deserializing source " << qPrintable(m_sampleSourceId);
|
|
||||||
// m_sampleSourcePluginGUI->deserialize(*sourceConfig);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// qint64 centerFrequency = preset->getCenterFrequency();
|
|
||||||
// m_sampleSourcePluginGUI->setCenterFrequency(centerFrequency);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// sort by increasing delta frequency and type (i.e. name)
|
|
||||||
bool PluginManager::ChannelInstanceRegistration::operator<(const ChannelInstanceRegistration& other) const {
|
|
||||||
if (m_gui && other.m_gui) {
|
|
||||||
if (m_gui->getCenterFrequency() == other.m_gui->getCenterFrequency()) {
|
|
||||||
return m_gui->getName() < other.m_gui->getName();
|
|
||||||
} else {
|
|
||||||
return m_gui->getCenterFrequency() < other.m_gui->getCenterFrequency();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//void PluginManager::saveSettings(Preset* preset)
|
|
||||||
//{
|
|
||||||
// qDebug("PluginManager::saveSettings");
|
|
||||||
//// saveSourceSettings(preset); // FIXME
|
|
||||||
//
|
|
||||||
// qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
|
|
||||||
//
|
|
||||||
// for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
|
|
||||||
// {
|
|
||||||
// preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize());
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//void PluginManager::saveSourceSettings(Preset* preset)
|
|
||||||
//{
|
|
||||||
// qDebug("PluginManager::saveSourceSettings");
|
|
||||||
//
|
|
||||||
// if(m_sampleSourcePluginGUI != NULL)
|
|
||||||
// {
|
|
||||||
// preset->addOrUpdateSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
|
|
||||||
// //preset->setSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
|
|
||||||
// preset->setCenterFrequency(m_sampleSourcePluginGUI->getCenterFrequency());
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
void PluginManager::freeAll()
|
|
||||||
{
|
|
||||||
m_dspDeviceEngine->stopAcquistion();
|
|
||||||
|
|
||||||
while(!m_channelInstanceRegistrations.isEmpty()) {
|
|
||||||
ChannelInstanceRegistration reg(m_channelInstanceRegistrations.takeLast());
|
|
||||||
reg.m_gui->destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_sampleSourcePluginGUI != NULL) {
|
|
||||||
m_dspDeviceEngine->setSource(NULL);
|
|
||||||
m_sampleSourcePluginGUI->destroy();
|
|
||||||
m_sampleSourcePluginGUI = NULL;
|
|
||||||
m_sampleSourceId.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//bool PluginManager::handleMessage(const Message& message)
|
|
||||||
//{
|
|
||||||
// if (m_sampleSourcePluginGUI != 0)
|
|
||||||
// {
|
|
||||||
// if ((message.getDestination() == 0) || (message.getDestination() == m_sampleSourcePluginGUI))
|
|
||||||
// {
|
|
||||||
// if (m_sampleSourcePluginGUI->handleMessage(message))
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it)
|
|
||||||
// {
|
|
||||||
// if ((message.getDestination() == 0) || (message.getDestination() == it->m_gui))
|
|
||||||
// {
|
|
||||||
// if (it->m_gui->handleMessage(message))
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
void PluginManager::updateSampleSourceDevices()
|
void PluginManager::updateSampleSourceDevices()
|
||||||
{
|
{
|
||||||
m_sampleSourceDevices.clear();
|
m_sampleSourceDevices.clear();
|
||||||
@ -498,13 +316,6 @@ void PluginManager::loadPlugins(const QDir& dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginManager::renameChannelInstances()
|
|
||||||
{
|
|
||||||
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) {
|
|
||||||
m_channelInstanceRegistrations[i].m_gui->setName(QString("%1:%2").arg(m_channelInstanceRegistrations[i].m_channelName).arg(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PluginManager::populateChannelComboBox(QComboBox *channels)
|
void PluginManager::populateChannelComboBox(QComboBox *channels)
|
||||||
{
|
{
|
||||||
for(PluginAPI::ChannelRegistrations::iterator it = m_channelRegistrations.begin(); it != m_channelRegistrations.end(); ++it)
|
for(PluginAPI::ChannelRegistrations::iterator it = m_channelRegistrations.begin(); it != m_channelRegistrations.end(); ++it)
|
||||||
|
@ -35,7 +35,7 @@ public:
|
|||||||
|
|
||||||
typedef QList<Plugin> Plugins;
|
typedef QList<Plugin> Plugins;
|
||||||
|
|
||||||
explicit PluginManager(MainWindow* mainWindow, uint deviceTabIndex, DSPDeviceEngine* dspDeviceEngine, QObject* parent = NULL);
|
explicit PluginManager(MainWindow* mainWindow, QObject* parent = NULL);
|
||||||
~PluginManager();
|
~PluginManager();
|
||||||
|
|
||||||
void loadPlugins();
|
void loadPlugins();
|
||||||
@ -43,21 +43,10 @@ public:
|
|||||||
|
|
||||||
// Callbacks from the plugins
|
// Callbacks from the plugins
|
||||||
void registerChannel(const QString& channelName, PluginInterface* plugin);
|
void registerChannel(const QString& channelName, PluginInterface* plugin);
|
||||||
// void registerChannelInstance(const QString& channelName, PluginGUI* pluginGUI);
|
|
||||||
// void removeChannelInstance(PluginGUI* pluginGUI);
|
|
||||||
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
|
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
|
||||||
|
|
||||||
PluginAPI::ChannelRegistrations *getChannelRegistrations() { return &m_channelRegistrations; }
|
PluginAPI::ChannelRegistrations *getChannelRegistrations() { return &m_channelRegistrations; }
|
||||||
|
|
||||||
// void loadChannelSettings(const Preset* preset, DeviceAPI *deviceAPI);
|
|
||||||
// void loadSourceSettings(const Preset* preset);
|
|
||||||
// void saveSettings(Preset* preset);
|
|
||||||
// void saveSourceSettings(Preset* preset);
|
|
||||||
|
|
||||||
void freeAll();
|
|
||||||
|
|
||||||
// bool handleMessage(const Message& message);
|
|
||||||
|
|
||||||
void updateSampleSourceDevices();
|
void updateSampleSourceDevices();
|
||||||
void fillSampleSourceSelector(QComboBox* comboBox);
|
void fillSampleSourceSelector(QComboBox* comboBox);
|
||||||
|
|
||||||
@ -68,24 +57,7 @@ public:
|
|||||||
void populateChannelComboBox(QComboBox *channels);
|
void populateChannelComboBox(QComboBox *channels);
|
||||||
void createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI);
|
void createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI);
|
||||||
|
|
||||||
PluginAPI *getAPI(MainWindow *mainWindow);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ChannelInstanceRegistration {
|
|
||||||
QString m_channelName;
|
|
||||||
PluginGUI* m_gui;
|
|
||||||
ChannelInstanceRegistration() :
|
|
||||||
m_channelName(),
|
|
||||||
m_gui(NULL)
|
|
||||||
{ }
|
|
||||||
ChannelInstanceRegistration(const QString& channelName, PluginGUI* pluginGUI) :
|
|
||||||
m_channelName(channelName),
|
|
||||||
m_gui(pluginGUI)
|
|
||||||
{ }
|
|
||||||
bool operator<(const ChannelInstanceRegistration& other) const;
|
|
||||||
};
|
|
||||||
typedef QList<ChannelInstanceRegistration> ChannelInstanceRegistrations;
|
|
||||||
|
|
||||||
struct SampleSourceRegistration {
|
struct SampleSourceRegistration {
|
||||||
QString m_sourceId;
|
QString m_sourceId;
|
||||||
PluginInterface* m_plugin;
|
PluginInterface* m_plugin;
|
||||||
@ -94,6 +66,7 @@ private:
|
|||||||
m_plugin(plugin)
|
m_plugin(plugin)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<SampleSourceRegistration> SampleSourceRegistrations;
|
typedef QList<SampleSourceRegistration> SampleSourceRegistrations;
|
||||||
|
|
||||||
struct SampleSourceDevice {
|
struct SampleSourceDevice {
|
||||||
@ -115,16 +88,14 @@ private:
|
|||||||
m_sourceSequence(sourceSequence)
|
m_sourceSequence(sourceSequence)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<SampleSourceDevice> SampleSourceDevices;
|
typedef QList<SampleSourceDevice> SampleSourceDevices;
|
||||||
|
|
||||||
PluginAPI m_pluginAPI;
|
PluginAPI m_pluginAPI;
|
||||||
MainWindow* m_mainWindow;
|
MainWindow* m_mainWindow;
|
||||||
uint m_deviceTabIndex;
|
|
||||||
DSPDeviceEngine* m_dspDeviceEngine;
|
|
||||||
Plugins m_plugins;
|
Plugins m_plugins;
|
||||||
|
|
||||||
PluginAPI::ChannelRegistrations m_channelRegistrations; //!< Channel plugins register here
|
PluginAPI::ChannelRegistrations m_channelRegistrations; //!< Channel plugins register here
|
||||||
ChannelInstanceRegistrations m_channelInstanceRegistrations; // TODO: remove
|
|
||||||
SampleSourceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
|
SampleSourceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
|
||||||
SampleSourceDevices m_sampleSourceDevices; //!< Instances of input sources present in the system
|
SampleSourceDevices m_sampleSourceDevices; //!< Instances of input sources present in the system
|
||||||
|
|
||||||
@ -134,7 +105,8 @@ private:
|
|||||||
PluginGUI* m_sampleSourcePluginGUI;
|
PluginGUI* m_sampleSourcePluginGUI;
|
||||||
|
|
||||||
void loadPlugins(const QDir& dir);
|
void loadPlugins(const QDir& dir);
|
||||||
void renameChannelInstances();
|
|
||||||
|
friend class MainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool operator<(const PluginManager::Plugin& a, const PluginManager::Plugin& b)
|
static inline bool operator<(const PluginManager::Plugin& a, const PluginManager::Plugin& b)
|
||||||
|
Loading…
Reference in New Issue
Block a user