1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-08-14 15:33:34 -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
+12 -11
View File
@@ -149,6 +149,15 @@ bool RTLSDRGui::handleMessage(const Message& message)
blockApplySettings(false);
return true;
}
if (RTLSDRInput::MsgStartStop::match(message))
{
RTLSDRInput::MsgStartStop& notif = (RTLSDRInput::MsgStartStop&) message;
blockApplySettings(true);
ui->startStop->setChecked(notif.getStartStop());
blockApplySettings(false);
return true;
}
else
{
return false;
@@ -320,18 +329,10 @@ void RTLSDRGui::on_gain_valueChanged(int value)
void RTLSDRGui::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();
RTLSDRInput::MsgStartStop *message = RTLSDRInput::MsgStartStop::create(checked);
m_sampleSource->getInputMessageQueue()->push(message);
}
}
+30 -10
View File
@@ -18,6 +18,7 @@
#include <QDebug>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include "SWGDeviceSettings.h"
#include "SWGRtlSdrSettings.h"
@@ -34,6 +35,7 @@
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgFileRecord, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgStartStop, Message)
const quint64 RTLSDRInput::frequencyLowRangeMin = 1000UL;
const quint64 RTLSDRInput::frequencyLowRangeMax = 275000UL;
@@ -274,6 +276,27 @@ bool RTLSDRInput::handleMessage(const Message& message)
return true;
}
else if (MsgStartStop::match(message))
{
MsgStartStop& cmd = (MsgStartStop&) message;
qDebug() << "RTLSDRInput::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
{
return false;
@@ -541,19 +564,16 @@ int RTLSDRInput::webapiRun(
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage __attribute__((unused)))
{
if (run)
MsgStartStop *message = MsgStartStop::create(run);
m_inputMessageQueue.push(message);
if (m_guiMessageQueue) // forward to GUI if any
{
if (m_deviceAPI->initAcquisition())
{
m_deviceAPI->startAcquisition();
DSPEngine::instance()->startAudioOutputImmediate();
}
}
else
{
m_deviceAPI->stopAcquisition();
MsgStartStop *msgToGUI = MsgStartStop::create(run);
m_guiMessageQueue->push(msgToGUI);
}
usleep(100000);
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
return 200;
}
+19
View File
@@ -92,6 +92,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)
{ }
};
RTLSDRInput(DeviceSourceAPI *deviceAPI);
virtual ~RTLSDRInput();
virtual void destroy();