Skip to content

Commit

Permalink
[core] CRcvBufferNew::dropUpTo() able to drop non-empty units (#2221)
Browse files Browse the repository at this point in the history
Using fixed TSBPD timebase update (#2226) when dropping.
  • Loading branch information
gou4shi1 authored Jan 18, 2022
1 parent 31de8aa commit 24bf666
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions srtcore/buffer_rcv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,10 @@ int CRcvBufferNew::insert(CUnit* unit)

int CRcvBufferNew::dropUpTo(int32_t seqno)
{
// Can drop only when nothing to read, and
// first unacknowledged packet is missing.
SRT_ASSERT(m_iStartPos == m_iFirstNonreadPos);

IF_RCVBUF_DEBUG(ScopedLog scoped_log);
IF_RCVBUF_DEBUG(scoped_log.ss << "CRcvBufferNew::dropUpTo: seqno " << seqno << " m_iStartSeqNo " << m_iStartSeqNo);

int len = CSeqNo::seqoff(m_iStartSeqNo, seqno);
SRT_ASSERT(len > 0);
if (len <= 0)
{
IF_RCVBUF_DEBUG(scoped_log.ss << ". Nothing to drop.");
Expand All @@ -180,34 +175,26 @@ int CRcvBufferNew::dropUpTo(int32_t seqno)
if (m_iMaxPosInc < 0)
m_iMaxPosInc = 0;

// Check that all packets being dropped are missing.
const int iDropCnt = len;
while (len > 0)
{
if (m_entries[m_iStartPos].pUnit != NULL)
{
releaseUnitInPos(m_iStartPos);
}

if (m_entries[m_iStartPos].status != EntryState_Empty)
{
SRT_ASSERT(m_entries[m_iStartPos].status == EntryState_Drop || m_entries[m_iStartPos].status == EntryState_Read);
m_entries[m_iStartPos].status = EntryState_Empty;
}

dropUnitInPos(m_iStartPos);
m_entries[m_iStartPos].status = EntryState_Empty;
SRT_ASSERT(m_entries[m_iStartPos].pUnit == NULL && m_entries[m_iStartPos].status == EntryState_Empty);
m_iStartPos = incPos(m_iStartPos);
--len;
}

// Update positions
m_iStartSeqNo = seqno;
// Move forward if there are "read" entries.
// Move forward if there are "read/drop" entries.
releaseNextFillerEntries();
// Set nonread position to the starting position before updating,
// because start position was increased, and preceeding packets are invalid.
m_iFirstNonreadPos = m_iStartPos;
updateNonreadPos();
if (!m_tsbpd.isEnabled() && m_bMessageAPI)
updateFirstReadableOutOfOrder();
return iDropCnt;
}

Expand Down

0 comments on commit 24bf666

Please sign in to comment.