1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-08-15 20:22:26 -04:00

BladeRF input: moved FileRecord out of the GUI

This commit is contained in:
f4exb 2017-09-04 22:45:07 +02:00
parent f6058d2b12
commit 8e9305c262
5 changed files with 51 additions and 19 deletions

View File

@ -232,7 +232,7 @@ bool AirspyInput::handleMessage(const Message& message)
else if (MsgFileRecord::match(message)) else if (MsgFileRecord::match(message))
{ {
MsgFileRecord& conf = (MsgFileRecord&) message; MsgFileRecord& conf = (MsgFileRecord&) message;
qDebug() << "RTLSDRInput::handleMessage: MsgFileRecord: " << conf.getStartStop(); qDebug() << "AirspyInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
if (conf.getStartStop()) { if (conf.getStartStop()) {
m_fileSink->startRecording(); m_fileSink->startRecording();

View File

@ -23,6 +23,7 @@
#include "util/simpleserializer.h" #include "util/simpleserializer.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/filerecord.h"
#include "device/devicesourceapi.h" #include "device/devicesourceapi.h"
#include "device/devicesinkapi.h" #include "device/devicesinkapi.h"
@ -30,6 +31,7 @@
#include "bladerfinputthread.h" #include "bladerfinputthread.h"
MESSAGE_CLASS_DEFINITION(BladerfInput::MsgConfigureBladerf, Message) MESSAGE_CLASS_DEFINITION(BladerfInput::MsgConfigureBladerf, Message)
MESSAGE_CLASS_DEFINITION(BladerfInput::MsgFileRecord, Message)
BladerfInput::BladerfInput(DeviceSourceAPI *deviceAPI) : BladerfInput::BladerfInput(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI), m_deviceAPI(deviceAPI),
@ -40,12 +42,20 @@ BladerfInput::BladerfInput(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);
m_deviceAPI->setBuddySharedPtr(&m_sharedParams); m_deviceAPI->setBuddySharedPtr(&m_sharedParams);
} }
BladerfInput::~BladerfInput() BladerfInput::~BladerfInput()
{ {
if (m_running) stop(); if (m_running) stop();
m_deviceAPI->removeSink(m_fileSink);
delete m_fileSink;
closeDevice(); closeDevice();
m_deviceAPI->setBuddySharedPtr(0); m_deviceAPI->setBuddySharedPtr(0);
} }
@ -213,6 +223,19 @@ bool BladerfInput::handleMessage(const Message& message)
return true; return true;
} }
else if (MsgFileRecord::match(message))
{
MsgFileRecord& conf = (MsgFileRecord&) message;
qDebug() << "BladerfInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
if (conf.getStartStop()) {
m_fileSink->startRecording();
} else {
m_fileSink->stopRecording();
}
return true;
}
else else
{ {
return false; return false;
@ -487,6 +510,7 @@ bool BladerfInput::applySettings(const BladeRFInputSettings& settings, bool forc
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
} }
qDebug() << "BladerfInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz" qDebug() << "BladerfInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz"

View File

@ -28,6 +28,7 @@
class DeviceSourceAPI; class DeviceSourceAPI;
class BladerfInputThread; class BladerfInputThread;
class FileRecord;
class BladerfInput : public DeviceSampleSource { class BladerfInput : public DeviceSampleSource {
public: public:
@ -51,6 +52,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)
{ }
};
BladerfInput(DeviceSourceAPI *deviceAPI); BladerfInput(DeviceSourceAPI *deviceAPI);
virtual ~BladerfInput(); virtual ~BladerfInput();
@ -78,6 +98,7 @@ private:
QString m_deviceDescription; QString m_deviceDescription;
DeviceBladeRFParams m_sharedParams; DeviceBladeRFParams m_sharedParams;
bool m_running; bool m_running;
FileRecord *m_fileSink; //!< File sink to record device I/Q output
}; };
#endif // INCLUDE_BLADERFINPUT_H #endif // INCLUDE_BLADERFINPUT_H

View File

@ -27,7 +27,6 @@
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include <device/devicesourceapi.h> #include <device/devicesourceapi.h>
#include <dsp/filerecord.h>
BladerfInputGui::BladerfInputGui(DeviceSourceAPI *deviceAPI, QWidget* parent) : BladerfInputGui::BladerfInputGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
QWidget(parent), QWidget(parent),
@ -61,18 +60,11 @@ BladerfInputGui::BladerfInputGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
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);
} }
BladerfInputGui::~BladerfInputGui() BladerfInputGui::~BladerfInputGui()
{ {
m_deviceAPI->removeSink(m_fileSink);
delete m_fileSink;
delete m_sampleSource; // Valgrind memcheck delete m_sampleSource; // Valgrind memcheck
delete ui; delete ui;
} }
@ -148,7 +140,6 @@ void BladerfInputGui::handleDSPMessages()
m_deviceCenterFrequency = notif->getCenterFrequency(); m_deviceCenterFrequency = notif->getCenterFrequency();
qDebug("BladerfGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); qDebug("BladerfGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
updateSampleRateAndFrequency(); updateSampleRateAndFrequency();
m_fileSink->handleMessage(*notif); // forward to file sink
delete message; delete message;
} }
@ -357,16 +348,14 @@ void BladerfInputGui::on_startStop_toggled(bool checked)
void BladerfInputGui::on_record_toggled(bool checked) void BladerfInputGui::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();
} }
BladerfInput::MsgFileRecord* message = BladerfInput::MsgFileRecord::create(checked);
m_sampleSource->getInputMessageQueue()->push(message);
} }
void BladerfInputGui::updateHardware() void BladerfInputGui::updateHardware()

View File

@ -24,7 +24,6 @@
#include "bladerfinput.h" #include "bladerfinput.h"
class DeviceSourceAPI; class DeviceSourceAPI;
class FileRecord;
namespace Ui { namespace Ui {
class BladerfInputGui; class BladerfInputGui;
@ -57,7 +56,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;