some cleanup, use new clear functionality for jitter buffer, use longer history in server

This commit is contained in:
Volker Fischer 2009-08-22 16:13:21 +00:00
parent 9b75ef5f9f
commit a0584119c2
2 changed files with 19 additions and 0 deletions

View file

@ -119,6 +119,16 @@ bool CNetBuf::Get ( CVector<uint8_t>& vecbyData )
return false; return false;
} }
// check for invalid data in buffer
if ( iNumInvalidElements > 0 )
{
// decrease number of invalid elements by the queried number (input
// size)
iNumInvalidElements -= iInSize;
bGetOK = false; // return error flag
}
// Check if there is not enough data available -> correct // Check if there is not enough data available -> correct
if ( GetAvailData() < iInSize ) if ( GetAvailData() < iInSize )
{ {
@ -245,6 +255,11 @@ void CNetBuf::Clear ( const EClearType eClearType )
iPutPos = 0; iPutPos = 0;
iGetPos = iMiddleOfBuffer; iGetPos = iMiddleOfBuffer;
// The buffer was cleared, the next time blocks are read from the
// buffer, these are invalid ones. Calculate the number of invalid
// elements
iNumInvalidElements = iMemSize - iMiddleOfBuffer;
// check for special case // check for special case
if ( iPutPos == iGetPos ) if ( iPutPos == iGetPos )
{ {
@ -269,6 +284,9 @@ void CNetBuf::Clear ( const EClearType eClearType )
iPutPos -= iMemSize; iPutPos -= iMemSize;
} }
// in case of put correction, no invalid blocks are inserted
iNumInvalidElements = 0;
// check for special case // check for special case
if ( iPutPos == iGetPos ) if ( iPutPos == iGetPos )
{ {

View file

@ -52,6 +52,7 @@ protected:
CVector<uint8_t> vecbyMemory; CVector<uint8_t> vecbyMemory;
int iMemSize; int iMemSize;
int iBlockSize; int iBlockSize;
int iNumInvalidElements;
int iGetPos, iPutPos; int iGetPos, iPutPos;
EBufState eBufState; EBufState eBufState;
}; };