From 2bc59154bf1b2d47501a43cd36211c2509db2fe8 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 4 Nov 2018 18:56:57 +0100 Subject: [PATCH] SoapySDR support: output: fixed sample FIFO resizing --- devices/soapysdr/devicesoapysdrshared.cpp | 4 +++ devices/soapysdr/devicesoapysdrshared.h | 4 +++ .../soapysdroutput/soapysdroutput.cpp | 32 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/devices/soapysdr/devicesoapysdrshared.cpp b/devices/soapysdr/devicesoapysdrshared.cpp index bbfabd460..e7ef10f70 100644 --- a/devices/soapysdr/devicesoapysdrshared.cpp +++ b/devices/soapysdr/devicesoapysdrshared.cpp @@ -18,6 +18,10 @@ MESSAGE_CLASS_DEFINITION(DeviceSoapySDRShared::MsgReportBuddyChange, Message) +const float DeviceSoapySDRShared::m_sampleFifoLengthInSeconds = 0.25; +const int DeviceSoapySDRShared::m_sampleFifoMinSize = 75000; // 300 kS/s knee +const int DeviceSoapySDRShared::m_sampleFifoMinSize32 = 150000; // Fixed for interpolation by 32 + DeviceSoapySDRShared::DeviceSoapySDRShared() : m_device(0), m_channel(-1), diff --git a/devices/soapysdr/devicesoapysdrshared.h b/devices/soapysdr/devicesoapysdrshared.h index 36d54c2bc..85adc878a 100644 --- a/devices/soapysdr/devicesoapysdrshared.h +++ b/devices/soapysdr/devicesoapysdrshared.h @@ -87,6 +87,10 @@ public: int m_channel; //!< allocated channel (-1 if none) SoapySDRInput *m_source; SoapySDROutput *m_sink; + + static const float m_sampleFifoLengthInSeconds; + static const int m_sampleFifoMinSize; + static const int m_sampleFifoMinSize32; }; diff --git a/plugins/samplesink/soapysdroutput/soapysdroutput.cpp b/plugins/samplesink/soapysdroutput/soapysdroutput.cpp index 325cd09a3..447bb3c58 100644 --- a/plugins/samplesink/soapysdroutput/soapysdroutput.cpp +++ b/plugins/samplesink/soapysdroutput/soapysdroutput.cpp @@ -621,6 +621,38 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool xlatedDeviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0; xlatedDeviceCenterFrequency = xlatedDeviceCenterFrequency < 0 ? 0 : xlatedDeviceCenterFrequency; + // resize FIFO + if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || (m_settings.m_log2Interp != settings.m_log2Interp) || force) + { + SoapySDROutputThread *soapySDROutputThread = findThread(); + SampleSourceFifo *fifo = 0; + + if (soapySDROutputThread) + { + fifo = soapySDROutputThread->getFifo(requestedChannel); + soapySDROutputThread->setFifo(requestedChannel, 0); + } + + int fifoSize; + + if (settings.m_log2Interp >= 5) + { + fifoSize = DeviceSoapySDRShared::m_sampleFifoMinSize32; + } + else + { + fifoSize = std::max( + (int) ((settings.m_devSampleRate/(1<setFifo(requestedChannel, &m_sampleSourceFifo); + } + } + if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) { forwardChangeOwnDSP = true;