1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 14:04:46 -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
@@ -18,6 +18,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <QDebug>
#include "SWGDeviceSettings.h"
@@ -34,6 +35,7 @@
#include "hackrfoutputthread.h"
MESSAGE_CLASS_DEFINITION(HackRFOutput::MsgConfigureHackRF, Message)
MESSAGE_CLASS_DEFINITION(HackRFOutput::MsgStartStop, Message)
MESSAGE_CLASS_DEFINITION(HackRFOutput::MsgReportHackRF, Message)
HackRFOutput::HackRFOutput(DeviceSinkAPI *deviceAPI) :
@@ -205,6 +207,27 @@ bool HackRFOutput::handleMessage(const Message& message)
return true;
}
else if (MsgStartStop::match(message))
{
MsgStartStop& cmd = (MsgStartStop&) message;
qDebug() << "HackRFOutput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
if (cmd.getStartStop())
{
if (m_deviceAPI->initGeneration())
{
m_deviceAPI->startGeneration();
DSPEngine::instance()->startAudioInput();
}
}
else
{
m_deviceAPI->stopGeneration();
DSPEngine::instance()->stopAudioInput();
}
return true;
}
else
{
return false;
@@ -413,19 +436,16 @@ int HackRFOutput::webapiRun(
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage __attribute__((unused)))
{
if (run)
MsgStartStop *message = MsgStartStop::create(run);
m_inputMessageQueue.push(message);
if (m_guiMessageQueue)
{
if (m_deviceAPI->initGeneration())
{
m_deviceAPI->startGeneration();
DSPEngine::instance()->startAudioInputImmediate();
}
}
else
{
m_deviceAPI->stopGeneration();
MsgStartStop *messagetoGui = MsgStartStop::create(run);
m_guiMessageQueue->push(messagetoGui);
}
usleep(100000);
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
return 200;
}