mirror of
https://github.com/g4klx/MMDVM.git
synced 2026-08-21 14:36:21 +02:00
Set up ring buffer overflow signalling and a little debugging.
This commit is contained in:
+15
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user