Skip to content

Commit

Permalink
Fixed CSndBuffer::addBufferFromFile
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Jan 2, 2023
1 parent f1b5d1a commit 9c35a6c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions srtcore/buffer_snd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ int CSndBuffer::addBufferFromFile(fstream& ifs, int len)
<< " buffers for " << len << " bytes");

// dynamically increase sender buffer
while (iPktLen + m_iCount >= m_iSize)
while (iNumBlocks + m_iCount >= m_iSize)
{
HLOGC(bslog.Debug,
log << "addBufferFromFile: ... still lacking " << (iPktLen + m_iCount - m_iSize) << " buffers...");
log << "addBufferFromFile: ... still lacking " << (iNumBlocks + m_iCount - m_iSize) << " buffers...");
increase();
}

Expand All @@ -258,7 +258,7 @@ int CSndBuffer::addBufferFromFile(fstream& ifs, int len)

Block* s = m_pLastBlock;
int total = 0;
for (int i = 0; i < iPktLen; ++i)
for (int i = 0; i < iNumBlocks; ++i)
{
if (ifs.bad() || ifs.fail() || ifs.eof())
break;
Expand All @@ -278,7 +278,7 @@ int CSndBuffer::addBufferFromFile(fstream& ifs, int len)
s->m_iMsgNoBitset = m_iNextMsgNo | MSGNO_PACKET_INORDER::mask;
if (i == 0)
s->m_iMsgNoBitset |= PacketBoundaryBits(PB_FIRST);
if (i == iPktLen - 1)
if (i == iNumBlocks - 1)
s->m_iMsgNoBitset |= PacketBoundaryBits(PB_LAST);
// NOTE: PB_FIRST | PB_LAST == PB_SOLO.
// none of PB_FIRST & PB_LAST == PB_SUBSEQUENT.
Expand All @@ -292,7 +292,7 @@ int CSndBuffer::addBufferFromFile(fstream& ifs, int len)
m_pLastBlock = s;

enterCS(m_BufLock);
m_iCount += iPktLen;
m_iCount += iNumBlocks;
m_iBytesCount += total;

leaveCS(m_BufLock);
Expand Down

0 comments on commit 9c35a6c

Please sign in to comment.