Skip to content

Commit

Permalink
[core] Add CRcvBufferNew::dropUnitInPos(..) (#2226)
Browse files Browse the repository at this point in the history
to simplify dropUpTo(..) and dropMessage(..)
  • Loading branch information
gou4shi1 committed Jan 17, 2022
1 parent 2aa90bb commit 31de8aa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions srtcore/buffer_rcv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,24 @@ void CRcvBufferNew::releaseUnitInPos(int pos)
m_pUnitQueue->makeUnitFree(tmp);
}

bool CRcvBufferNew::dropUnitInPos(int pos)
{
if (!m_entries[pos].pUnit)
return false;
if (m_tsbpd.isEnabled())
{
updateTsbPdTimeBase(m_entries[pos].pUnit->m_Packet.getMsgTimeStamp());
}
else if (m_bMessageAPI && !m_entries[pos].pUnit->m_Packet.getMsgOrderFlag())
{
--m_numOutOfOrderPackets;
if (pos == m_iFirstReadableOutOfOrder)
m_iFirstReadableOutOfOrder = -1;
}
releaseUnitInPos(pos);
return true;
}

void CRcvBufferNew::releaseNextFillerEntries()
{
int pos = m_iStartPos;
Expand Down
5 changes: 5 additions & 0 deletions srtcore/buffer_rcv.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ class CRcvBufferNew
void updateNonreadPos();
void releaseUnitInPos(int pos);

/// @brief Drop a unit from the buffer.
/// @param pos position in the m_entries of the unit to drop.
/// @return false if nothing to drop, true if the unit was dropped successfully.
bool dropUnitInPos(int pos);

/// Release entries following the current buffer position if they were already
/// read out of order (EntryState_Read) or dropped (EntryState_Drop).
void releaseNextFillerEntries();
Expand Down

0 comments on commit 31de8aa

Please sign in to comment.