Skip to content

Commit

Permalink
Additional improvements for timespan
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Apr 12, 2021
1 parent 55c1d9a commit 6d92119
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions srtcore/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1743,15 +1743,21 @@ CRcvBuffer::ReadingState CRcvBuffer::debugGetReadingState() const
: m_iLastAckPos + (m_iSize - m_iStartPos);
}

// m_iLastAckPos points to the first unacknowledged packet
const int iLastAckPos = (m_iLastAckPos - 1) % m_iSize;
if (m_iLastAckPos != m_iStartPos && (NULL != m_pUnit[iLastAckPos]) && (m_pUnit[iLastAckPos]->m_iFlag == CUnit::GOOD))
{
if (m_bTsbPdMode)
readstate.tsFirstUnack = getPktTsbPdTimeNoWrap(m_pUnit[iLastAckPos]->m_Packet.getMsgTimeStamp());
readstate.tsLastAck = getPktTsbPdTimeNoWrap(m_pUnit[iLastAckPos]->m_Packet.getMsgTimeStamp());
}

const int iEndPos = (m_iLastAckPos + m_iMaxPos - 1) % m_iSize;
if (m_iMaxPos != 0 && (NULL != m_pUnit[iEndPos]) && (m_pUnit[iEndPos]->m_iFlag == CUnit::GOOD))
if (m_iMaxPos == 0)
{
if (m_bTsbPdMode)
readstate.tsEnd = readstate.tsLastAck;
}
else if ((NULL != m_pUnit[iEndPos]) && (m_pUnit[iEndPos]->m_iFlag == CUnit::GOOD))
{
if (m_bTsbPdMode)
readstate.tsEnd = getPktTsbPdTimeNoWrap(m_pUnit[iEndPos]->m_Packet.getMsgTimeStamp());
Expand Down
2 changes: 1 addition & 1 deletion srtcore/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class CRcvBuffer
struct ReadingState
{
time_point tsStart;
time_point tsFirstUnack;
time_point tsLastAck;
time_point tsEnd;
int numAcknowledged;
int numUnacknowledged;
Expand Down
4 changes: 2 additions & 2 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9449,11 +9449,11 @@ int CUDT::processData(CUnit* in_unit)


ss << "Packets ACKed: " << bufstate.numAcknowledged << " (TSBPD ready in ";
if (!is_zero(bufstate.tsStart) && !is_zero(bufstate.tsFirstUnack))
if (!is_zero(bufstate.tsStart) && !is_zero(bufstate.tsLastAck))
{
ss << count_milliseconds(bufstate.tsStart - curtime);
ss << " : ";
ss << count_milliseconds(bufstate.tsFirstUnack - curtime);
ss << count_milliseconds(bufstate.tsLastAck - curtime);
ss << " ms)";
}
else
Expand Down

0 comments on commit 6d92119

Please sign in to comment.