1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-24 10:50:29 -05:00

SDRDaemon input: moved FileRecord out of the GUI

This commit is contained in:
f4exb 2017-09-05 00:31:45 +02:00
parent 48503d3147
commit 6c25c939e7
4 changed files with 55 additions and 19 deletions

View File

@ -38,7 +38,6 @@
#include "util/simpleserializer.h" #include "util/simpleserializer.h"
#include <device/devicesourceapi.h> #include <device/devicesourceapi.h>
#include <dsp/filerecord.h>
#include "sdrdaemonsourcegui.h" #include "sdrdaemonsourcegui.h"
SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceSourceAPI *deviceAPI, QWidget* parent) : SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
@ -104,11 +103,6 @@ SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceSourceAPI *deviceAPI, QWidget* pare
displaySettings(); displaySettings();
char recFileNameCStr[30];
sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID());
m_fileSink = new FileRecord(std::string(recFileNameCStr));
m_deviceAPI->addSink(m_fileSink);
connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection); connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
m_eventsTime.start(); m_eventsTime.start();
@ -122,8 +116,6 @@ SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceSourceAPI *deviceAPI, QWidget* pare
SDRdaemonSourceGui::~SDRdaemonSourceGui() SDRdaemonSourceGui::~SDRdaemonSourceGui()
{ {
m_deviceAPI->removeSink(m_fileSink);
delete m_fileSink;
delete m_sampleSource; delete m_sampleSource;
delete ui; delete ui;
} }
@ -273,7 +265,8 @@ void SDRdaemonSourceGui::handleDSPMessages()
m_deviceCenterFrequency = notif->getCenterFrequency(); m_deviceCenterFrequency = notif->getCenterFrequency();
qDebug("SDRdaemonGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); qDebug("SDRdaemonGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
updateSampleRateAndFrequency(); updateSampleRateAndFrequency();
m_fileSink->handleMessage(*notif); // forward to file sink DSPSignalNotification *fwd = new DSPSignalNotification(*notif);
m_sampleSource->getInputMessageQueue()->push(fwd);
delete message; delete message;
} }
@ -620,16 +613,14 @@ void SDRdaemonSourceGui::on_startStop_toggled(bool checked)
void SDRdaemonSourceGui::on_record_toggled(bool checked) void SDRdaemonSourceGui::on_record_toggled(bool checked)
{ {
if (checked) if (checked) {
{
ui->record->setStyleSheet("QToolButton { background-color : red; }"); ui->record->setStyleSheet("QToolButton { background-color : red; }");
m_fileSink->startRecording(); } else {
}
else
{
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
m_fileSink->stopRecording();
} }
SDRdaemonSourceInput::MsgFileRecord* message = SDRdaemonSourceInput::MsgFileRecord::create(checked);
m_sampleSource->getInputMessageQueue()->push(message);
} }
void SDRdaemonSourceGui::on_eventCountsReset_clicked(bool checked __attribute__((unused))) void SDRdaemonSourceGui::on_eventCountsReset_clicked(bool checked __attribute__((unused)))

View File

