diff --git a/srtcore/buffer_rcv.cpp b/srtcore/buffer_rcv.cpp index a323360bb..d790345a6 100644 --- a/srtcore/buffer_rcv.cpp +++ b/srtcore/buffer_rcv.cpp @@ -435,6 +435,20 @@ void CRcvBuffer::updateGapInfo() m_iDropOff = 0; if (m_iEndOff < m_iMaxPosOff) { + CPos start = incPos(m_iStartPos, m_iEndOff + 1), + end = incPos(m_iStartPos, m_iEndOff); + + for (CPos i = start; i != end; i = incPos(i)) + { + if (m_entries[i].status == EntryState_Avail) + { + m_iDropOff = offPos(m_iStartPos, i); + break; + } + } + + /* OPTIMIZED, but buggy. + int maxend = m_szSize - m_iStartPos VALUE; int ifrom = m_iEndOff + 1; int ito = m_iMaxPosOff VALUE; @@ -463,6 +477,7 @@ void CRcvBuffer::updateGapInfo() } } } + */ // Must be found somewhere, worst case at the position // of m_iMaxPosOff-1. If no finding loop caught it somehow, diff --git a/srtcore/buffer_rcv.h b/srtcore/buffer_rcv.h index 7ad000b69..325245194 100644 --- a/srtcore/buffer_rcv.h +++ b/srtcore/buffer_rcv.h @@ -208,14 +208,14 @@ const int CPos_TRAP = -1; // NOTE: in scrap region, the first cell is empty and the last one filled. // SPARE REGION: Region without packets // -// | BUSY REGION | -// | | | | -// | ICR | SCRAP REGION | SPARE REGION...-> -// ......->| | | | -// | FIRST-GAP | | +// | BUSY REGION | +// | | | | +// | ICR | SCRAP REGION | SPARE REGION...-> +// ......->| | | | +// | /FIRST-GAP | | // |<------------------- m_szSize ---------------------------->| // | |<------------ m_iMaxPosOff ----------->| | -// | | | | | | +// | | | | | | // +---+---+---+---+---+---+---+---+---+---+---+---+---+ +---+ // | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 0 |...| 0 | m_pUnit[] // +---+---+---+---+---+---+---+---+---+---+---+---+---+ +---+