diff --git a/sdrbase/dsp/dspdeviceengine.cpp b/sdrbase/dsp/dspdeviceengine.cpp index 2149c096f..feb244141 100644 --- a/sdrbase/dsp/dspdeviceengine.cpp +++ b/sdrbase/dsp/dspdeviceengine.cpp @@ -25,7 +25,8 @@ #include "dsp/dspcommands.h" #include "dsp/samplesource.h" -DSPDeviceEngine::DSPDeviceEngine(QObject* parent) : +DSPDeviceEngine::DSPDeviceEngine(uint uid, QObject* parent) : + m_uid(uid), QThread(parent), m_state(StNotStarted), m_sampleSource(0), diff --git a/sdrbase/dsp/dspdeviceengine.h b/sdrbase/dsp/dspdeviceengine.h index 1f7e40a0e..18e406939 100644 --- a/sdrbase/dsp/dspdeviceengine.h +++ b/sdrbase/dsp/dspdeviceengine.h @@ -45,9 +45,11 @@ public: StError //!< engine is in error }; - DSPDeviceEngine(QObject* parent = NULL); + DSPDeviceEngine(uint uid, QObject* parent = NULL); ~DSPDeviceEngine(); + uint getUID() const { return m_uid; } + MessageQueue* getInputMessageQueue() { return &m_inputMessageQueue; } MessageQueue* getOutputMessageQueue() { return &m_outputMessageQueue; } @@ -75,6 +77,8 @@ public: QString sourceDeviceDescription(); //!< Return the source device description private: + uint m_uid; //!< unique ID + MessageQueue m_inputMessageQueue; //errorMessage(); } +DSPDeviceEngine *DSPEngine::getDeviceEngineByUID(uint uid) +{ + std::vector::iterator it = m_deviceEngines.begin(); + + while (it != m_deviceEngines.end()) + { + if ((*it)->getUID() == uid) + { + return *it; + } + + ++it; + } + + return 0; +} + QString DSPEngine::sourceDeviceDescription(uint deviceIndex) { return m_deviceEngines[deviceIndex]->sourceDeviceDescription(); diff --git a/sdrbase/dsp/dspengine.h b/sdrbase/dsp/dspengine.h index fbc88f259..4583fbabc 100644 --- a/sdrbase/dsp/dspengine.h +++ b/sdrbase/dsp/dspengine.h @@ -65,7 +65,8 @@ public: QString errorMessage(uint deviceIndex = 0); //!< Return the current error message QString sourceDeviceDescription(uint deviceIndex = 0); //!< Return the source device description - DSPDeviceEngine *getDeviceEngine(uint deviceIndex) { return m_deviceEngines[deviceIndex]; } + DSPDeviceEngine *getDeviceEngineByIndex(uint deviceIndex) { return m_deviceEngines[deviceIndex]; } + DSPDeviceEngine *getDeviceEngineByUID(uint uid); void addAudioSink(AudioFifo* audioFifo); //!< Add the audio sink void removeAudioSink(AudioFifo* audioFifo); //!< Remove the audio sink diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index 860def5f4..ff2a4a42e 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -104,7 +104,7 @@ MainWindow::MainWindow(QWidget* parent) : qDebug() << "MainWindow::MainWindow: m_pluginManager->loadPlugins ..."; - m_pluginManager = new PluginManager(this, m_dspEngine->getDeviceEngine(0)); + m_pluginManager = new PluginManager(this, m_dspEngine->getDeviceEngineByIndex(0)); m_pluginManager->loadPlugins(); //bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true); diff --git a/sdrbase/mainwindow.h b/sdrbase/mainwindow.h index ed5348452..374703fad 100644 --- a/sdrbase/mainwindow.h +++ b/sdrbase/mainwindow.h @@ -133,6 +133,8 @@ private: QTreeWidgetItem* addPresetToTree(const Preset* preset); void applySettings(); + void createDevice(); + private slots: void handleDSPMessages(); void handleMessages();