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

RTLSDR input: moved FileRecord out of the GUI

This commit is contained in:
f4exb 2017-09-04 11:29:27 +02:00
parent 0b4ee5cfcc
commit fd851592ba
4 changed files with 47 additions and 18 deletions

View File

@ -53,12 +53,6 @@ RTLSDRGui::RTLSDRGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
displaySettings(); displaySettings();
connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
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);
queryDeviceReport(); // will reply with MsgReportRTLSDR to report gain list queryDeviceReport(); // will reply with MsgReportRTLSDR to report gain list
@ -66,8 +60,6 @@ RTLSDRGui::RTLSDRGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
RTLSDRGui::~RTLSDRGui() RTLSDRGui::~RTLSDRGui()
{ {
m_deviceAPI->removeSink(m_fileSink);
delete m_fileSink;
delete ui; delete ui;
delete m_sampleSource; delete m_sampleSource;
} }
@ -169,7 +161,6 @@ void RTLSDRGui::handleDSPMessages()
m_deviceCenterFrequency = notif->getCenterFrequency(); m_deviceCenterFrequency = notif->getCenterFrequency();
qDebug("RTLSDRGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); qDebug("RTLSDRGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
updateSampleRateAndFrequency(); updateSampleRateAndFrequency();
m_fileSink->handleMessage(*notif); // forward to file sink
delete message; delete message;
} }
@ -329,16 +320,14 @@ void RTLSDRGui::on_startStop_toggled(bool checked)
void RTLSDRGui::on_record_toggled(bool checked) void RTLSDRGui::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();
} }
RTLSDRInput::MsgFileRecord* message = RTLSDRInput::MsgFileRecord::create(checked);
m_sampleSource->getInputMessageQueue()->push(message);
} }
void RTLSDRGui::queryDeviceReport() void RTLSDRGui::queryDeviceReport()

View File

@ -24,7 +24,6 @@
#include "rtlsdrinput.h" #include "rtlsdrinput.h"
class DeviceSourceAPI; class DeviceSourceAPI;
class FileRecord;
namespace Ui { namespace Ui {
class RTLSDRGui; class RTLSDRGui;
@ -58,7 +57,6 @@ private:
QTimer m_statusTimer; QTimer m_statusTimer;
std::vector<int> m_gains; std::vector<int> m_gains;
DeviceSampleSource* m_sampleSource; DeviceSampleSource* m_sampleSource;
FileRecord *m_fileSink; //!< File sink to record device I/Q output
int m_sampleRate; int m_sampleRate;
quint64 m_deviceCenterFrequency; //!< Center frequency in device quint64 m_deviceCenterFrequency; //!< Center frequency in device
int m_lastEngineState; int m_lastEngineState;

View File

@ -26,10 +26,12 @@
#include "rtlsdrgui.h" #include "rtlsdrgui.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/filerecord.h"
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message) MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgConfigureRTLSDR, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgQueryRTLSDR, Message) MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgQueryRTLSDR, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message) MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgReportRTLSDR, Message)
MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgFileRecord, Message)
RTLSDRInput::RTLSDRInput(DeviceSourceAPI *deviceAPI) : RTLSDRInput::RTLSDRInput(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI), m_deviceAPI(deviceAPI),
@ -40,11 +42,18 @@ RTLSDRInput::RTLSDRInput(DeviceSourceAPI *deviceAPI) :
m_running(false) m_running(false)
{ {
openDevice(); openDevice();
char recFileNameCStr[30];
sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID());
m_fileSink = new FileRecord(std::string(recFileNameCStr));
m_deviceAPI->addSink(m_fileSink);
} }
RTLSDRInput::~RTLSDRInput() RTLSDRInput::~RTLSDRInput()
{ {
if (m_running) stop(); if (m_running) stop();
m_deviceAPI->removeSink(m_fileSink);
delete m_fileSink;
closeDevice(); closeDevice();
} }
@ -246,6 +255,17 @@ bool RTLSDRInput::handleMessage(const Message& message)
return true; return true;
} }
else if (MsgFileRecord::match(message))
{
MsgFileRecord& conf = (MsgFileRecord&) message;
qDebug() << "RTLSDRInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
if (conf.getStartStop()) {
m_fileSink->startRecording();
} else {
m_fileSink->stopRecording();
}
}
else else
{ {
return false; return false;
@ -400,6 +420,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim); int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency); DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
m_deviceAPI->getDeviceInputMessageQueue()->push(notif); m_deviceAPI->getDeviceInputMessageQueue()->push(notif);
m_fileSink->handleMessage(*notif); // forward to file sink
} }
return true; return true;

View File

@ -26,6 +26,7 @@
class DeviceSourceAPI; class DeviceSourceAPI;
class RTLSDRThread; class RTLSDRThread;
class FileRecord;
class RTLSDRInput : public DeviceSampleSource { class RTLSDRInput : public DeviceSampleSource {
public: public:
@ -84,6 +85,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)
{ }
};
RTLSDRInput(DeviceSourceAPI *deviceAPI); RTLSDRInput(DeviceSourceAPI *deviceAPI);
virtual ~RTLSDRInput(); virtual ~RTLSDRInput();
@ -101,6 +121,7 @@ public:
private: private:
DeviceSourceAPI *m_deviceAPI; DeviceSourceAPI *m_deviceAPI;
FileRecord *m_fileSink; //!< File sink to record device I/Q output
QMutex m_mutex; QMutex m_mutex;
RTLSDRSettings m_settings; RTLSDRSettings m_settings;
rtlsdr_dev_t* m_dev; rtlsdr_dev_t* m_dev;