bug fix for a crash in the jitter buffer, patch from pljones
This commit is contained in:
parent
911692c5fa
commit
08c16748a8
4 changed files with 510 additions and 498 deletions
16
llcon.pro
16
llcon.pro
|
@ -163,14 +163,14 @@ DISTFILES += AUTHORS \
|
|||
NEWS \
|
||||
README \
|
||||
TODO \
|
||||
libs\celt\AUTHORS \
|
||||
libs\celt\ChangeLog \
|
||||
libs\celt\COPYING \
|
||||
libs\celt\INSTALL \
|
||||
libs\celt\NEWS \
|
||||
libs\celt\README \
|
||||
libs\celt\README_LLCON \
|
||||
libs\celt\TODO \
|
||||
libs/celt/AUTHORS \
|
||||
libs/celt/ChangeLog \
|
||||
libs/celt/COPYING \
|
||||
libs/celt/INSTALL \
|
||||
libs/celt/NEWS \
|
||||
libs/celt/README \
|
||||
libs/celt/README_LLCON \
|
||||
libs/celt/TODO \
|
||||
src/res/CLEDBlack.png \
|
||||
src/res/CLEDBlackSmall.png \
|
||||
src/res/CLEDDisabledSmall.png \
|
||||
|
|
|
@ -206,10 +206,9 @@ bool CNetBufWithStats::Get ( CVector<uint8_t>& vecbyData )
|
|||
const double dInitState =
|
||||
ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].InitializationState();
|
||||
|
||||
if ( dInitState < 0.2 )
|
||||
if ( dInitState < 0.1 )
|
||||
{
|
||||
if ( ( dInitState > 0.1 ) &&
|
||||
( ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].GetAverage() > ERROR_RATE_BOUND ) )
|
||||
if ( ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].GetAverage() > ERROR_RATE_BOUND )
|
||||
{
|
||||
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ )
|
||||
{
|
||||
|
|
30
src/buffer.h
30
src/buffer.h
|
@ -78,7 +78,7 @@ public:
|
|||
}
|
||||
|
||||
// set correct buffer state
|
||||
if ( iCopyLen >= iNewMemSize )
|
||||
if ( iCopyLen == iNewMemSize )
|
||||
{
|
||||
eBufState = CBufferBase<TData>::BS_FULL;
|
||||
}
|
||||
|
@ -101,16 +101,6 @@ public:
|
|||
{
|
||||
vecMemory[iCurPos] = vecTempMemory[iGetPos + iCurPos];
|
||||
}
|
||||
|
||||
// update put pointer
|
||||
if ( eBufState == CBufferBase<TData>::BS_FULL )
|
||||
{
|
||||
iPutPos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
iPutPos -= iGetPos;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -119,7 +109,7 @@ public:
|
|||
int iFirstPartLen = iMemSize - iGetPos;
|
||||
|
||||
// check that first copy length is not larger then new memory
|
||||
if ( iFirstPartLen > iCopyLen )
|
||||
if ( iFirstPartLen >= iCopyLen )
|
||||
{
|
||||
iFirstPartLen = iCopyLen;
|
||||
bEnoughSpaceForSecondPart = false;
|
||||
|
@ -142,6 +132,7 @@ public:
|
|||
vecTempMemory[iCurPos];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update put pointer
|
||||
if ( eBufState == CBufferBase<TData>::BS_FULL )
|
||||
|
@ -150,8 +141,7 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
iPutPos += iFirstPartLen;
|
||||
}
|
||||
iPutPos = iCopyLen;
|
||||
}
|
||||
|
||||
// update get position -> zero per definition
|
||||
|
@ -222,6 +212,12 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// take care about wrap around of put pointer
|
||||
if ( iPutPos == iMemSize )
|
||||
{
|
||||
iPutPos = 0;
|
||||
}
|
||||
|
||||
// set buffer state flag
|
||||
if ( iPutPos == iGetPos )
|
||||
{
|
||||
|
@ -281,6 +277,12 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// take care about wrap around of get pointer
|
||||
if ( iGetPos == iMemSize )
|
||||
{
|
||||
iGetPos = 0;
|
||||
}
|
||||
|
||||
// set buffer state flag
|
||||
if ( iPutPos == iGetPos )
|
||||
{
|
||||
|
|
13
src/util.h
13
src/util.h
|
@ -271,6 +271,7 @@ public:
|
|||
|
||||
inline double GetAverage()
|
||||
{
|
||||
// make sure we do not divide by zero
|
||||
if ( this->iNorm == 0 )
|
||||
{
|
||||
return dNoDataResult;
|
||||
|
@ -282,7 +283,17 @@ public:
|
|||
}
|
||||
|
||||
double InitializationState() const
|
||||
{ return static_cast<double> ( this->iNorm ) / this->iVectorSize; }
|
||||
{
|
||||
// make sure we do not divide by zero
|
||||
if ( this->iVectorSize != 0 )
|
||||
{
|
||||
return static_cast<double> ( this->iNorm ) / this->iVectorSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
int iCurIdx;
|
||||
|
|
Loading…
Reference in a new issue