From 802749afd33c6ed67d92d7d7260fa6da24098c98 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Mon, 8 Mar 2021 21:41:46 +0000 Subject: [PATCH 1/3] Check sample rate is non-zero to avoid divide by zero --- plugins/samplesource/fileinput/fileinput.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/samplesource/fileinput/fileinput.cpp b/plugins/samplesource/fileinput/fileinput.cpp index 4d8988f52..fc05306a0 100644 --- a/plugins/samplesource/fileinput/fileinput.cpp +++ b/plugins/samplesource/fileinput/fileinput.cpp @@ -110,16 +110,21 @@ void FileInput::openFileStream() m_sampleSize = header.sampleSize; QString crcHex = QString("%1").arg(header.crc32 , 0, 16); - if (crcOK) + if (crcOK && (m_sampleRate > 0) && (m_sampleSize > 0)) { qDebug("FileInput::openFileStream: CRC32 OK for header: %s", qPrintable(crcHex)); m_recordLengthMuSec = ((fileSize - sizeof(FileRecord::Header)) * 1000000UL) / ((m_sampleSize == 24 ? 8 : 4) * m_sampleRate); } - else + else if (!crcOK) { qCritical("FileInput::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex)); m_recordLengthMuSec = 0; } + else + { + qCritical("FileInput::openFileStream: invalid header"); + m_recordLengthMuSec = 0; + } if (getMessageQueueToGUI()) { From f6b3512951e8a34092ed77717b1f0c895015db8c Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Mon, 8 Mar 2021 22:10:43 +0000 Subject: [PATCH 2/3] Add delay of 1s before starting file sinks, to give time for DSPnotification to be processed in filerecord --- .../satellitetrackerworker.cpp | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/plugins/feature/satellitetracker/satellitetrackerworker.cpp b/plugins/feature/satellitetracker/satellitetrackerworker.cpp index 7bfaf56e5..193e4fbe0 100644 --- a/plugins/feature/satellitetracker/satellitetrackerworker.cpp +++ b/plugins/feature/satellitetracker/satellitetrackerworker.cpp @@ -631,19 +631,6 @@ void SatelliteTrackerWorker::applyDeviceAOSSettings(const QString& name) } } - for (int i = 0; i < m_deviceSettingsList->size(); i++) - { - SatelliteTrackerSettings::SatelliteDeviceSettings *devSettings = m_deviceSettingsList->at(i); - - // Start file sinks (See issue #782 - currently must occur after starting acqusition) - if (devSettings->m_startStopFileSink) - { - qDebug() << "SatelliteTrackerWorker::aos: starting file sinks"; - int deviceSetIndex = devSettings->m_deviceSet.mid(1).toInt(); - ChannelWebAPIUtils::startStopFileSinks(deviceSetIndex, true); - } - } - // Send AOS message to channels SatWorkerState *satWorkerState = m_workerState.value(name); ChannelWebAPIUtils::satelliteAOS(name, satWorkerState->m_satState.m_passes[0]->m_northToSouth); @@ -682,6 +669,23 @@ void SatelliteTrackerWorker::applyDeviceAOSSettings(const QString& name) doppler(satWorkerState); }); } + + // Start file sinks (need a little delay to ensure sample rate message has been handled in filerecord) + QTimer::singleShot(1000, [this, m_deviceSettingsList]() + { + for (int i = 0; i < m_deviceSettingsList->size(); i++) + { + SatelliteTrackerSettings::SatelliteDeviceSettings *devSettings = m_deviceSettingsList->at(i); + + if (devSettings->m_startStopFileSink) + { + qDebug() << "SatelliteTrackerWorker::aos: starting file sinks"; + int deviceSetIndex = devSettings->m_deviceSet.mid(1).toInt(); + ChannelWebAPIUtils::startStopFileSinks(deviceSetIndex, true); + } + } + }); + }); } else From 1197e43c473cfd54e74dea4dd651f1e1924fdff6 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Mon, 8 Mar 2021 22:41:00 +0000 Subject: [PATCH 3/3] Add mutex to atomize start and setting of sample rate --- sdrbase/dsp/filerecord.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sdrbase/dsp/filerecord.cpp b/sdrbase/dsp/filerecord.cpp index 0b019d6f8..3e149ea8d 100644 --- a/sdrbase/dsp/filerecord.cpp +++ b/sdrbase/dsp/filerecord.cpp @@ -156,6 +156,7 @@ bool FileRecord::handleMessage(const Message& message) { if (DSPSignalNotification::match(message)) { + QMutexLocker mutexLocker(&m_mutex); DSPSignalNotification& notif = (DSPSignalNotification&) message; quint32 sampleRate = notif.getSampleRate(); qint64 centerFrequency = notif.getCenterFrequency();