mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-30 03:38:55 -05:00
SDRdaemon plugin: set the r/w buffer maximum correction limit to +/- 20 ms
This commit is contained in:
parent
b14ae1e7c1
commit
bfdcac70d0
@ -64,7 +64,9 @@ SDRdaemonBuffer::SDRdaemonBuffer(uint32_t throttlems) :
|
||||
m_readCount(0),
|
||||
m_writeCount(0),
|
||||
m_nbCycles(0),
|
||||
m_nbReads(0)
|
||||
m_nbReads(0),
|
||||
m_balCorrection(0),
|
||||
m_balCorrLimit(0)
|
||||
{
|
||||
m_currentMeta.init();
|
||||
}
|
||||
@ -95,6 +97,7 @@ void SDRdaemonBuffer::updateBufferSize(uint32_t sampleRate)
|
||||
if (rawSize != m_rawSize)
|
||||
{
|
||||
m_rawSize = rawSize;
|
||||
m_balCorrLimit = sampleRate / 50; // +/- 20 ms correction max per read
|
||||
|
||||
if (m_rawBuffer) {
|
||||
delete[] m_rawBuffer;
|
||||
@ -269,15 +272,14 @@ uint8_t *SDRdaemonBuffer::readData(int32_t length)
|
||||
}
|
||||
|
||||
m_balCorrection += dBytes / (int32_t) (m_nbReads * m_iqSampleSize); // correction is in number of samples
|
||||
int32_t limit = (int32_t) m_rawSize / (int32_t) (5 * m_rawBufferLengthSeconds * m_iqSampleSize);
|
||||
int32_t corrLimit = (int32_t) m_rawSize / (int32_t) (10 * m_rawBufferLengthSeconds * m_iqSampleSize);
|
||||
|
||||
if (m_balCorrection < -limit) {
|
||||
m_balCorrection = -limit;
|
||||
} else if (m_balCorrection > limit) {
|
||||
m_balCorrection = limit;
|
||||
if (m_balCorrection < -m_balCorrLimit) {
|
||||
m_balCorrection = -m_balCorrLimit;
|
||||
} else if (m_balCorrection > m_balCorrLimit) {
|
||||
m_balCorrection = m_balCorrLimit;
|
||||
}
|
||||
|
||||
|
||||
m_nbReads = 0;
|
||||
}
|
||||
else
|
||||
|
@ -168,6 +168,7 @@ private:
|
||||
|
||||
uint32_t m_nbReads; //!< Number of buffer reads since start of auto R/W balance correction period
|
||||
int32_t m_balCorrection; //!< R/W balance correction in number of samples
|
||||
int32_t m_balCorrLimit; //!< Correction absolute value limit in number of samples
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user