Set up ring buffer overflow signalling and a little debugging.

This commit is contained in:
Jonathan Naylor 2016-01-14 19:15:39 +00:00
parent dd17a47972
commit d9b5f5753e
7 changed files with 45 additions and 6 deletions

View file

@ -27,7 +27,8 @@ m_samples(NULL),
m_control(NULL),
m_head(0U),
m_tail(0U),
m_full(false)
m_full(false),
m_overflow(false)
{
m_samples = new uint16_t[length];
m_control = new uint8_t[length];
@ -65,8 +66,10 @@ void CSampleRB::put(uint16_t sample, uint8_t control)
if (m_head >= m_length)
m_head = 0U;
if (m_head == m_tail)
m_full = true;
if (m_head == m_tail) {
m_overflow = true;
m_full = true;
}
}
void CSampleRB::get(uint16_t& sample, uint8_t& control)
@ -81,3 +84,12 @@ void CSampleRB::get(uint16_t& sample, uint8_t& control)
m_tail = 0U;
}
bool CSampleRB::hasOverflowed()
{
bool overflow = m_overflow;
m_overflow = false;
return overflow;
}