1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-07 08:24:43 -04:00

Web API: use message passing to start/stop device for all the rest of device plugins

This commit is contained in:
f4exb
2017-12-14 18:02:49 +01:00
parent db86bc5813
commit 966767a44a
42 changed files with 884 additions and 389 deletions
+16 -12
View File
@@ -210,7 +210,19 @@ bool FCDProGui::deserialize(const QByteArray& data)
bool FCDProGui::handleMessage(const Message& message __attribute__((unused)))
{
return false;
if (BladerfInput::MsgStartStop::match(message))
{
BladerfInput::MsgStartStop& notif = (BladerfInput::MsgStartStop&) message;
blockApplySettings(true);
ui->startStop->setChecked(notif.getStartStop());
blockApplySettings(false);
return true;
}
else
{
return false;
}
}
void FCDProGui::handleInputMessages()
@@ -435,18 +447,10 @@ void FCDProGui::on_setDefaults_clicked(bool checked __attribute__((unused)))
void FCDProGui::on_startStop_toggled(bool checked)
{
if (checked)
if (m_doApplySettings)
{
if (m_deviceUISet->m_deviceSourceAPI->initAcquisition())
{
m_deviceUISet->m_deviceSourceAPI->startAcquisition();
DSPEngine::instance()->startAudioOutput();
}
}
else
{
m_deviceUISet->m_deviceSourceAPI->stopAcquisition();
DSPEngine::instance()->stopAudioOutput();
BladerfInput::MsgStartStop *message = BladerfInput::MsgStartStop::create(checked);
m_sampleSource->getInputMessageQueue()->push(message);
}
}
+2
View File
@@ -55,6 +55,7 @@ private:
Ui::FCDProGui* ui;
DeviceUISet* m_deviceUISet;
bool m_doApplySettings;
bool m_forceSettings;
FCDProSettings m_settings;
QTimer m_updateTimer;
@@ -66,6 +67,7 @@ private:
int m_lastEngineState;
MessageQueue m_inputMessageQueue;
void blockApplySettings(bool block) { m_doApplySettings = !block; }
void displaySettings();
void sendSettings();
void updateSampleRateAndFrequency();
@@ -34,6 +34,7 @@
#include "fcdproconst.h"
MESSAGE_CLASS_DEFINITION(FCDProInput::MsgConfigureFCD, Message)
MESSAGE_CLASS_DEFINITION(FCDProInput::MsgStartStop, Message)
MESSAGE_CLASS_DEFINITION(FCDProInput::MsgFileRecord, Message)
FCDProInput::FCDProInput(DeviceSourceAPI *deviceAPI) :
@@ -178,6 +179,27 @@ bool FCDProInput::handleMessage(const Message& message)
applySettings(conf.getSettings(), conf.getForce());
return true;
}
else if (MsgStartStop::match(message))
{
MsgStartStop& cmd = (MsgStartStop&) message;
qDebug() << "FCDProInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
if (cmd.getStartStop())
{
if (m_deviceAPI->initAcquisition())
{
m_deviceAPI->startAcquisition();
DSPEngine::instance()->startAudioOutput();
}
}
else
{
m_deviceAPI->stopAcquisition();
DSPEngine::instance()->stopAudioOutput();
}
return true;
}
else if (MsgFileRecord::match(message))
{
MsgFileRecord& conf = (MsgFileRecord&) message;
+19
View File
@@ -78,6 +78,25 @@ public:
{ }
};
class MsgStartStop : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool getStartStop() const { return m_startStop; }
static MsgStartStop* create(bool startStop) {
return new MsgStartStop(startStop);
}
protected:
bool m_startStop;
MsgStartStop(bool startStop) :
Message(),
m_startStop(startStop)
{ }
};
FCDProInput(DeviceSourceAPI *deviceAPI);
virtual ~FCDProInput();
virtual void destroy();