mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-04-05 22:46:59 +00:00
Set up ring buffer overflow signalling and a little debugging.
This commit is contained in:
parent
dd17a47972
commit
d9b5f5753e
7 changed files with 45 additions and 6 deletions
18
SampleRB.cpp
18
SampleRB.cpp
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue