bug fix for a crash in the jitter buffer, patch from pljones

This commit is contained in:
Volker Fischer 2011-06-28 19:07:24 +00:00
parent 911692c5fa
commit 08c16748a8
4 changed files with 510 additions and 498 deletions

View file

@ -163,14 +163,14 @@ DISTFILES += AUTHORS \
NEWS \ NEWS \
README \ README \
TODO \ TODO \
libs\celt\AUTHORS \ libs/celt/AUTHORS \
libs\celt\ChangeLog \ libs/celt/ChangeLog \
libs\celt\COPYING \ libs/celt/COPYING \
libs\celt\INSTALL \ libs/celt/INSTALL \
libs\celt\NEWS \ libs/celt/NEWS \
libs\celt\README \ libs/celt/README \
libs\celt\README_LLCON \ libs/celt/README_LLCON \
libs\celt\TODO \ libs/celt/TODO \
src/res/CLEDBlack.png \ src/res/CLEDBlack.png \
src/res/CLEDBlackSmall.png \ src/res/CLEDBlackSmall.png \
src/res/CLEDDisabledSmall.png \ src/res/CLEDDisabledSmall.png \

View file

@ -206,10 +206,9 @@ bool CNetBufWithStats::Get ( CVector<uint8_t>& vecbyData )
const double dInitState = const double dInitState =
ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].InitializationState(); ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].InitializationState();
if ( dInitState < 0.2 ) if ( dInitState < 0.1 )
{ {
if ( ( dInitState > 0.1 ) && if ( ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].GetAverage() > ERROR_RATE_BOUND )
( ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].GetAverage() > ERROR_RATE_BOUND ) )
{ {
for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ ) for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ )
{ {

View file

@ -78,7 +78,7 @@ public:
} }
// set correct buffer state // set correct buffer state
if ( iCopyLen >= iNewMemSize ) if ( iCopyLen == iNewMemSize )
{ {
eBufState = CBufferBase<TData>::BS_FULL; eBufState = CBufferBase<TData>::BS_FULL;
} }
@ -101,16 +101,6 @@ public:
{ {
vecMemory[iCurPos] = vecTempMemory[iGetPos + iCurPos]; vecMemory[iCurPos] = vecTempMemory[iGetPos + iCurPos];
} }
// update put pointer
if ( eBufState == CBufferBase<TData>::BS_FULL )
{
iPutPos = 0;
}
else
{
iPutPos -= iGetPos;
}
} }
else else
{ {
@ -119,7 +109,7 @@ public:
int iFirstPartLen = iMemSize - iGetPos; int iFirstPartLen = iMemSize - iGetPos;
// check that first copy length is not larger then new memory // check that first copy length is not larger then new memory
if ( iFirstPartLen > iCopyLen ) if ( iFirstPartLen >= iCopyLen )
{ {
iFirstPartLen = iCopyLen; iFirstPartLen = iCopyLen;
bEnoughSpaceForSecondPart = false; bEnoughSpaceForSecondPart = false;
@ -142,6 +132,7 @@ public:
vecTempMemory[iCurPos]; vecTempMemory[iCurPos];
} }
} }
}
// update put pointer // update put pointer
if ( eBufState == CBufferBase<TData>::BS_FULL ) if ( eBufState == CBufferBase<TData>::BS_FULL )
@ -150,8 +141,7 @@ public:
} }
else else
{ {
iPutPos += iFirstPartLen; iPutPos = iCopyLen;
}
} }
// update get position -> zero per definition // 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 // set buffer state flag
if ( iPutPos == iGetPos ) 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 // set buffer state flag
if ( iPutPos == iGetPos ) if ( iPutPos == iGetPos )
{ {

View file

@ -271,6 +271,7 @@ public:
inline double GetAverage() inline double GetAverage()
{ {
// make sure we do not divide by zero
if ( this->iNorm == 0 ) if ( this->iNorm == 0 )
{ {
return dNoDataResult; return dNoDataResult;
@ -282,7 +283,17 @@ public:
} }
double InitializationState() const 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: protected:
int iCurIdx; int iCurIdx;