mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-22 08:05:49 +08:00
Add extra logging and re-do the initial timer.
This commit is contained in:
@@ -35,7 +35,8 @@ m_stopWatch(),
|
|||||||
m_buffer(NULL),
|
m_buffer(NULL),
|
||||||
m_headSequenceNumber(0U),
|
m_headSequenceNumber(0U),
|
||||||
m_lastData(NULL),
|
m_lastData(NULL),
|
||||||
m_lastDataLength(0U)
|
m_lastDataLength(0U),
|
||||||
|
m_running(false)
|
||||||
{
|
{
|
||||||
assert(blockSize > 0U);
|
assert(blockSize > 0U);
|
||||||
assert(blockTime > 0U);
|
assert(blockTime > 0U);
|
||||||
@@ -98,7 +99,7 @@ bool CJitterBuffer::addData(const unsigned char* data, unsigned int length, unsi
|
|||||||
// Do we already have the data?
|
// Do we already have the data?
|
||||||
if (m_buffer[index].m_length > 0U) {
|
if (m_buffer[index].m_length > 0U) {
|
||||||
if (m_debug)
|
if (m_debug)
|
||||||
LogDebug("JitterBuffer: rejecting frame with seqNo=%u, already exists", sequenceNumber);
|
LogDebug("JitterBuffer: rejecting duplicate frame with seqNo=%u, raw=%u, head=%u, tail=%u", sequenceNumber, m_headSequenceNumber, headSequenceNumber, tailSequenceNumber);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,10 +116,8 @@ JB_STATUS CJitterBuffer::getData(unsigned char* data, unsigned int& length)
|
|||||||
{
|
{
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
|
||||||
if (!m_timer.isRunning() || !m_timer.hasExpired()) {
|
if (!m_running)
|
||||||
m_stopWatch.start();
|
|
||||||
return JBS_NO_DATA;
|
return JBS_NO_DATA;
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int sequenceNumber = m_stopWatch.elapsed() / m_blockTime;
|
unsigned int sequenceNumber = m_stopWatch.elapsed() / m_blockTime;
|
||||||
if (m_headSequenceNumber > sequenceNumber)
|
if (m_headSequenceNumber > sequenceNumber)
|
||||||
@@ -141,8 +140,8 @@ JB_STATUS CJitterBuffer::getData(unsigned char* data, unsigned int& length)
|
|||||||
return JBS_DATA;
|
return JBS_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_debug)
|
if (m_debug)
|
||||||
LogDebug("JitterBuffer: no data available, elapsed=%ums, raw=%u, head=%u", m_stopWatch.elapsed(), m_headSequenceNumber - 1U, head);
|
LogDebug("JitterBuffer: no data available, elapsed=%ums, raw=%u, head=%u", m_stopWatch.elapsed(), m_headSequenceNumber - 1U, head);
|
||||||
|
|
||||||
// Return the last data frame if we have it
|
// Return the last data frame if we have it
|
||||||
if (m_lastDataLength > 0U) {
|
if (m_lastDataLength > 0U) {
|
||||||
@@ -165,9 +164,17 @@ void CJitterBuffer::reset()
|
|||||||
m_lastDataLength = 0U;
|
m_lastDataLength = 0U;
|
||||||
|
|
||||||
m_timer.stop();
|
m_timer.stop();
|
||||||
|
|
||||||
|
m_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CJitterBuffer::clock(unsigned int ms)
|
void CJitterBuffer::clock(unsigned int ms)
|
||||||
{
|
{
|
||||||
m_timer.clock(ms);
|
m_timer.clock(ms);
|
||||||
|
if (m_timer.isRunning() && m_timer.hasExpired()) {
|
||||||
|
if (!m_running) {
|
||||||
|
m_stopWatch.start();
|
||||||
|
m_running = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ private:
|
|||||||
unsigned int m_blockCount;
|
unsigned int m_blockCount;
|
||||||
CTimer m_timer;
|
CTimer m_timer;
|
||||||
CStopWatch m_stopWatch;
|
CStopWatch m_stopWatch;
|
||||||
|
bool m_running;
|
||||||
|
|
||||||
struct JitterEntry
|
struct JitterEntry
|
||||||
{
|
{
|
||||||
unsigned char* m_data;
|
unsigned char* m_data;
|
||||||
|
|||||||
Reference in New Issue
Block a user