mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 17:58:43 -05:00
SDRdaemon plugin: attempt to fix the skew rate calculation
This commit is contained in:
parent
d5f65a7e39
commit
87a53f03a2
@ -60,7 +60,8 @@ SDRdaemonBuffer::SDRdaemonBuffer(uint32_t throttlems) :
|
||||
m_skewTest(false),
|
||||
m_skewCorrection(false),
|
||||
m_readCount(0),
|
||||
m_writeCount(0)
|
||||
m_writeCount(0),
|
||||
m_nbCycles(0)
|
||||
{
|
||||
m_currentMeta.init();
|
||||
}
|
||||
@ -180,8 +181,8 @@ bool SDRdaemonBuffer::readMeta(char *array, uint32_t length)
|
||||
{
|
||||
if (m_skewCorrection)
|
||||
{
|
||||
uint64_t newRate = (m_sampleRate * m_writeCount) / (m_readCount * m_iqSampleSize);
|
||||
m_sampleRate = newRate * m_iqSampleSize; // ensure it is a multiple of the I/Q sample size
|
||||
int64_t deltaRate = (m_writeCount - m_readCount) / (m_nbCycles * m_rawBufferLengthSeconds * m_iqSampleSize);
|
||||
m_sampleRate = ((m_sampleRate + deltaRate) / m_iqSampleSize) * m_iqSampleSize; // ensure it is a multiple of the I/Q sample size
|
||||
resetIndexes();
|
||||
}
|
||||
}
|
||||
@ -243,6 +244,7 @@ uint8_t *SDRdaemonBuffer::readData(int32_t length)
|
||||
{
|
||||
int dIndex = (m_readIndex - m_writeIndex > 0 ? m_readIndex - m_writeIndex : m_writeIndex - m_readIndex); // absolute delta
|
||||
m_skewCorrection = (dIndex < m_rawSize / 10); // close by 10%
|
||||
m_nbCycles++;
|
||||
m_skewTest = false;
|
||||
}
|
||||
|
||||
@ -367,6 +369,7 @@ void SDRdaemonBuffer::resetIndexes()
|
||||
m_readIndex = m_rawSize / 2;
|
||||
m_readCount = 0;
|
||||
m_writeCount = 0;
|
||||
m_nbCycles = 0;
|
||||
m_skewTest = false;
|
||||
m_skewCorrection = false;
|
||||
}
|
||||
|
@ -132,8 +132,9 @@ private:
|
||||
bool m_autoFollowRate; //!< Auto follow stream sample rate else stick with meta data sample rate
|
||||
bool m_skewTest;
|
||||
bool m_skewCorrection; //!< Do a skew rate correction at next meta data reception
|
||||
uint64_t m_readCount;
|
||||
uint64_t m_writeCount;
|
||||
int64_t m_readCount;
|
||||
int64_t m_writeCount;
|
||||
uint32_t m_nbCycles; //!< Number of buffer cycles since start of byte counting
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user