1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Multi device support: pass plugin API to devices input handlers to give access to DSP device engine methods

This commit is contained in:
f4exb 2016-05-12 23:35:30 +02:00
parent 7b0e6fd42e
commit 7707858d57
25 changed files with 62 additions and 45 deletions

View File

@ -46,7 +46,7 @@ AirspyGui::AirspyGui(PluginAPI* pluginAPI, QWidget* parent) :
displaySettings();
m_sampleSource = new AirspyInput();
m_sampleSource = new AirspyInput(m_pluginAPI);
m_rates = ((AirspyInput*) m_sampleSource)->getSampleRates();
displaySampleRates();
connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));

View File

@ -20,6 +20,7 @@
#include "airspygui.h"
#include "airspyinput.h"
#include "plugin/pluginapi.h"
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
#include "airspysettings.h"
@ -28,7 +29,8 @@
MESSAGE_CLASS_DEFINITION(AirspyInput::MsgConfigureAirspy, Message)
MESSAGE_CLASS_DEFINITION(AirspyInput::MsgReportAirspy, Message)
AirspyInput::AirspyInput() :
AirspyInput::AirspyInput(PluginAPI *pluginAPI) :
m_pluginAPI(pluginAPI),
m_settings(),
m_dev(0),
m_airspyThread(0),
@ -449,7 +451,7 @@ bool AirspyInput::applySettings(const AirspySettings& settings, bool force)
{
int sampleRate = devSampleRate/(1<<m_settings.m_log2Decim);
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
DSPEngine::instance()->getInputMessageQueue()->push(notif);
m_pluginAPI->getDeviceInputMessageQueue()->push(notif);
}
return true;

View File

@ -22,6 +22,7 @@
#include <libairspy/airspy.h>
#include <QString>
class PluginAPI;
class AirspyThread;
class AirspyInput : public SampleSource {
@ -66,7 +67,7 @@ public:
{ }
};
AirspyInput();
AirspyInput(PluginAPI *pluginAPI);
virtual ~AirspyInput();
virtual bool init(const Message& message);
@ -85,6 +86,7 @@ private:
struct airspy_device *open_airspy_from_sequence(int sequence);
void setCenterFrequency(quint64 freq);
PluginAPI *m_pluginAPI;
QMutex m_mutex;
AirspySettings m_settings;
struct airspy_device* m_dev;

View File

@ -59,7 +59,7 @@ BladerfGui::BladerfGui(PluginAPI* pluginAPI, QWidget* parent) :
displaySettings();
m_sampleSource = new BladerfInput();
m_sampleSource = new BladerfInput(m_pluginAPI);
DSPEngine::instance()->setSource(m_sampleSource);
char recFileNameCStr[30];

View File

@ -18,6 +18,7 @@
#include <errno.h>
#include <QDebug>
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
@ -28,7 +29,8 @@
MESSAGE_CLASS_DEFINITION(BladerfInput::MsgConfigureBladerf, Message)
MESSAGE_CLASS_DEFINITION(BladerfInput::MsgReportBladerf, Message)
BladerfInput::BladerfInput() :
BladerfInput::BladerfInput(PluginAPI *pluginAPI) :
m_pluginAPI(pluginAPI),
m_settings(),
m_dev(0),
m_bladerfThread(0),
@ -413,7 +415,7 @@ bool BladerfInput::applySettings(const BladeRFSettings& settings, bool force)
{
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
DSPEngine::instance()->getInputMessageQueue()->push(notif);
m_pluginAPI->getDeviceInputMessageQueue()->push(notif);
}
qDebug() << "BladerfInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"

View File

