Skip to content

Commit

Permalink
[core] Fixed CRcvBuffer::countBytes() usage
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko authored and rndi committed Sep 3, 2019
1 parent ef9101c commit 6f2c941
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions srtcore/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,8 +1033,6 @@ bool CRcvBuffer::getRcvFirstMsg(ref_t<uint64_t> r_tsbpdtime, ref_t<bool> r_passa
bool CRcvBuffer::getRcvReadyMsg(ref_t<uint64_t> tsbpdtime, ref_t<int32_t> curpktseq)
{
*tsbpdtime = 0;
int rmpkts = 0;
int rmbytes = 0;

#if ENABLE_HEAVY_LOGGING
const char* reason = "NOT RECEIVED";
Expand Down Expand Up @@ -1085,10 +1083,12 @@ bool CRcvBuffer::getRcvReadyMsg(ref_t<uint64_t> tsbpdtime, ref_t<int32_t> curpkt

if (freeunit)
{
/* removed skipped, dropped, undecryptable bytes from rcv buffer */
const int rmbytes = (int)m_pUnit[i]->m_Packet.getLength();
countBytes(-1, -rmbytes, true);

CUnit* tmp = m_pUnit[i];
m_pUnit[i] = NULL;
rmpkts++;
rmbytes += (int) tmp->m_Packet.getLength();
m_pUnitQueue->makeUnitFree(tmp);

if (++m_iStartPos == m_iSize)
Expand All @@ -1097,8 +1097,6 @@ bool CRcvBuffer::getRcvReadyMsg(ref_t<uint64_t> tsbpdtime, ref_t<int32_t> curpkt
}

HLOGC(mglog.Debug, log << "getRcvReadyMsg: nothing to deliver: " << reason);
/* removed skipped, dropped, undecryptable bytes from rcv buffer */
countBytes(-rmpkts, -rmbytes, true);
return false;
}

Expand Down Expand Up @@ -1590,12 +1588,15 @@ int CRcvBuffer::readMsg(char* data, int len, ref_t<SRT_MSGCTRL> r_msgctl)
msgctl.pktseq = pkt1.getSeqNo();
msgctl.msgno = pkt1.getMsgSeq();

SRT_ASSERT(len > 0);
int rs = len;
while (p != (q + 1) % m_iSize)
{
int unitsize = (int) m_pUnit[p]->m_Packet.getLength();
if ((rs >= 0) && (unitsize > rs))
unitsize = rs;
const int pktlen = (int)m_pUnit[p]->m_Packet.getLength();
if (pktlen > 0)
countBytes(-1, -pktlen, true);

const int unitsize = ((rs >= 0) && (unitsize > rs)) ? rs : pktlen;

if (unitsize > 0)
{
Expand Down

0 comments on commit 6f2c941

Please sign in to comment.