From 1c76d2e8fea180300c28f925f6f0d24a862fa57f Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 7 Feb 2010 12:15:36 +0000 Subject: [PATCH] bug fix with overall delay calculation if sound card conversion buffer is used --- ChangeLog | 7 ++++++- src/client.cpp | 4 ++-- src/client.h | 16 +++++++++++++++- src/clientsettingsdlg.cpp | 10 +++++++--- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 29b2a643..a9ba2fb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 3.0.4 +- all available ASIO sample formats supported + +- sound card frame size support for frame sizes other than 128, 256 and 512 + samples + - improvement of network buffer (jitter buffer) in case of small buffer sizes @@ -53,7 +58,7 @@ - bug fix: buzzing occurred when audio stream was interrupted (e.g. in case of network trouble) - + 3.0.0 - introduced new audio codec "CELT", not compatible to old versions diff --git a/src/client.cpp b/src/client.cpp index 3463b158..c8032f08 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -355,7 +355,6 @@ void CClient::Init() iSndCrdFrameSizeFactor = iMonoBlockSizeSam / SYSTEM_FRAME_SIZE_SAMPLES; // no sound card conversion buffer required - iSndCardMonoBlockSizeSamConvBuff = 0; // this is important! bSndCrdConversionBufferRequired = false; } else @@ -640,7 +639,8 @@ void CClient::UpdateSocketBufferSize() // calculate current buffer setting const double dAudioBufferDurationMs = - ( iMonoBlockSizeSam + iSndCardMonoBlockSizeSamConvBuff ) * + ( GetSndCrdActualMonoBlSize() + + GetSndCrdConvBufAdditionalDelayMonoBlSize() ) * 1000 / SYSTEM_SAMPLE_RATE; // jitter introduced in the server by the timer implementation diff --git a/src/client.h b/src/client.h index acfc36cc..5c2255b8 100755 --- a/src/client.h +++ b/src/client.h @@ -142,13 +142,27 @@ public: // sound card conversion buffer is used or not if ( bSndCrdConversionBufferRequired ) { - return iSndCardMonoBlockSizeSamConvBuff + iMonoBlockSizeSam; + return iSndCardMonoBlockSizeSamConvBuff; } else { return iMonoBlockSizeSam; } } + int GetSystemMonoBlSize() { return iMonoBlockSizeSam; } + int GetSndCrdConvBufAdditionalDelayMonoBlSize() + { + if ( bSndCrdConversionBufferRequired ) + { + // by introducing the conversion buffer we also introduce additional + // delay which equals the "internal" mono buffer size + return iMonoBlockSizeSam; + } + else + { + return 0; + } + } bool GetFraSiFactPrefSupported() { return bFraSiFactPrefSupported; } bool GetFraSiFactDefSupported() { return bFraSiFactDefSupported; } diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index feb852bf..8dccd384 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -508,14 +508,18 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime ) // we assume that we have two period sizes for the input and one for the // output, therefore we have "3 *" instead of "2 *" (for input and output) - // the actual sound card buffer size + // the actual sound card buffer size, also consider delay introduced by + // sound card conversion buffer by using + // "GetSndCrdConvBufAdditionalDelayMonoBlSize" const double dTotalSoundCardDelayMS = - 3 * pClient->GetSndCrdActualMonoBlSize() * + ( 3 * pClient->GetSndCrdActualMonoBlSize() + + pClient->GetSndCrdConvBufAdditionalDelayMonoBlSize() ) * 1000 / SYSTEM_SAMPLE_RATE; // network packets are of the same size as the audio packets per definition + // if no sound card conversion buffer is used const double dDelayToFillNetworkPackets = - pClient->GetSndCrdActualMonoBlSize() * + pClient->GetSystemMonoBlSize() * 1000 / SYSTEM_SAMPLE_RATE; // CELT additional delay at small frame sizes is half a frame size