1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

SDRdaemon plugin: Ensure a minimal size of the main buffer depending on frame size so that auto follow ups work fine

This commit is contained in:
f4exb 2016-03-20 12:59:55 +01:00
parent 0ffc02102e
commit b7a4c468fc
2 changed files with 13 additions and 1 deletions

View File

@ -27,6 +27,7 @@ const int SDRdaemonBuffer::m_udpPayloadSize = 512;
const int SDRdaemonBuffer::m_sampleSize = 2;
const int SDRdaemonBuffer::m_iqSampleSize = 2 * m_sampleSize;
const int SDRdaemonBuffer::m_rawBufferLengthSeconds = 8; // should be even
const int SDRdaemonBuffer::m_rawBufferMinNbFrames = 50;
SDRdaemonBuffer::SDRdaemonBuffer(uint32_t throttlems) :
m_throttlemsNominal(throttlems),
@ -95,6 +96,11 @@ void SDRdaemonBuffer::updateBufferSize(uint32_t sampleRate)
{
uint32_t rawSize = sampleRate * m_iqSampleSize * m_rawBufferLengthSeconds; // store worth of this seconds of samples at this sample rate
if ((m_frameSize > 0) && (rawSize / m_frameSize < m_rawBufferMinNbFrames))
{
rawSize = m_rawBufferMinNbFrames * m_frameSize; // ensure a minimal size of this times the write block size so that auto follow ups work fine
}
if (rawSize != m_rawSize)
{
m_rawSize = rawSize;
@ -109,6 +115,7 @@ void SDRdaemonBuffer::updateBufferSize(uint32_t sampleRate)
qDebug() << "SDRdaemonBuffer::updateBufferSize:"
<< " sampleRate: " << sampleRate
<< " m_frameSize: " << m_frameSize
<< " m_rawSize: " << m_rawSize;
}
}
@ -221,7 +228,11 @@ bool SDRdaemonBuffer::readMeta(char *array, uint32_t length)
m_lz4 = false;
}
m_frameSize = frameSize;
if (frameSize != m_frameSize) {
m_frameSize = frameSize;
updateBufferSize(m_sampleRate);
}
m_sync = true;
}
else

View File

@ -111,6 +111,7 @@ public:
static const int m_sampleSize;
static const int m_iqSampleSize;
static const int m_rawBufferLengthSeconds;
static const int m_rawBufferMinNbFrames; //!< Minimum number of frames for the length of buffer
private:
void updateBufferSize(uint32_t sampleRate);