mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-02 06:04:39 -04:00
Web API: use message passing to start/stop device for all the rest of device plugins
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user