From 9111f327a5593f20fb1f35d433c93dd9bfcefc87 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 13 May 2009 07:14:08 +0000 Subject: [PATCH] bug fix --- src/channel.cpp | 30 ++++++++++++++++++++++-------- src/channel.h | 2 +- src/client.h | 10 ++++------ src/llconclientdlg.cpp | 1 + 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index c004d51a..893a1873 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -691,9 +691,14 @@ CChannel::CChannel ( const bool bNIsServer ) : // network block size factor must start from 1 -> i + 1 const int iCurNetBlockSizeFact = i + 1; - vecNetwBufferInProps[iNoneIdx].iAudioBlockSize = iCurNetBlockSizeFact * MIN_SERVER_BLOCK_SIZE_SAMPLES; - vecNetwBufferInProps[iIMAIdx].iAudioBlockSize = iCurNetBlockSizeFact * MIN_SERVER_BLOCK_SIZE_SAMPLES; - vecNetwBufferInProps[iMSIdx].iAudioBlockSize = iCurNetBlockSizeFact * MIN_SERVER_BLOCK_SIZE_SAMPLES; + vecNetwBufferInProps[iNoneIdx].iAudioBlockSize = + iCurNetBlockSizeFact * MIN_SERVER_BLOCK_SIZE_SAMPLES; + + vecNetwBufferInProps[iIMAIdx].iAudioBlockSize = + iCurNetBlockSizeFact * MIN_SERVER_BLOCK_SIZE_SAMPLES; + + vecNetwBufferInProps[iMSIdx].iAudioBlockSize = + iCurNetBlockSizeFact * MIN_SERVER_BLOCK_SIZE_SAMPLES; // None (no audio compression) vecNetwBufferInProps[iNoneIdx].eAudComprType = CT_NONE; @@ -887,15 +892,24 @@ void CChannel::SetAudioCompressionOut ( const EAudComprType eNewAudComprTypeOut } } -void CChannel::SetSockBufSize ( const int iNumBlocks ) +bool CChannel::SetSockBufSize ( const int iNumBlocks ) { QMutexLocker locker ( &Mutex ); // this opperation must be done with mutex - iCurSockBufSize = iNumBlocks; + // first check for valid input parameter range + if ( ( iNumBlocks >= MIN_NET_BUF_SIZE_NUM_BL ) && + ( iNumBlocks <= MAX_NET_BUF_SIZE_NUM_BL ) ) + { + iCurSockBufSize = iNumBlocks; - // the network block size is a multiple of the internal minimal - // block size - SockBuf.Init ( MIN_SERVER_BLOCK_SIZE_SAMPLES, iNumBlocks ); + // the network block size is a multiple of the internal minimal + // block size + SockBuf.Init ( MIN_SERVER_BLOCK_SIZE_SAMPLES, iNumBlocks ); + + return false; // -> no error + } + + return true; // set error flag } void CChannel::SetGain ( const int iChanID, const double dNewGain ) diff --git a/src/channel.h b/src/channel.h index f822f93a..99bc6647 100755 --- a/src/channel.h +++ b/src/channel.h @@ -105,7 +105,7 @@ public: void SetRemoteChanGain ( const int iId, const double dGain ) { Protocol.CreateChanGainMes ( iId, dGain ); } - void SetSockBufSize ( const int iNumBlocks ); + bool SetSockBufSize ( const int iNumBlocks ); int GetSockBufSize() { return iCurSockBufSize; } void SetNetwBufSizeOut ( const int iNewAudioBlockSizeOut ); diff --git a/src/client.h b/src/client.h index a63eba0a..75b93187 100755 --- a/src/client.h +++ b/src/client.h @@ -96,15 +96,13 @@ public: bool GetDoAutoSockBufSize() { return bDoAutoSockBufSize; } void SetSockBufSize ( const int iNumBlocks ) { + // only change parameter if new parameter is different from current one if ( Channel.GetSockBufSize() != iNumBlocks ) { - // check for valid values - if ( ( iNumBlocks >= MIN_NET_BUF_SIZE_NUM_BL ) && - ( iNumBlocks <= MAX_NET_BUF_SIZE_NUM_BL ) ) + // set the new socket size + if ( !Channel.SetSockBufSize ( iNumBlocks ) ) { - // set the new socket size - Channel.SetSockBufSize ( iNumBlocks ); - + // if setting of socket buffer size was successful, // tell the server that size has changed Channel.CreateJitBufMes ( iNumBlocks ); } diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 8c3e2e6a..dc0a09f3 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -453,6 +453,7 @@ void CLlconClientDlg::customEvent ( QEvent* Event ) case MS_SET_JIT_BUF_SIZE: pClient->SetSockBufSize ( iStatus ); + break; } // update general settings dialog, too