@ -25,7 +25,6 @@
#include "sdrdaemonsourceinput.h" #include "sdrdaemonsourceinput.h"
class DeviceSourceAPI; class DeviceSourceAPI;
class FileRecord;
namespace Ui { namespace Ui {
class SDRdaemonSourceGui; class SDRdaemonSourceGui;
@ -59,7 +58,6 @@ private:
QTimer m_statusTimer; QTimer m_statusTimer;
DeviceSampleSource* m_sampleSource; DeviceSampleSource* m_sampleSource;
bool m_acquisition; bool m_acquisition;
FileRecord *m_fileSink; //!< File sink to record device I/Q output
int m_deviceSampleRate; int m_deviceSampleRate;
quint64 m_deviceCenterFrequency; //!< Center frequency in device quint64 m_deviceCenterFrequency; //!< Center frequency in device
int m_lastEngineState; int m_lastEngineState;

View File

@ -36,6 +36,7 @@ MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgConfigureSDRdaemonStreamTiming
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonAcquisition, Message) MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonAcquisition, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData, Message) MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming, Message) MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgFileRecord, Message)
SDRdaemonSourceInput::SDRdaemonSourceInput(const QTimer& masterTimer, DeviceSourceAPI *deviceAPI) : SDRdaemonSourceInput::SDRdaemonSourceInput(const QTimer& masterTimer, DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI), m_deviceAPI(deviceAPI),
@ -53,11 +54,18 @@ SDRdaemonSourceInput::SDRdaemonSourceInput(const QTimer& masterTimer, DeviceSour
m_sampleFifo.setSize(96000 * 4); m_sampleFifo.setSize(96000 * 4);
m_SDRdaemonUDPHandler = new SDRdaemonSourceUDPHandler(&m_sampleFifo, getOutputMessageQueueToGUI(), m_deviceAPI); m_SDRdaemonUDPHandler = new SDRdaemonSourceUDPHandler(&m_sampleFifo, getOutputMessageQueueToGUI(), m_deviceAPI);
m_SDRdaemonUDPHandler->connectTimer(&m_masterTimer); m_SDRdaemonUDPHandler->connectTimer(&m_masterTimer);
char recFileNameCStr[30];
sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID());
m_fileSink = new FileRecord(std::string(recFileNameCStr));
m_deviceAPI->addSink(m_fileSink);
} }
SDRdaemonSourceInput::~SDRdaemonSourceInput() SDRdaemonSourceInput::~SDRdaemonSourceInput()
{ {
stop(); stop();
m_deviceAPI->removeSink(m_fileSink);
delete m_fileSink;
delete m_SDRdaemonUDPHandler; delete m_SDRdaemonUDPHandler;
} }
@ -106,7 +114,25 @@ void SDRdaemonSourceInput::getRemoteAddress(QString &s)
bool SDRdaemonSourceInput::handleMessage(const Message& message) bool SDRdaemonSourceInput::handleMessage(const Message& message)
{ {
if (MsgConfigureSDRdaemonSource::match(message)) if (DSPSignalNotification::match(message))
{
DSPSignalNotification& notif = (DSPSignalNotification&) message;
return m_fileSink->handleMessage(notif); // forward to file sink
}
else if (MsgFileRecord::match(message))
{
MsgFileRecord& conf = (MsgFileRecord&) message;
qDebug() << "SDRdaemonSourceInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
if (conf.getStartStop()) {
m_fileSink->startRecording();
} else {
m_fileSink->stopRecording();
}
return true;
}
else if (MsgConfigureSDRdaemonSource::match(message))
{ {
qDebug() << "SDRdaemonSourceInput::handleMessage:" << message.getIdentifier(); qDebug() << "SDRdaemonSourceInput::handleMessage:" << message.getIdentifier();
//SDRdaemonSourceInput& conf = (MsgConfigureSDRdaemonFEC&) message; //SDRdaemonSourceInput& conf = (MsgConfigureSDRdaemonFEC&) message;

View File

@ -28,6 +28,7 @@
class DeviceSourceAPI; class DeviceSourceAPI;
class SDRdaemonSourceUDPHandler; class SDRdaemonSourceUDPHandler;
class FileRecord;
class SDRdaemonSourceInput : public DeviceSampleSource { class SDRdaemonSourceInput : public DeviceSampleSource {
public: public:
@ -283,6 +284,25 @@ public:
{ } { }
}; };
class MsgFileRecord : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool getStartStop() const { return m_startStop; }
static MsgFileRecord* create(bool startStop) {
return new MsgFileRecord(startStop);
}
protected:
bool m_startStop;
MsgFileRecord(bool startStop) :
Message(),
m_startStop(startStop)
{ }
};
SDRdaemonSourceInput(const QTimer& masterTimer, DeviceSourceAPI *deviceAPI); SDRdaemonSourceInput(const QTimer& masterTimer, DeviceSourceAPI *deviceAPI);
virtual ~SDRdaemonSourceInput(); virtual ~SDRdaemonSourceInput();
@ -310,6 +330,7 @@ private:
const QTimer& m_masterTimer; const QTimer& m_masterTimer;
bool m_autoFollowRate; bool m_autoFollowRate;
bool m_autoCorrBuffer; bool m_autoCorrBuffer;
FileRecord *m_fileSink; //!< File sink to record device I/Q output
}; };
#endif // INCLUDE_SDRDAEMONSOURCEINPUT_H #endif // INCLUDE_SDRDAEMONSOURCEINPUT_H