1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-27 07:16:48 -04:00

Sample source FIFO: limit read count to FIFO size

This commit is contained in:
f4exb 2019-11-17 03:16:10 +01:00
parent 55d43c2e03
commit 6533df15f5

View File

@ -62,7 +62,7 @@ void SampleSourceFifo::read(
{
QMutexLocker mutexLocker(&m_mutex);
unsigned int spaceLeft = m_size - m_readHead;
m_readCount += amount;
m_readCount = m_readCount + amount < m_size ? m_readCount + amount : m_size; // cannot exceed FIFO size
if (amount <= spaceLeft)
{
@ -125,7 +125,7 @@ void SampleSourceFifo::write(
m_writeHead = remaining;
}
m_readCount = amount < m_readCount ? m_readCount - amount : 0;
m_readCount = amount < m_readCount ? m_readCount - amount : 0; // cannot be less than 0
}
unsigned int SampleSourceFifo::getSizePolicy(unsigned int sampleRate)