1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-11 18:28:43 -04:00

FileRecordInterface: true dynamic allocation

This commit is contained in:
f4exb
2020-05-30 21:21:51 +02:00
parent e5db77a6e0
commit 22a886fba9
17 changed files with 452 additions and 159 deletions
@@ -44,7 +44,7 @@ MESSAGE_CLASS_DEFINITION(PlutoSDRInput::MsgStartStop, Message)
PlutoSDRInput::PlutoSDRInput(DeviceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_fileSink(0),
m_fileSink(nullptr),
m_deviceDescription("PlutoSDRInput"),
m_running(false),
m_plutoRxBuffer(0),
@@ -66,9 +66,7 @@ PlutoSDRInput::PlutoSDRInput(DeviceAPI *deviceAPI) :
resumeBuddies();
m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
m_deviceAPI->setNbSourceStreams(1);
m_deviceAPI->addAncillarySink(m_fileSink);
m_networkManager = new QNetworkAccessManager();
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
@@ -78,8 +76,13 @@ PlutoSDRInput::~PlutoSDRInput()
{
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
delete m_networkManager;
m_deviceAPI->removeAncillarySink(m_fileSink);
delete m_fileSink;
if (m_fileSink)
{
m_deviceAPI->removeAncillarySink(m_fileSink);
delete m_fileSink;
}
suspendBuddies();
closeDevice();
resumeBuddies();
@@ -213,17 +216,27 @@ bool PlutoSDRInput::handleMessage(const Message& message)
if (conf.getStartStop())
{
if (m_settings.m_fileRecordName.size() != 0) {
m_fileSink->setFileName(m_settings.m_fileRecordName);
} else {
m_fileSink->setFileName(FileRecordInterface::genUniqueFileName(m_deviceAPI->getDeviceUID()));
if (m_fileSink)
{
m_deviceAPI->removeAncillarySink(m_fileSink);
delete m_fileSink;
}
if (m_settings.m_fileRecordName.size() != 0) {
m_fileSink = new FileRecord(m_settings.m_fileRecordName);
} else {
m_fileSink = new FileRecord(FileRecordInterface::genUniqueFileName(m_deviceAPI->getDeviceUID()));
}
m_deviceAPI->addAncillarySink(m_fileSink);
m_fileSink->startRecording();
}
else
{
m_fileSink->stopRecording();
m_deviceAPI->removeAncillarySink(m_fileSink);
delete m_fileSink;
m_fileSink = nullptr;
}
return true;
@@ -748,7 +761,11 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
int sampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Decim);
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
m_fileSink->handleMessage(*notif); // forward to file sink
if (m_fileSink) {
m_fileSink->handleMessage(*notif); // forward to file sink
}
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
}