mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-30 13:52:25 -04:00
SDRdaemon plugin: fix auto read/write balance correction
This commit is contained in:
parent
8b22d2cbbc
commit
1c0ef544d3
@ -64,9 +64,7 @@ SDRdaemonBuffer::SDRdaemonBuffer(uint32_t throttlems) :
|
|||||||
m_readCount(0),
|
m_readCount(0),
|
||||||
m_writeCount(0),
|
m_writeCount(0),
|
||||||
m_nbCycles(0),
|
m_nbCycles(0),
|
||||||
m_readCountBal(0),
|
m_nbReads(0)
|
||||||
m_writeCountBal(0),
|
|
||||||
m_nbReadsBal(0)
|
|
||||||
{
|
{
|
||||||
m_currentMeta.init();
|
m_currentMeta.init();
|
||||||
}
|
}
|
||||||
@ -260,13 +258,18 @@ uint8_t *SDRdaemonBuffer::readData(int32_t length)
|
|||||||
m_skewCorrection = (dIndex < m_rawSize / 10); // close by 10%
|
m_skewCorrection = (dIndex < m_rawSize / 10); // close by 10%
|
||||||
m_nbCycles++;
|
m_nbCycles++;
|
||||||
// auto R/W balance calculation
|
// auto R/W balance calculation
|
||||||
if (m_nbReadsBal && m_autoCorrBuffer)
|
if (m_nbReads && m_autoCorrBuffer)
|
||||||
{
|
{
|
||||||
int32_t dBytes = (m_writeCountBal - m_readCountBal) / m_nbReadsBal;
|
int32_t dBytes;
|
||||||
m_balCorrection += dBytes / (int32_t) m_iqSampleSize;
|
|
||||||
m_readCountBal = 0;
|
if (m_readIndex > m_writeIndex) { // write leads
|
||||||
m_writeCountBal = 0;
|
dBytes = m_writeIndex; // positive from start of buffer
|
||||||
m_nbReadsBal = 0;
|
} else { // read leads
|
||||||
|
dBytes = m_writeIndex - (int32_t) m_rawSize; // negative from end of buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
m_balCorrection += dBytes / (int32_t) (m_nbReads * m_iqSampleSize); // correction is in number of samples
|
||||||
|
m_nbReads = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -277,8 +280,7 @@ uint8_t *SDRdaemonBuffer::readData(int32_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_readCount += length;
|
m_readCount += length;
|
||||||
m_readCountBal += length;
|
m_nbReads++;
|
||||||
m_nbReadsBal++;
|
|
||||||
|
|
||||||
if (m_readIndex + length < m_rawSize)
|
if (m_readIndex + length < m_rawSize)
|
||||||
{
|
{
|
||||||
@ -389,7 +391,6 @@ void SDRdaemonBuffer::writeToRawBufferUncompressed(const char *array, uint32_t l
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_writeCount += length;
|
m_writeCount += length;
|
||||||
m_writeCountBal += length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRdaemonBuffer::resetIndexes()
|
void SDRdaemonBuffer::resetIndexes()
|
||||||
@ -401,9 +402,7 @@ void SDRdaemonBuffer::resetIndexes()
|
|||||||
m_nbCycles = 0;
|
m_nbCycles = 0;
|
||||||
m_skewTest = false;
|
m_skewTest = false;
|
||||||
m_skewCorrection = false;
|
m_skewCorrection = false;
|
||||||
m_readCountBal = 0;
|
m_nbReads = 0;
|
||||||
m_writeCountBal = 0;
|
|
||||||
m_nbReadsBal = 0;
|
|
||||||
m_balCorrection = 0;
|
m_balCorrection = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,9 +166,7 @@ private:
|
|||||||
int64_t m_writeCount; //!< Number of bytes written for auto skew compensation
|
int64_t m_writeCount; //!< Number of bytes written for auto skew compensation
|
||||||
uint32_t m_nbCycles; //!< Number of buffer cycles since start of auto skew compensation byte counting
|
uint32_t m_nbCycles; //!< Number of buffer cycles since start of auto skew compensation byte counting
|
||||||
|
|
||||||
int64_t m_readCountBal; //!< Number of bytes read for auto R/W balance
|
uint32_t m_nbReads; //!< Number of buffer reads since start of auto R/W balance correction period
|
||||||
int64_t m_writeCountBal; //!< Number of bytes written for auto R/W balance
|
|
||||||
uint32_t m_nbReadsBal; //!< Number of buffer reads since start of auto R/W balance byte counting
|
|
||||||
int32_t m_balCorrection; //!< R/W balance correction in number of samples
|
int32_t m_balCorrection; //!< R/W balance correction in number of samples
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user