From 0e04086d37633c9997b2fcdca5ac9cb2c94b0e87 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Thu, 16 Jun 2011 11:43:28 +0000 Subject: [PATCH] removed Cycle Time Variance measurement since it is not required anymore --- src/channel.cpp | 38 ----------------------- src/channel.h | 6 ++-- src/client.cpp | 9 ------ src/client.h | 2 -- src/server.cpp | 10 ------ src/server.h | 1 - src/util.h | 82 ------------------------------------------------- 7 files changed, 3 insertions(+), 145 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index a7ba2d9b..adfe99a3 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -46,10 +46,6 @@ CChannel::CChannel ( const bool bNIsServer ) : // init the socket buffer SetSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL ); - // initialize cycle time variance measurement with defaults - CycleTimeVariance.Init ( SYSTEM_FRAME_SIZE_SAMPLES, - SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS ); - // initialize channel name ResetName(); @@ -156,9 +152,6 @@ void CChannel::SetAudioStreamProperties ( const int iNewNetwFrameSize, // init conversion buffer ConvBuf.Init ( iNetwFrameSize * iNetwFrameSizeFact ); - // reset cycle time variance measurement - CycleTimeVariance.Reset(); - // tell the server that audio coding has changed CreateNetTranspPropsMessFromCurrentSettings(); } @@ -200,24 +193,6 @@ bool CChannel::SetSockBufNumFrames ( const int iNewNumFrames, return true; // set error flag } -void CChannel::SetDoAutoSockBufSize ( const bool bValue ) -{ - QMutexLocker locker ( &Mutex ); - - // only act on new value if it is different from the current one - if ( bDoAutoSockBufSize != bValue ) - { - if ( bValue ) - { - // in case auto socket buffer size was just enabled, reset statistic - CycleTimeVariance.Reset(); - } - - // store new setting - bDoAutoSockBufSize = bValue; - } -} - void CChannel::SetGain ( const int iChanID, const double dNewGain ) { @@ -361,9 +336,6 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor // init conversion buffer ConvBuf.Init ( iNetwFrameSize * iNetwFrameSizeFact ); - - // reset statistic - CycleTimeVariance.Reset(); } } @@ -464,13 +436,6 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, { eRet = PS_AUDIO_ERR; } - - // update cycle time variance measurement (this is only - // used in case auto socket buffer size is enabled) - if ( bDoAutoSockBufSize ) - { - CycleTimeVariance.Update(); - } } else { @@ -514,9 +479,6 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, Protocol.CreateReqNetwTranspPropsMes(); } - // reset cycle time variance measurement - CycleTimeVariance.Reset(); - // inform other objects that new connection was established emit NewConnection(); } diff --git a/src/channel.h b/src/channel.h index 8364286c..e900317a 100755 --- a/src/channel.h +++ b/src/channel.h @@ -105,7 +105,9 @@ public: const int iNewNetwFrameSizeFact, const int iNewNumAudioChannels ); - void SetDoAutoSockBufSize ( const bool bValue ); + void SetDoAutoSockBufSize ( const bool bValue ) + { bDoAutoSockBufSize = bValue; } + bool GetDoAutoSockBufSize() const { return bDoAutoSockBufSize; } int GetNetwFrameSizeFact() const { return iNetwFrameSizeFact; } @@ -155,8 +157,6 @@ protected: int iCurSockBufNumFrames; bool bDoAutoSockBufSize; - CCycleTimeVariance CycleTimeVariance; - // network output conversion buffer CConvBuf ConvBuf; diff --git a/src/client.cpp b/src/client.cpp index 84fb7986..01c5100b 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -594,12 +594,6 @@ void CClient::Init() vecsAudioSndCrdMono.Init ( iMonoBlockSizeSam ); vecdAudioStereo.Init ( iStereoBlockSizeSam ); - // init response time evaluation - CycleTimeVariance.Init ( SYSTEM_FRAME_SIZE_SAMPLES, - SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS ); - - CycleTimeVariance.Reset(); - // init reverberation AudioReverbL.Init ( SYSTEM_SAMPLE_RATE_HZ ); AudioReverbR.Init ( SYSTEM_SAMPLE_RATE_HZ ); @@ -958,9 +952,6 @@ fflush(pFileDelay); vecsStereoSndCrd.Reset ( 0 ); } - // update response time measurement - CycleTimeVariance.Update(); - // update socket buffer size Channel.UpdateSocketBufferSize(); } diff --git a/src/client.h b/src/client.h index abf6716d..9a5ac1c5 100755 --- a/src/client.h +++ b/src/client.h @@ -320,8 +320,6 @@ protected: // for ping measurement CPreciseTime PreciseTime; - CCycleTimeVariance CycleTimeVariance; - public slots: void OnSendProtMessage ( CVector vecMessage ); void OnDetectedCLMessage ( CVector vecbyData, int iNumBytes ); diff --git a/src/server.cpp b/src/server.cpp index dc3dddfe..92e782a8 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -225,10 +225,6 @@ CServer::CServer ( const int iNewNumChan, vstrChatColors[4] = "maroon"; vstrChatColors[5] = "coral"; - // init moving average buffer for response time evaluation - CycleTimeVariance.Init ( SYSTEM_FRAME_SIZE_SAMPLES, - SYSTEM_SAMPLE_RATE_HZ, TIME_MOV_AV_RESPONSE_SECONDS ); - // enable history graph (if requested) if ( !strHistoryFileName.isEmpty() ) { @@ -476,9 +472,6 @@ void CServer::Start() // start timer HighPrecisionTimer.Start(); - // init time for response time evaluation - CycleTimeVariance.Reset(); - // emit start signal emit Started(); } @@ -703,9 +696,6 @@ void CServer::OnTimer() // does not consume any significant CPU when no client is connected. Stop(); } - - // update response time measurement - CycleTimeVariance.Update(); } CVector CServer::ProcessData ( const int iCurIndex, diff --git a/src/server.h b/src/server.h index dd2904e9..d7ef0298 100755 --- a/src/server.h +++ b/src/server.h @@ -216,7 +216,6 @@ protected: // actual working objects CSocket Socket; - CCycleTimeVariance CycleTimeVariance; // logging CServerLogging Logging; diff --git a/src/util.h b/src/util.h index e673ea40..192f7351 100755 --- a/src/util.h +++ b/src/util.h @@ -754,88 +754,6 @@ public: /******************************************************************************\ * Statistics * \******************************************************************************/ -// Cycle time variance measurement --------------------------------------------- -// use for, e.g., measuring the variance of a timer -class CCycleTimeVariance -{ -public: - CCycleTimeVariance() : iBlockLengthAtSystemSampleRate ( 0 ), - dIntervalTime ( 0.0 ), iNewValueBoundFactor ( 0 ) {} - - void Init ( const int iNewBlockLengthAtSystemSampleRate, - const int iNewSystemSampleRateHz, - const int iHistoryLengthTimeSec, - const int iNewNewValueBoundFactor = MAX_NET_BUF_SIZE_NUM_BL ) - { - // store block size and new value bound factor - iBlockLengthAtSystemSampleRate = iNewBlockLengthAtSystemSampleRate; - iNewValueBoundFactor = iNewNewValueBoundFactor; - - // calculate interval time - dIntervalTime = static_cast ( - iBlockLengthAtSystemSampleRate ) * 1000 / iNewSystemSampleRateHz; - - // calculate actual moving average length and initialize buffer - RespTimeMoAvBuf.Init ( iHistoryLengthTimeSec * - iNewSystemSampleRateHz / iNewBlockLengthAtSystemSampleRate ); - } - - int GetBlockLength() { return iBlockLengthAtSystemSampleRate; } - - void Reset() - { - TimeLastBlock = PreciseTime.elapsed(); - RespTimeMoAvBuf.Reset(); - } - - double Update() - { - // add time difference - const int CurTime = PreciseTime.elapsed(); - - // we want to calculate the standard deviation (we assume that the mean - // is correct at the block period time) - const double dCurAddVal = - static_cast ( CurTime - TimeLastBlock ) - dIntervalTime; - -/* -// TEST -static FILE* pFile = fopen ( "c:\\temp\\test.dat", "w" ); -fprintf ( pFile, "%e %e\n", dCurAddVal, iNewValueBoundFactor * dIntervalTime ); -fflush ( pFile ); -// close;x=read('c:/temp/test.dat',-1,2);plot(x) -*/ - - // check if new value is in range (lower and upper bound) - if ( ( fabs ( dCurAddVal ) <= ( iNewValueBoundFactor * dIntervalTime ) ) )// && -// ( fabs ( dCurAddVal ) >= dIntervalTime ) ) - { - // add squared value - RespTimeMoAvBuf.Add ( dCurAddVal * dCurAddVal ); - } - - // store old time value - TimeLastBlock = CurTime; - - return dCurAddVal; - } - - // return the standard deviation, for that we need to calculate - // the sqaure root - double GetStdDev() { return sqrt ( RespTimeMoAvBuf.GetAverage() ); } - - bool IsInitialized() { return RespTimeMoAvBuf.IsInitialized(); } - -protected: - CPreciseTime PreciseTime; - CMovingAv RespTimeMoAvBuf; - int TimeLastBlock; - int iBlockLengthAtSystemSampleRate; - double dIntervalTime; - int iNewValueBoundFactor; -}; - - // Error rate measurement ------------------------------------------------------ class CErrorRate {