mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-23 00:18:37 -05:00
HackRF input: moved FileRecord out of the GUI
This commit is contained in:
parent
fc303cc218
commit
9da26ad8b3
@ -23,6 +23,7 @@
|
||||
#include "util/simpleserializer.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "dsp/filerecord.h"
|
||||
#include "device/devicesourceapi.h"
|
||||
#include "device/devicesinkapi.h"
|
||||
#include "hackrf/devicehackrfvalues.h"
|
||||
@ -33,6 +34,7 @@
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(HackRFInput::MsgConfigureHackRF, Message)
|
||||
MESSAGE_CLASS_DEFINITION(HackRFInput::MsgReportHackRF, Message)
|
||||
MESSAGE_CLASS_DEFINITION(HackRFInput::MsgFileRecord, Message)
|
||||
|
||||
HackRFInput::HackRFInput(DeviceSourceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
@ -43,12 +45,20 @@ HackRFInput::HackRFInput(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);
|
||||
|
||||
m_deviceAPI->setBuddySharedPtr(&m_sharedParams);
|
||||
}
|
||||
|
||||
HackRFInput::~HackRFInput()
|
||||
{
|
||||
if (m_running) stop();
|
||||
m_deviceAPI->removeSink(m_fileSink);
|
||||
delete m_fileSink;
|
||||
closeDevice();
|
||||
m_deviceAPI->setBuddySharedPtr(0);
|
||||
}
|
||||
@ -195,6 +205,19 @@ bool HackRFInput::handleMessage(const Message& message)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgFileRecord::match(message))
|
||||
{
|
||||
MsgFileRecord& conf = (MsgFileRecord&) message;
|
||||
qDebug() << "HackRFInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
|
||||
|
||||
if (conf.getStartStop()) {
|
||||
m_fileSink->startRecording();
|
||||
} else {
|
||||
m_fileSink->stopRecording();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
@ -441,6 +464,7 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
|
||||
int sampleRate = devSampleRate/(1<<m_settings.m_log2Decim);
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
|
||||
m_deviceAPI->getDeviceInputMessageQueue()->push(notif);
|
||||
m_fileSink->handleMessage(*notif); // forward to file sink
|
||||
}
|
||||
|
||||
m_settings.m_linkTxFrequency = settings.m_linkTxFrequency;
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
class DeviceSourceAPI;
|
||||
class HackRFInputThread;
|
||||
class FileRecord;
|
||||
|
||||
class HackRFInput : public DeviceSampleSource {
|
||||
public:
|
||||
@ -71,6 +72,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)
|
||||
{ }
|
||||
};
|
||||
|
||||
HackRFInput(DeviceSourceAPI *deviceAPI);
|
||||
virtual ~HackRFInput();
|
||||
|
||||
@ -98,6 +118,7 @@ private:
|
||||
QString m_deviceDescription;
|
||||
DeviceHackRFParams m_sharedParams;
|
||||
bool m_running;
|
||||
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
||||
};
|
||||
|
||||
#endif // INCLUDE_HACKRFINPUT_H
|
||||
|
@ -14,7 +14,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../hackrfinput/hackrfinputgui.h"
|
||||
#include "hackrfinputgui.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
@ -27,7 +27,6 @@
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "device/devicesourceapi.h"
|
||||
#include "device/devicesinkapi.h"
|
||||
#include "dsp/filerecord.h"
|
||||
#include "hackrf/devicehackrfvalues.h"
|
||||
|
||||
#include "ui_hackrfinputgui.h"
|
||||
@ -58,11 +57,6 @@ HackRFInputGui::HackRFInputGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
|
||||
displaySettings();
|
||||
displayBandwidths();
|
||||
|
||||
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);
|
||||
|
||||
sendSettings();
|
||||
@ -70,8 +64,6 @@ HackRFInputGui::HackRFInputGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
|
||||
|
||||
HackRFInputGui::~HackRFInputGui()
|
||||
{
|
||||
m_deviceAPI->removeSink(m_fileSink);
|
||||
delete m_fileSink;
|
||||
delete m_sampleSource; // Valgrind memcheck
|
||||
delete ui;
|
||||
}
|
||||
@ -159,7 +151,6 @@ void HackRFInputGui::handleDSPMessages()
|
||||
m_deviceCenterFrequency = notif->getCenterFrequency();
|
||||
qDebug("HackRFGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
||||
updateSampleRateAndFrequency();
|
||||
m_fileSink->handleMessage(*notif); // forward to file sink
|
||||
|
||||
delete message;
|
||||
}
|
||||
@ -355,16 +346,14 @@ void HackRFInputGui::on_startStop_toggled(bool checked)
|
||||
|
||||
void HackRFInputGui::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();
|
||||
}
|
||||
|
||||
HackRFInput::MsgFileRecord* message = HackRFInput::MsgFileRecord::create(checked);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void HackRFInputGui::updateHardware()
|
||||
|
@ -21,12 +21,11 @@
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
#include "../hackrfinput/hackrfinput.h"
|
||||
#include "hackrfinput.h"
|
||||
|
||||
#define HACKRF_MAX_DEVICE (32)
|
||||
|
||||
class DeviceSourceAPI;
|
||||
class FileRecord;
|
||||
|
||||
namespace Ui {
|
||||
class HackRFInputGui;
|
||||
@ -67,7 +66,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;
|
||||
|
Loading…
Reference in New Issue
Block a user