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

SDRPlay input: moved FileRecord out of the GUI

This commit is contained in:
f4exb 2017-09-05 00:40:42 +02:00
parent 6c25c939e7
commit ea4f0972be
4 changed files with 49 additions and 17 deletions

View File

@ -20,7 +20,6 @@
#include "sdrplaygui.h"
#include <device/devicesourceapi.h>
#include <dsp/filerecord.h>
#include "ui_sdrplaygui.h"
#include "gui/colormapper.h"
@ -72,12 +71,6 @@ SDRPlayGui::SDRPlayGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
displaySettings();
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);
}
@ -190,7 +183,6 @@ void SDRPlayGui::handleDSPMessages()
m_deviceCenterFrequency = notif->getCenterFrequency();
qDebug("SDRPlayGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
updateSampleRateAndFrequency();
m_fileSink->handleMessage(*notif); // forward to file sink
delete message;
}
@ -464,16 +456,14 @@ void SDRPlayGui::on_startStop_toggled(bool checked)
void SDRPlayGui::on_record_toggled(bool checked)
{
if (checked)
{
if (checked) {
ui->record->setStyleSheet("QToolButton { background-color : red; }");
m_fileSink->startRecording();
}
else
{
} else {
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
m_fileSink->stopRecording();
}
SDRPlayInput::MsgFileRecord* message = SDRPlayInput::MsgFileRecord::create(checked);
m_sampleSource->getInputMessageQueue()->push(message);
}
// ====================================================================

View File

@ -27,7 +27,6 @@
class DeviceSampleSource;
class DeviceSourceAPI;
class FileRecord;
namespace Ui {
class SDRPlayGui;
@ -59,7 +58,6 @@ private:
QTimer m_updateTimer;
QTimer m_statusTimer;
DeviceSampleSource* m_sampleSource;
FileRecord *m_fileSink; //!< File sink to record device I/Q output
int m_sampleRate;
quint64 m_deviceCenterFrequency; //!< Center frequency in device
int m_lastEngineState;

View File

@ -21,6 +21,7 @@
#include "util/simpleserializer.h"
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
#include <dsp/filerecord.h>
#include "sdrplaygui.h"
#include "sdrplayinput.h"
@ -30,6 +31,7 @@
MESSAGE_CLASS_DEFINITION(SDRPlayInput::MsgConfigureSDRPlay, Message)
MESSAGE_CLASS_DEFINITION(SDRPlayInput::MsgReportSDRPlayGains, Message)
MESSAGE_CLASS_DEFINITION(SDRPlayInput::MsgFileRecord, Message)
SDRPlayInput::SDRPlayInput(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
@ -41,11 +43,18 @@ SDRPlayInput::SDRPlayInput(DeviceSourceAPI *deviceAPI) :
m_running(false)
{
openDevice();
char recFileNameCStr[30];
sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID());
m_fileSink = new FileRecord(std::string(recFileNameCStr));
m_deviceAPI->addSink(m_fileSink);
}
SDRPlayInput::~SDRPlayInput()
{
if (m_running) stop();
m_deviceAPI->removeSink(m_fileSink);
delete m_fileSink;
closeDevice();
}
@ -226,6 +235,19 @@ bool SDRPlayInput::handleMessage(const Message& message)
return true;
}
else if (MsgFileRecord::match(message))
{
MsgFileRecord& conf = (MsgFileRecord&) message;
qDebug() << "SDRPlayInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
if (conf.getStartStop()) {
m_fileSink->startRecording();
} else {
m_fileSink->stopRecording();
}
return true;
}
else
{
return false;
@ -509,6 +531,7 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
int sampleRate = getSampleRate();
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
m_deviceAPI->getDeviceInputMessageQueue()->push(notif);
m_fileSink->handleMessage(*notif); // forward to file sink
}
return true;

View File

@ -26,6 +26,7 @@
class DeviceSourceAPI;
class SDRPlayThread;
class FileRecord;
class SDRPlayInput : public DeviceSampleSource {
public:
@ -78,6 +79,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)
{ }
};
SDRPlayInput(DeviceSourceAPI *deviceAPI);
virtual ~SDRPlayInput();
@ -104,6 +124,7 @@ private:
QString m_deviceDescription;
int m_devNumber;
bool m_running;
FileRecord *m_fileSink; //!< File sink to record device I/Q output
};
#endif /* PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_ */