@ -22,6 +22,7 @@
#include <libbladeRF.h>
#include <QString>
class PluginAPI;
class BladerfThread;
class BladerfInput : public SampleSource {
@ -63,7 +64,7 @@ public:
{ }
};
BladerfInput();
BladerfInput(PluginAPI *pluginAPI);
virtual ~BladerfInput();
virtual bool init(const Message& message);
@ -81,6 +82,7 @@ private:
bladerf_lna_gain getLnaGain(int lnaGain);
struct bladerf *open_bladerf_from_serial(const char *serial);
PluginAPI *m_pluginAPI;
QMutex m_mutex;
BladeRFSettings m_settings;
struct bladerf* m_dev;

View File

@ -140,7 +140,7 @@ FCDProGui::FCDProGui(PluginAPI* pluginAPI, QWidget* parent) :
displaySettings();
m_sampleSource = new FCDProInput();
m_sampleSource = new FCDProInput(m_pluginAPI);
DSPEngine::instance()->setSource(m_sampleSource);
char recFileNameCStr[30];

View File

@ -20,6 +20,8 @@
#include <QDebug>
#include <string.h>
#include <errno.h>
#include "plugin/pluginapi.h"
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
#include "fcdproinput.h"
@ -31,7 +33,8 @@
MESSAGE_CLASS_DEFINITION(FCDProInput::MsgConfigureFCD, Message)
FCDProInput::FCDProInput() :
FCDProInput::FCDProInput(PluginAPI *pluginAPI) :
m_pluginAPI(pluginAPI),
m_dev(0),
m_settings(),
m_FCDThread(0),
@ -344,7 +347,7 @@ void FCDProInput::applySettings(const FCDProSettings& settings, bool force)
if (signalChange)
{
DSPSignalNotification *notif = new DSPSignalNotification(fcd_traits<Pro>::sampleRate, m_settings.m_centerFrequency);
DSPEngine::instance()->getInputMessageQueue()->push(notif);
m_pluginAPI->getDeviceInputMessageQueue()->push(notif);
}
}

View File

@ -29,6 +29,7 @@ struct fcd_buffer {
std::size_t length;
};
class PluginAPI;
class FCDProThread;
class FCDProInput : public SampleSource {
@ -53,7 +54,7 @@ public:
{ }
};
FCDProInput();
FCDProInput(PluginAPI *pluginAPI);
virtual ~FCDProInput();
virtual bool init(const Message& cmd);
@ -89,6 +90,7 @@ private:
void applySettings(const FCDProSettings& settings, bool force);
void set_lo_ppm();
PluginAPI *m_pluginAPI;
hid_device *m_dev;
QMutex m_mutex;
FCDProSettings m_settings;

View File

@ -58,7 +58,7 @@ FCDProPlusGui::FCDProPlusGui(PluginAPI* pluginAPI, QWidget* parent) :
displaySettings();
m_sampleSource = new FCDProPlusInput();
m_sampleSource = new FCDProPlusInput(m_pluginAPI);
DSPEngine::instance()->setSource(m_sampleSource);
char recFileNameCStr[30];

View File

@ -19,6 +19,8 @@
#include <QDebug>
#include <string.h>
#include <errno.h>
#include "plugin/pluginapi.h"
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
#include "fcdproplusinput.h"
@ -30,7 +32,8 @@
MESSAGE_CLASS_DEFINITION(FCDProPlusInput::MsgConfigureFCD, Message)
FCDProPlusInput::FCDProPlusInput() :
FCDProPlusInput::FCDProPlusInput(PluginAPI *pluginAPI) :
m_pluginApi(pluginAPI),
m_dev(0),
m_settings(),
m_FCDThread(0),
@ -243,7 +246,8 @@ void FCDProPlusInput::applySettings(const FCDProPlusSettings& settings, bool for
if (signalChange)
{
DSPSignalNotification *notif = new DSPSignalNotification(fcd_traits<ProPlus>::sampleRate, m_settings.m_centerFrequency);
DSPEngine::instance()->getInputMessageQueue()->push(notif);
m_pluginApi->getDeviceInputMessageQueue()->push(notif);
//DSPEngine::instance()->getInputMessageQueue()->push(notif);
}
}

View File

