From 7af781447d73f5469eb5ce7202d26f8c79995ff2 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 28 May 2011 06:01:26 +0000 Subject: [PATCH] some fixes for server jitter buffer setting but still not working correctly --- src/channel.cpp | 22 ++++++++++++---------- src/client.cpp | 19 +++++++++++++++++-- src/client.h | 4 +--- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index 72c82629..d1f2ca1b 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -203,20 +203,20 @@ bool CChannel::SetSockBufNumFrames ( const int iNewNumFrames, void CChannel::SetDoAutoSockBufSize ( const bool bValue ) { - // in case auto socket buffer size was just enabled, reset statistic and in - // case of the client, inform the server about the change - if ( ( bDoAutoSockBufSize != bValue ) && bValue ) + QMutexLocker locker ( &Mutex ); + + // only act on new value if it is different from the current one + if ( bDoAutoSockBufSize != bValue ) { - CycleTimeVariance.Reset(); - - if ( !bIsServer ) + if ( bValue ) { - CreateJitBufMes ( AUTO_NET_BUF_SIZE_FOR_PROTOCOL ); + // in case auto socket buffer size was just enabled, reset statistic + CycleTimeVariance.Reset(); } - } - // store new setting - bDoAutoSockBufSize = bValue; + // store new setting + bDoAutoSockBufSize = bValue; + } } void CChannel::SetGain ( const int iChanID, @@ -302,6 +302,8 @@ void CChannel::OnJittBufSizeChange ( int iNewJitBufSize ) } else { + // manual setting is received, turn OFF auto setting and apply new value + SetDoAutoSockBufSize ( false ); SetSockBufNumFrames ( iNewJitBufSize, true ); } } diff --git a/src/client.cpp b/src/client.cpp index e1bcb065..7fef71e5 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -172,10 +172,12 @@ void CClient::OnNewConnection() void CClient::CreateServerJitterBufferMessage() { - // in case auto jitter buffer size is enabled, we have to transmit a - // special value + // per definition in the client: if auto jitter buffer is enabled, both, + // the client and server shall use an auto jitter buffer if ( GetDoAutoSockBufSize() ) { + // in case auto jitter buffer size is enabled, we have to transmit a + // special value Channel.CreateJitBufMes ( AUTO_NET_BUF_SIZE_FOR_PROTOCOL ); } else @@ -225,6 +227,19 @@ int CClient::EvaluatePingMessage ( const int iMs ) return PreciseTime.elapsed() - iMs; } +void CClient::SetDoAutoSockBufSize ( const bool bValue ) +{ + // only act on new parameter if it is different from the current one + if ( Channel.GetDoAutoSockBufSize() != bValue ) + { + // first, set new value in the channel object + Channel.SetDoAutoSockBufSize ( bValue ); + + // inform the server about the change + CreateServerJitterBufferMessage(); + } +} + bool CClient::SetServerAddr ( QString strNAddr ) { CHostAddress HostAddress; diff --git a/src/client.h b/src/client.h index fe0c762e..323c8fa2 100755 --- a/src/client.h +++ b/src/client.h @@ -132,9 +132,7 @@ public: AudioReverbR.Clear(); } - void SetDoAutoSockBufSize ( const bool bValue ) - { Channel.SetDoAutoSockBufSize ( bValue ); } - + void SetDoAutoSockBufSize ( const bool bValue ); bool GetDoAutoSockBufSize() const { return Channel.GetDoAutoSockBufSize(); } void SetSockBufNumFrames ( const int iNumBlocks,