bug fix with channel time out, set the default time out to 20 seconds

This commit is contained in:
Volker Fischer 2009-03-03 08:35:28 +00:00
parent 2efdb7775d
commit 24a7740438
2 changed files with 33 additions and 27 deletions

View file

@ -606,6 +606,14 @@ CChannel::CChannel ( const bool bNIsServer ) : bIsServer ( bNIsServer ),
vecNetwBufferInProps[iMSIdx].eAudComprType ); vecNetwBufferInProps[iMSIdx].eAudComprType );
} }
// initial value for connection time out counter, we calculate the total
// number of samples here and subtract the number of samples of the block
// which we take out of the buffer to be independent of block sizes
iConTimeOutStartVal = CON_TIME_OUT_SEC_MAX * SYSTEM_SAMPLE_RATE;
// init time-out for the buffer with zero -> no connection
iConTimeOut = 0;
// init the socket buffer // init the socket buffer
SetSockBufSize ( DEF_NET_BUF_SIZE_NUM_BL ); SetSockBufSize ( DEF_NET_BUF_SIZE_NUM_BL );
@ -619,10 +627,6 @@ CChannel::CChannel ( const bool bNIsServer ) : bIsServer ( bNIsServer ),
// set initial audio compression format for output // set initial audio compression format for output
SetAudioCompressionOut ( CT_MSADPCM ); SetAudioCompressionOut ( CT_MSADPCM );
// init time-out for the buffer with zero -> no connection
iConTimeOut = 0;
// connections ------------------------------------------------------------- // connections -------------------------------------------------------------
QObject::connect ( &Protocol, QObject::connect ( &Protocol,
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ), SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
@ -723,13 +727,6 @@ void CChannel::SetAudioBlockSizeAndComprIn ( const int iNewBlockSize,
// init audio compression unit // init audio compression unit
AudioCompressionIn.Init ( iNewBlockSize, eNewAudComprType ); AudioCompressionIn.Init ( iNewBlockSize, eNewAudComprType );
// initial value for connection time out counter
// TODO FIXME this does not work correctly -> bug
// (the calculation is correct but the value is not correctly applied)
iConTimeOutStartVal =
( CON_TIME_OUT_SEC_MAX * SYSTEM_SAMPLE_RATE ) / iNewBlockSize;
} }
void CChannel::SetNetwBufSizeOut ( const int iNewAudioBlockSizeOut ) void CChannel::SetNetwBufSizeOut ( const int iNewAudioBlockSizeOut )
@ -1097,20 +1094,29 @@ EGetDataStat CChannel::GetData ( CVector<double>& vecdData )
{ {
QMutexLocker locker ( &Mutex ); QMutexLocker locker ( &Mutex );
// init with ok flag EGetDataStat eGetStatus;
EGetDataStat eGetStatus = GS_BUFFER_OK;
const bool bSockBufState = SockBuf.Get ( vecdData );
if ( !SockBuf.Get ( vecdData ) )
{
// decrease time-out counter // decrease time-out counter
if ( iConTimeOut > 0 ) if ( iConTimeOut > 0 )
{ {
iConTimeOut--; // subtract the number of samples of the current block since the
// time out counter is based on samples not on blocks
iConTimeOut -= vecdData.Size();
if ( iConTimeOut == 0 ) if ( iConTimeOut <= 0 )
{ {
// channel is just disconnected // channel is just disconnected
eGetStatus = GS_CHAN_NOW_DISCONNECTED; eGetStatus = GS_CHAN_NOW_DISCONNECTED;
iConTimeOut = 0; // make sure we do not have negative values
}
else
{
if ( bSockBufState )
{
// everything is ok
eGetStatus = GS_BUFFER_OK;
} }
else else
{ {
@ -1118,12 +1124,12 @@ EGetDataStat CChannel::GetData ( CVector<double>& vecdData )
eGetStatus = GS_BUFFER_UNDERRUN; eGetStatus = GS_BUFFER_UNDERRUN;
} }
} }
}
else else
{ {
// channel is disconnected // channel is disconnected
eGetStatus = GS_CHAN_NOT_CONNECTED; eGetStatus = GS_CHAN_NOT_CONNECTED;
} }
}
return eGetStatus; return eGetStatus;
} }

View file

@ -41,7 +41,7 @@
// Set the time-out for the input buffer until the state changes from // Set the time-out for the input buffer until the state changes from
// connected to not-connected (the actual time depends on the way the error // connected to not-connected (the actual time depends on the way the error
// correction is implemented) // correction is implemented)
#define CON_TIME_OUT_SEC_MAX 5 // seconds #define CON_TIME_OUT_SEC_MAX 20 // seconds
// no valid channel number // no valid channel number
#define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 ) #define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 )