From 564d54f68ce19b0cb10c0d5b0d6d101e6eac29cc Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 18 Mar 2009 07:24:53 +0000 Subject: [PATCH] small fix for auto jitter buffer setting --- src/channel.cpp | 5 ++++- src/client.cpp | 10 ++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index f220d062..0cae95aa 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -1130,7 +1130,10 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, // re-initialization, too, if necessary if ( iAudioSize != CycleTimeVariance.GetBlockLength() ) { - // re-init + // re-init (we have to use the buffer size which works + // on the system sample rate, therefore we use the + // decompressed audio buffer size instead of the network + // buffer size) CycleTimeVariance.Init ( iAudioSize, TIME_MOV_AV_RESPONSE ); CycleTimeVariance.Reset(); } diff --git a/src/client.cpp b/src/client.cpp index bc3a6085..40a8ca1d 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -443,11 +443,9 @@ void CClient::UpdateSocketBufferSize() { // We use the time response measurement for the automatic setting. // Assumptions: - // - the network jitter can be neglected compared to the audio - // interface jitter - // - the audio interface jitter is assumed to be Gaussian - // - the buffer size is set to two times the standard deviation of - // the audio interface jitter (~95% of the jitter should be fit in the + // - the audio interface/network jitter is assumed to be Gaussian + // - the buffer size is set to 2.3 times the standard deviation of + // the jitter (~90% of the jitter should be fit in the // buffer) // - introduce a hysteresis to avoid switching the buffer sizes all the // time in case the time response measurement is close to a bound @@ -471,7 +469,7 @@ void CClient::UpdateSocketBufferSize() // divide by MIN_SERVER_BLOCK_DURATION_MS because this is the size of // one block in the jitter buffer const double dEstCurBufSet = ( dAudioBufferDurationMs + - 2 * ( Channel.GetTimingStdDev() + CycleTimeVariance.GetStdDev() + 0.5 ) ) / + 2.3 * ( Channel.GetTimingStdDev() + CycleTimeVariance.GetStdDev() + 0.5 ) ) / MIN_SERVER_BLOCK_DURATION_MS; // upper/lower hysteresis decision