Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] add CRcvBufferNew::dropUnitInPos() to simplify dropUpTo() and dropMessage() #2226

Merged
merged 4 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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