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

Web API: fixed segfault when mixing start/stop between GUI and API. Applied to BladeRF input, SDRdaemon input and SDRPlay

This commit is contained in:
f4exb
2017-12-14 00:19:59 +01:00
parent 8798b64471
commit 53925bd4fd
10 changed files with 199 additions and 66 deletions
@@ -247,6 +247,15 @@ bool SDRdaemonSourceGui::handleMessage(const Message& message)
updateWithStreamTime();
return true;
}
else if (SDRdaemonSourceInput::MsgStartStop::match(message))
{
SDRdaemonSourceInput::MsgStartStop& notif = (SDRdaemonSourceInput::MsgStartStop&) message;
blockApplySettings(true);
ui->startStop->setChecked(notif.getStartStop());
blockApplySettings(false);
return true;
}
else
{
return false;
@@ -591,18 +600,10 @@ void SDRdaemonSourceGui::on_nbFECBlocks_valueChanged(int value)
void SDRdaemonSourceGui::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();
SDRdaemonSourceInput::MsgStartStop *message = SDRdaemonSourceInput::MsgStartStop::create(checked);
m_sampleSource->getInputMessageQueue()->push(message);
}
}
@@ -16,6 +16,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <QDebug>
#include "SWGDeviceSettings.h"
@@ -40,6 +41,7 @@ MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonAcquisition, Me
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgFileRecord, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgStartStop, Message)
SDRdaemonSourceInput::SDRdaemonSourceInput(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
@@ -138,6 +140,27 @@ bool SDRdaemonSourceInput::handleMessage(const Message& message)
return true;
}
else if (MsgStartStop::match(message))
{
MsgStartStop& cmd = (MsgStartStop&) message;
qDebug() << "SDRdaemonSourceInput::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 (MsgConfigureSDRdaemonSource::match(message))
{
qDebug() << "SDRdaemonSourceInput::handleMessage:" << message.getIdentifier();
@@ -222,19 +245,16 @@ int SDRdaemonSourceInput::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;
}
@@ -303,6 +303,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)
{ }
};
SDRdaemonSourceInput(DeviceSourceAPI *deviceAPI);
virtual ~SDRdaemonSourceInput();
virtual void destroy();