@ -28,6 +28,7 @@ struct fcd_buffer {
std::size_t length;
};
class PluginAPI;
class FCDProPlusThread;
class FCDProPlusInput : public SampleSource {
@ -52,7 +53,7 @@ public:
{ }
};
FCDProPlusInput();
FCDProPlusInput(PluginAPI *pluginAPI);
virtual ~FCDProPlusInput();
virtual bool init(const Message& cmd);
@ -77,6 +78,7 @@ public:
private:
void applySettings(const FCDProPlusSettings& settings, bool force);
PluginAPI *m_pluginApi;
hid_device *m_dev;
QMutex m_mutex;
FCDProPlusSettings m_settings;

View File

@ -46,7 +46,7 @@ HackRFGui::HackRFGui(PluginAPI* pluginAPI, QWidget* parent) :
displaySettings();
m_sampleSource = new HackRFInput();
m_sampleSource = new HackRFInput(m_pluginAPI);
displaySampleRates();
displayBandwidths();

View File

@ -18,6 +18,7 @@
#include <errno.h>
#include <QDebug>
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
@ -29,7 +30,8 @@
MESSAGE_CLASS_DEFINITION(HackRFInput::MsgConfigureHackRF, Message)
MESSAGE_CLASS_DEFINITION(HackRFInput::MsgReportHackRF, Message)
HackRFInput::HackRFInput() :
HackRFInput::HackRFInput(PluginAPI *pluginAPI) :
m_pluginAPI(pluginAPI),
m_settings(),
m_dev(0),
m_hackRFThread(0),
@ -396,8 +398,7 @@ bool HackRFInput::applySettings(const HackRFSettings& settings, bool force)
{
int sampleRate = devSampleRate/(1<<m_settings.m_log2Decim);
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
DSPEngine::instance()->getInputMessageQueue()->push(notif);
//getOutputMessageQueue()->push(notif);
m_pluginAPI->getDeviceInputMessageQueue()->push(notif);
}
return true;

View File

@ -22,6 +22,7 @@
#include "hackrfsettings.h"
#include <QString>
class PluginAPI;
class HackRFThread;
class HackRFInput : public SampleSource {
@ -64,7 +65,7 @@ public:
{ }
};
HackRFInput();
HackRFInput(PluginAPI *pluginAPI);
virtual ~HackRFInput();
virtual bool init(const Message& message);
@ -82,6 +83,7 @@ private:
hackrf_device *open_hackrf_from_sequence(int sequence);
void setCenterFrequency(quint64 freq);
PluginAPI *m_pluginAPI;
QMutex m_mutex;
HackRFSettings m_settings;
struct hackrf_device* m_dev;

View File

@ -51,7 +51,7 @@ RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) :
displaySettings();
m_sampleSource = new RTLSDRInput();
m_sampleSource = new RTLSDRInput(m_pluginAPI);
connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
DSPEngine::instance()->setSource(m_sampleSource);

View File

@ -21,13 +21,15 @@
#include "rtlsdrinput.h"
#include "rtlsdrthread.h"
#include "rtlsdrgui.h"
#include "plugin/pluginapi.h"
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message)
RTLSDRInput::RTLSDRInput() :
RTLSDRInput::RTLSDRInput(PluginAPI *pluginAPI) :
m_pluginAPI(pluginAPI),
m_settings(),
m_dev(0),
m_rtlSDRThread(0),
@ -369,7 +371,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
{
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
DSPEngine::instance()->getInputMessageQueue()->push(notif);
m_pluginAPI->getDeviceInputMessageQueue()->push(notif);
}
return true;

View File

