SoapySDR support: output: fixed sample FIFO resizing

This commit is contained in:
f4exb 2018-11-04 18:56:57 +01:00
parent 564a99d14e
commit 2bc59154bf
3 changed files with 40 additions and 0 deletions

View File

@ -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),

View File

@ -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;
};

View File

@ -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<<settings.m_log2Interp)) * DeviceSoapySDRShared::m_sampleFifoLengthInSeconds),
DeviceSoapySDRShared::m_sampleFifoMinSize);
}
m_sampleSourceFifo.resize(fifoSize);
if (fifo) {
soapySDROutputThread->setFifo(requestedChannel, &m_sampleSourceFifo);
}
}
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
{
forwardChangeOwnDSP = true;