mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-24 11:12:27 -04:00
Prepare multi device support in DSP Engine
This commit is contained in:
parent
15d0fbfdea
commit
c556a16caa
@ -22,13 +22,19 @@
|
|||||||
DSPEngine::DSPEngine() :
|
DSPEngine::DSPEngine() :
|
||||||
m_audioSampleRate(48000) // Use default output device at 48 kHz
|
m_audioSampleRate(48000) // Use default output device at 48 kHz
|
||||||
{
|
{
|
||||||
m_deviceEngine = new DSPDeviceEngine();
|
m_deviceEngines.push_back(new DSPDeviceEngine());
|
||||||
m_dvSerialSupport = false;
|
m_dvSerialSupport = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DSPEngine::~DSPEngine()
|
DSPEngine::~DSPEngine()
|
||||||
{
|
{
|
||||||
delete m_deviceEngine;
|
std::vector<DSPDeviceEngine*>::iterator it = m_deviceEngines.begin();
|
||||||
|
|
||||||
|
while (it != m_deviceEngines.end())
|
||||||
|
{
|
||||||
|
delete *it;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(DSPEngine, dspEngine)
|
Q_GLOBAL_STATIC(DSPEngine, dspEngine)
|
||||||
@ -37,90 +43,90 @@ DSPEngine *DSPEngine::instance()
|
|||||||
return dspEngine;
|
return dspEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueue* DSPEngine::getInputMessageQueue()
|
MessageQueue* DSPEngine::getInputMessageQueue(uint deviceIndex)
|
||||||
{
|
{
|
||||||
return m_deviceEngine->getInputMessageQueue();
|
return m_deviceEngines[deviceIndex]->getInputMessageQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueue* DSPEngine::getOutputMessageQueue()
|
MessageQueue* DSPEngine::getOutputMessageQueue(uint deviceIndex)
|
||||||
{
|
{
|
||||||
return m_deviceEngine->getOutputMessageQueue();
|
return m_deviceEngines[deviceIndex]->getOutputMessageQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::start()
|
void DSPEngine::start(uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::start");
|
qDebug("DSPEngine::start(%d)", deviceIndex);
|
||||||
m_deviceEngine->start();
|
m_deviceEngines[deviceIndex]->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::stop()
|
void DSPEngine::stop(uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::stop");
|
qDebug("DSPEngine::stop(%d)", deviceIndex);
|
||||||
m_audioOutput.stop();
|
m_audioOutput.stop(); // FIXME: do not stop here since it is global
|
||||||
m_deviceEngine->stop();
|
m_deviceEngines[deviceIndex]->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DSPEngine::initAcquisition()
|
bool DSPEngine::initAcquisition(uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::initAcquisition");
|
qDebug("DSPEngine::initAcquisition(%d)", deviceIndex);
|
||||||
return m_deviceEngine->initAcquisition();
|
return m_deviceEngines[deviceIndex]->initAcquisition();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DSPEngine::startAcquisition()
|
bool DSPEngine::startAcquisition(uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::startAcquisition");
|
qDebug("DSPEngine::startAcquisition(%d)", deviceIndex);
|
||||||
bool started = m_deviceEngine->startAcquisition();
|
bool started = m_deviceEngines[deviceIndex]->startAcquisition();
|
||||||
|
|
||||||
if (started)
|
if (started)
|
||||||
{
|
{
|
||||||
m_audioOutput.start(-1, m_audioSampleRate);
|
m_audioOutput.start(-1, m_audioSampleRate); // FIXME: do not start here since it is global
|
||||||
m_audioSampleRate = m_audioOutput.getRate(); // update with actual rate
|
m_audioSampleRate = m_audioOutput.getRate(); // update with actual rate
|
||||||
}
|
}
|
||||||
|
|
||||||
return started;
|
return started;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::stopAcquistion()
|
void DSPEngine::stopAcquistion(uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::stopAcquistion");
|
qDebug("DSPEngine::stopAcquistion(%d)", deviceIndex);
|
||||||
m_audioOutput.stop();
|
m_audioOutput.stop();
|
||||||
m_deviceEngine->stopAcquistion();
|
m_deviceEngines[deviceIndex]->stopAcquistion();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::setSource(SampleSource* source)
|
void DSPEngine::setSource(SampleSource* source, uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::setSource");
|
qDebug("DSPEngine::setSource(%d)", deviceIndex);
|
||||||
m_deviceEngine->setSource(source);
|
m_deviceEngines[deviceIndex]->setSource(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::setSourceSequence(int sequence)
|
void DSPEngine::setSourceSequence(int sequence, uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::setSource");
|
qDebug("DSPEngine::setSource(%d)", deviceIndex);
|
||||||
m_deviceEngine->setSourceSequence(sequence);
|
m_deviceEngines[deviceIndex]->setSourceSequence(sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::addSink(SampleSink* sink)
|
void DSPEngine::addSink(SampleSink* sink, uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::setSource");
|
qDebug("DSPEngine::setSource(%d)", deviceIndex);
|
||||||
m_deviceEngine->addSink(sink);
|
m_deviceEngines[deviceIndex]->addSink(sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::removeSink(SampleSink* sink)
|
void DSPEngine::removeSink(SampleSink* sink, uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::removeSink");
|
qDebug("DSPEngine::removeSink(%d)", deviceIndex);
|
||||||
m_deviceEngine->removeSink(sink);
|
m_deviceEngines[deviceIndex]->removeSink(sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::addThreadedSink(ThreadedSampleSink* sink)
|
void DSPEngine::addThreadedSink(ThreadedSampleSink* sink, uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::addThreadedSink");
|
qDebug("DSPEngine::addThreadedSink(%d)", deviceIndex);
|
||||||
m_deviceEngine->addThreadedSink(sink);
|
m_deviceEngines[deviceIndex]->addThreadedSink(sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::removeThreadedSink(ThreadedSampleSink* sink)
|
void DSPEngine::removeThreadedSink(ThreadedSampleSink* sink, uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::addThreadedSink");
|
qDebug("DSPEngine::removeThreadedSink(%d)", deviceIndex);
|
||||||
m_deviceEngine->removeThreadedSink(sink);
|
m_deviceEngines[deviceIndex]->removeThreadedSink(sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::addAudioSink(AudioFifo* audioFifo)
|
void DSPEngine::addAudioSink(AudioFifo* audioFifo)
|
||||||
@ -135,25 +141,25 @@ void DSPEngine::removeAudioSink(AudioFifo* audioFifo)
|
|||||||
m_audioOutput.removeFifo(audioFifo);
|
m_audioOutput.removeFifo(audioFifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection)
|
void DSPEngine::configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, uint deviceIndex)
|
||||||
{
|
{
|
||||||
qDebug("DSPEngine::configureCorrections");
|
qDebug("DSPEngine::configureCorrections(%d)", deviceIndex);
|
||||||
m_deviceEngine->configureCorrections(dcOffsetCorrection, iqImbalanceCorrection);
|
m_deviceEngines[deviceIndex]->configureCorrections(dcOffsetCorrection, iqImbalanceCorrection);
|
||||||
}
|
}
|
||||||
|
|
||||||
DSPDeviceEngine::State DSPEngine::state() const
|
DSPDeviceEngine::State DSPEngine::state(uint deviceIndex) const
|
||||||
{
|
{
|
||||||
return m_deviceEngine->state();
|
return m_deviceEngines[deviceIndex]->state();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DSPEngine::errorMessage()
|
QString DSPEngine::errorMessage(uint deviceIndex)
|
||||||
{
|
{
|
||||||
return m_deviceEngine->errorMessage();
|
return m_deviceEngines[deviceIndex]->errorMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DSPEngine::sourceDeviceDescription()
|
QString DSPEngine::sourceDeviceDescription(uint deviceIndex)
|
||||||
{
|
{
|
||||||
return m_deviceEngine->sourceDeviceDescription();
|
return m_deviceEngines[deviceIndex]->sourceDeviceDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPEngine::setDVSerialSupport(bool support)
|
void DSPEngine::setDVSerialSupport(bool support)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define INCLUDE_DSPENGINE_H
|
#define INCLUDE_DSPENGINE_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <vector>
|
||||||
#include "dsp/dspdeviceengine.h"
|
#include "dsp/dspdeviceengine.h"
|
||||||
#include "audio/audiooutput.h"
|
#include "audio/audiooutput.h"
|
||||||
#include "util/export.h"
|
#include "util/export.h"
|
||||||
@ -37,36 +38,38 @@ public:
|
|||||||
|
|
||||||
static DSPEngine *instance();
|
static DSPEngine *instance();
|
||||||
|
|
||||||
MessageQueue* getInputMessageQueue();
|
MessageQueue* getInputMessageQueue(uint deviceIndex = 0);
|
||||||
MessageQueue* getOutputMessageQueue();
|
MessageQueue* getOutputMessageQueue(uint deviceIndex = 0);
|
||||||
|
|
||||||
uint getAudioSampleRate() const { return m_audioSampleRate; }
|
uint getAudioSampleRate() const { return m_audioSampleRate; }
|
||||||
|
|
||||||
void start(); //!< Device engine(s) start
|
void start(uint deviceIndex = 0); //!< Device engine(s) start
|
||||||
void stop(); //!< Device engine(s) stop
|
void stop(uint deviceIndex = 0); //!< Device engine(s) stop
|
||||||
|
|
||||||
bool initAcquisition(); //!< Initialize acquisition sequence
|
bool initAcquisition(uint deviceIndex = 0); //!< Initialize acquisition sequence
|
||||||
bool startAcquisition(); //!< Start acquisition sequence
|
bool startAcquisition(uint deviceIndex = 0); //!< Start acquisition sequence
|
||||||
void stopAcquistion(); //!< Stop acquisition sequence
|
void stopAcquistion(uint deviceIndex = 0); //!< Stop acquisition sequence
|
||||||
|
|
||||||
void setSource(SampleSource* source); //!< Set the sample source type
|
void setSource(SampleSource* source, uint deviceIndex = 0); //!< Set the sample source type
|
||||||
void setSourceSequence(int sequence); //!< Set the sample source sequence in type
|
void setSourceSequence(int sequence, uint deviceIndex = 0); //!< Set the sample source sequence in type
|
||||||
|
|
||||||
void addSink(SampleSink* sink); //!< Add a sample sink
|
void addSink(SampleSink* sink, uint deviceIndex = 0); //!< Add a sample sink
|
||||||
void removeSink(SampleSink* sink); //!< Remove a sample sink
|
void removeSink(SampleSink* sink, uint deviceIndex = 0); //!< Remove a sample sink
|
||||||
|
|
||||||
void addThreadedSink(ThreadedSampleSink* sink); //!< Add a sample sink that will run on its own thread
|
void addThreadedSink(ThreadedSampleSink* sink, uint deviceIndex = 0); //!< Add a sample sink that will run on its own thread
|
||||||
void removeThreadedSink(ThreadedSampleSink* sink); //!< Remove a sample sink that runs on its own thread
|
void removeThreadedSink(ThreadedSampleSink* sink, uint deviceIndex = 0); //!< Remove a sample sink that runs on its own thread
|
||||||
|
|
||||||
void addAudioSink(AudioFifo* audioFifo); //!< Add the audio sink
|
void addAudioSink(AudioFifo* audioFifo); //!< Add the audio sink
|
||||||
void removeAudioSink(AudioFifo* audioFifo); //!< Remove the audio sink
|
void removeAudioSink(AudioFifo* audioFifo); //!< Remove the audio sink
|
||||||
|
|
||||||
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure DSP corrections
|
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, uint deviceIndex = 0); //!< Configure DSP corrections
|
||||||
|
|
||||||
DSPDeviceEngine::State state() const;
|
DSPDeviceEngine::State state(uint deviceIndex = 0) const;
|
||||||
|
|
||||||
QString errorMessage(); //!< Return the current error message
|
QString errorMessage(uint deviceIndex = 0); //!< Return the current error message
|
||||||
QString sourceDeviceDescription(); //!< Return the source device description
|
QString sourceDeviceDescription(uint deviceIndex = 0); //!< Return the source device description
|
||||||
|
|
||||||
|
// Serial DV methods:
|
||||||
|
|
||||||
bool hasDVSerialSupport()
|
bool hasDVSerialSupport()
|
||||||
{
|
{
|
||||||
@ -94,7 +97,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DSPDeviceEngine *m_deviceEngine;
|
std::vector<DSPDeviceEngine*> m_deviceEngines;
|
||||||
AudioOutput m_audioOutput;
|
AudioOutput m_audioOutput;
|
||||||
uint m_audioSampleRate;
|
uint m_audioSampleRate;
|
||||||
bool m_dvSerialSupport;
|
bool m_dvSerialSupport;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user