1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 18:15:45 -05:00

Multi device support: add a unique ID to DSPDeviceEngine

This commit is contained in:
f4exb 2016-05-11 19:14:23 +02:00
parent 66daf9fa4e
commit 6ef4653d35
6 changed files with 30 additions and 5 deletions

View File

@ -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),

View File

@ -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; //<! Input message queue. Post here.
MessageQueue m_outputMessageQueue; //<! Output message queue. Listen here.
SyncMessenger m_syncMessenger; //!< Used to process messages synchronously with the thread

View File

@ -22,7 +22,7 @@
DSPEngine::DSPEngine() :
m_audioSampleRate(48000) // Use default output device at 48 kHz
{
m_deviceEngines.push_back(new DSPDeviceEngine());
m_deviceEngines.push_back(new DSPDeviceEngine(0)); // TODO: multi device support
m_dvSerialSupport = false;
}
@ -157,6 +157,23 @@ QString DSPEngine::errorMessage(uint deviceIndex)
return m_deviceEngines[deviceIndex]->errorMessage();
}
DSPDeviceEngine *DSPEngine::getDeviceEngineByUID(uint uid)
{
std::vector<DSPDeviceEngine*>::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();

View File

@ -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

View File

@ -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);

View File

@ -133,6 +133,8 @@ private:
QTreeWidgetItem* addPresetToTree(const Preset* preset);
void applySettings();
void createDevice();
private slots:
void handleDSPMessages();
void handleMessages();