@ -23,6 +23,7 @@
#include <rtl-sdr.h>
#include <QString>
class PluginAPI;
class RTLSDRThread;
class RTLSDRInput : public SampleSource {
@ -67,7 +68,7 @@ public:
{ }
};
RTLSDRInput();
RTLSDRInput(PluginAPI *pluginAPI);
virtual ~RTLSDRInput();
virtual bool init(const Message& message);
@ -83,6 +84,7 @@ public:
void set_ds_mode(int on);
private:
PluginAPI *m_pluginAPI;
QMutex m_mutex;
RTLSDRSettings m_settings;
rtlsdr_dev_t* m_dev;

View File

@ -88,7 +88,7 @@ SDRdaemonGui::SDRdaemonGui(PluginAPI* pluginAPI, QWidget* parent) :
m_statusTimer.start(500);
connect(&(m_pluginAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
m_sampleSource = new SDRdaemonInput(m_pluginAPI->getMainWindow()->getMasterTimer());
m_sampleSource = new SDRdaemonInput(m_pluginAPI->getMainWindow()->getMasterTimer(), m_pluginAPI);
connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
DSPEngine::instance()->setSource(m_sampleSource);

View File

@ -18,6 +18,7 @@
#include <errno.h>
#include <QDebug>
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
@ -37,7 +38,8 @@ MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgReportSDRdaemonAcquisition, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgReportSDRdaemonStreamData, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgReportSDRdaemonStreamTiming, Message)
SDRdaemonInput::SDRdaemonInput(const QTimer& masterTimer) :
SDRdaemonInput::SDRdaemonInput(const QTimer& masterTimer, PluginAPI *pluginAPI) :
m_pluginAPI(pluginAPI),
m_address("127.0.0.1"),
m_port(9090),
m_SDRdaemonUDPHandler(0),

View File

@ -24,6 +24,7 @@
#include <iostream>
#include <stdint.h>
class PluginAPI;
class SDRdaemonUDPHandler;
class SDRdaemonInput : public SampleSource {
@ -273,7 +274,7 @@ public:
{ }
};
SDRdaemonInput(const QTimer& masterTimer);
SDRdaemonInput(const QTimer& masterTimer, PluginAPI *pluginAPI);
virtual ~SDRdaemonInput();
virtual bool init(const Message& message);
@ -289,6 +290,7 @@ public:
virtual bool handleMessage(const Message& message);
private:
PluginAPI *m_pluginAPI;
QMutex m_mutex;
QString m_address;
quint16 m_port;

View File

@ -49,11 +49,6 @@ MessageQueue* DSPEngine::getInputMessageQueue(uint deviceIndex)
return m_deviceEngines[deviceIndex]->getInputMessageQueue();
}
MessageQueue* DSPEngine::getOutputMessageQueue(uint deviceIndex)
{
return m_deviceEngines[deviceIndex]->getOutputMessageQueue();
}
void DSPEngine::stopAllAcquisitions()
{
std::vector<DSPDeviceEngine*>::iterator it = m_deviceEngines.begin();

View File

@ -39,7 +39,6 @@ public:
static DSPEngine *instance();
MessageQueue* getInputMessageQueue(uint deviceIndex = 0);
MessageQueue* getOutputMessageQueue(uint deviceIndex = 0);
uint getAudioSampleRate() const { return m_audioSampleRate; }

View File

@ -276,11 +276,6 @@ void MainWindow::closeEvent(QCloseEvent*)
{
}
void MainWindow::updateCenterFreqDisplay()
{
m_deviceUIs.back()->m_spectrum->setCenterFrequency(m_centerFrequency);
}
void MainWindow::updatePresetControls()
{
ui->presetTree->resizeColumnToContents(0);
@ -334,7 +329,6 @@ QTreeWidgetItem* MainWindow::addPresetToTree(const Preset* preset)
void MainWindow::applySettings()
{
updateCenterFreqDisplay();
}
void MainWindow::handleMessages()

View File

@ -122,7 +122,6 @@ private:
void createStatusBar();
void closeEvent(QCloseEvent*);
void updateCenterFreqDisplay();
void updatePresetControls();
QTreeWidgetItem* addPresetToTree(const Preset* preset);
void applySettings();