mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-05 23:45:00 -04:00
Web API: use message passing to start/stop device for all the rest of device plugins
This commit is contained in:
@@ -179,6 +179,15 @@ bool FileSourceGui::handleMessage(const Message& message)
|
||||
updateWithStreamTime();
|
||||
return true;
|
||||
}
|
||||
else if (FileSourceInput::MsgStartStop::match(message))
|
||||
{
|
||||
FileSourceInput::MsgStartStop& notif = (FileSourceInput::MsgStartStop&) message;
|
||||
blockApplySettings(true);
|
||||
ui->startStop->setChecked(notif.getStartStop());
|
||||
blockApplySettings(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
@@ -207,18 +216,10 @@ void FileSourceGui::on_playLoop_toggled(bool checked __attribute__((unused)))
|
||||
|
||||
void FileSourceGui::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();
|
||||
FileSourceInput::MsgStartStop *message = FileSourceInput::MsgStartStop::create(checked);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ private:
|
||||
|
||||
DeviceUISet* m_deviceUISet;
|
||||
FileSourceInput::Settings m_settings;
|
||||
bool m_doApplySettings;
|
||||
QTimer m_statusTimer;
|
||||
std::vector<int> m_gains;
|
||||
DeviceSampleSource* m_sampleSource;
|
||||
@@ -72,6 +73,7 @@ private:
|
||||
int m_lastEngineState;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
|
||||
void blockApplySettings(bool block) { m_doApplySettings = !block; }
|
||||
void displaySettings();
|
||||
void displayTime();
|
||||
void sendSettings();
|
||||
|
||||
@@ -36,6 +36,7 @@ MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceName, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceWork, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceSeek, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceStreamTiming, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgStartStop, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceAcquisition, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamData, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamTiming, Message)
|
||||
@@ -288,6 +289,27 @@ bool FileSourceInput::handleMessage(const Message& message)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgStartStop::match(message))
|
||||
{
|
||||
MsgStartStop& cmd = (MsgStartStop&) message;
|
||||
qDebug() << "FileSourceInput::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;
|
||||
|
||||
@@ -155,6 +155,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)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgReportFileSourceStreamData : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
|
||||
Reference in New Issue
Block a user