Sample source FIFO: limit read count to FIFO size

pull/442/head
f4exb 2019-11-17 03:16:10 +01:00
rodzic 55d43c2e03
commit 6533df15f5
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -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)