mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-09-27 15:26:33 -04:00
Sample source FIFO: limit read count to FIFO size
This commit is contained in:
parent
55d43c2e03
commit
6533df15f5
@ -62,7 +62,7 @@ void SampleSourceFifo::read(
|
|||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
unsigned int spaceLeft = m_size - m_readHead;
|
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)
|
if (amount <= spaceLeft)
|
||||||
{
|
{
|
||||||
@ -125,7 +125,7 @@ void SampleSourceFifo::write(
|
|||||||
m_writeHead = remaining;
|
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)
|
unsigned int SampleSourceFifo::getSizePolicy(unsigned int sampleRate)
|
||||||
|
Loading…
Reference in New Issue
Block a user