From 95389cbf7aa53b6b51ba72511893170f9ec27515 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 12 Mar 2006 13:19:41 +0000 Subject: [PATCH] fixes for network buffer factor setting --- src/channel.cpp | 59 +++++++++++++++++++++------------------ src/llconclientdlg.cpp | 24 ++++++++++------ src/llconclientdlg.h | 14 ++++++---- src/llconclientdlgbase.ui | 51 +++++++++++++++++++++++++++++---- 4 files changed, 101 insertions(+), 47 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index 2e1c8beb..8af6ea30 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -61,7 +61,7 @@ int CChannelSet::GetFreeChan() /* look for a free channel */ for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { - if ( !vecChannels[i].IsConnected () ) + if ( !vecChannels[i].IsConnected() ) { return i; } @@ -98,7 +98,7 @@ bool CChannelSet::PutData ( const CVector& vecbyRecBuf, { bool bRet = false; - Mutex.lock (); + Mutex.lock(); { bool bChanOK = true; @@ -109,7 +109,7 @@ bool CChannelSet::PutData ( const CVector& vecbyRecBuf, if ( iCurChanID == INVALID_CHANNEL_ID ) { /* a new client is calling, look for free channel */ - iCurChanID = GetFreeChan (); + iCurChanID = GetFreeChan(); if ( iCurChanID != INVALID_CHANNEL_ID ) { @@ -145,7 +145,7 @@ bool CChannelSet::PutData ( const CVector& vecbyRecBuf, } } } - Mutex.unlock (); + Mutex.unlock(); return bRet; } @@ -161,7 +161,7 @@ void CChannelSet::GetBlockAllConC ( CVector& vecChanID, /* make put and get calls thread safe. Do not forget to unlock mutex afterwards! */ - Mutex.lock (); + Mutex.lock(); { /* Check all possible channels */ for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) @@ -170,14 +170,14 @@ void CChannelSet::GetBlockAllConC ( CVector& vecChanID, disconnected channels */ const bool bGetOK = vecChannels[i].GetData ( vecdData ); - if ( vecChannels[i].IsConnected () ) + if ( vecChannels[i].IsConnected() ) { /* add ID and data */ vecChanID.Add ( i ); - const int iOldSize = vecvecdData.Size (); + const int iOldSize = vecvecdData.Size(); vecvecdData.Enlarge ( 1 ); - vecvecdData[iOldSize].Init ( vecdData.Size () ); + vecvecdData[iOldSize].Init ( vecdData.Size() ); vecvecdData[iOldSize] = vecdData; /* send message for get status (for GUI) */ @@ -192,7 +192,7 @@ void CChannelSet::GetBlockAllConC ( CVector& vecChanID, } } } - Mutex.unlock (); /* release mutex */ + Mutex.unlock(); /* release mutex */ } void CChannelSet::GetConCliParam ( CVector& vecHostAddresses, @@ -220,7 +220,7 @@ void CChannelSet::GetConCliParam ( CVector& vecHostAddresses, /******************************************************************************\ * CChannel * \******************************************************************************/ -CChannel::CChannel () +CChannel::CChannel() { /* init time stamp index counter */ byTimeStampIdxCnt = 0; @@ -283,17 +283,21 @@ void CChannel::SetNetwOutBlSiFact ( const int iNewBlockSizeFactor ) void CChannel::OnSendProtMessage ( CVector vecMessage ) { - // only send messages if we are connected, otherwise delete complete queue - if ( IsConnected () ) - { + +// must be disabled to be able to receive network buffer size factor changes +// FIXME check, if this condition must be checked somewhere else! + +// // only send messages if we are connected, otherwise delete complete queue +// if ( IsConnected() ) +// { // emit message to actually send the data emit MessReadyForSending ( vecMessage ); - } - else - { - // delete send message queue - Protocol.DeleteSendMessQueue(); - } +// } +// else +// { +// // delete send message queue +// Protocol.DeleteSendMessQueue(); +// } } @@ -301,7 +305,7 @@ void CChannel::OnSendProtMessage ( CVector vecMessage ) void CChannel::SetSockBufSize ( const int iNumBlocks ) { /* this opperation must be done with mutex */ - Mutex.lock (); + Mutex.lock(); { iCurSockBufSize = iNumBlocks; @@ -314,7 +318,7 @@ void CChannel::SetSockBufSize ( const int iNumBlocks ) SockBuf.Init ( MIN_BLOCK_SIZE_SAMPLES, iNumBlocks + iCurNetwInBlSiFact ); } - Mutex.unlock (); + Mutex.unlock(); } void CChannel::OnJittBufSizeChange ( int iNewJitBufSize ) @@ -367,7 +371,7 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, /* only process if packet has correct size */ if ( iNumBytes == iAudComprSizeIn ) { - Mutex.lock (); + Mutex.lock(); { /* decompress audio */ CVector vecsDecomprAudio ( AudioCompressionIn.Decode ( vecbyData ) ); @@ -402,13 +406,14 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) { // reset time-out counter iConTimeOut = iConTimeOutStartVal; } - Mutex.unlock (); + Mutex.unlock(); } else { // only use protocol data if channel is connected // must be disabled to be able to receive network buffer size factor changes +// FIXME check, if this condition must be checked somewhere else! // if ( IsConnected() ) { @@ -442,7 +447,7 @@ bool CChannel::GetData ( CVector& vecdData ) { bool bGetOK = false; - Mutex.lock (); /* get mutex lock */ + Mutex.lock(); /* get mutex lock */ { bGetOK = SockBuf.Get ( vecdData ); @@ -455,12 +460,12 @@ bool CChannel::GetData ( CVector& vecdData ) } } } - Mutex.unlock (); /* get mutex unlock */ + Mutex.unlock(); /* get mutex unlock */ return bGetOK; } -CVector CChannel::PrepSendPacket(const CVector& vecsNPacket) +CVector CChannel::PrepSendPacket ( const CVector& vecsNPacket ) { /* if the block is not ready we have to initialize with zero length to tell the following network send routine that nothing should be sent */ @@ -472,7 +477,7 @@ CVector CChannel::PrepSendPacket(const CVector& vecsNPacke { /* a packet is ready, compress audio */ vecbySendBuf.Init ( iAudComprSizeOut ); - vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get () ); + vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get() ); } // if we are not connected, send network buffer size factor so that the diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 24dbe696..8810a262 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -235,24 +235,28 @@ void CLlconClientDlg::OnSliderSndBufInChange(int value) { pClient->GetSndInterface()->SetInNumBuf(value); TextSndBufIn->setText("In: " + QString().setNum(value)); + UpdateDisplay(); } void CLlconClientDlg::OnSliderSndBufOutChange(int value) { pClient->GetSndInterface()->SetOutNumBuf(value); TextSndBufOut->setText("Out: " + QString().setNum(value)); + UpdateDisplay(); } void CLlconClientDlg::OnSliderNetBuf(int value) { pClient->SetSockBufSize ( value ); TextNetBuf->setText("Size: " + QString().setNum(value)); + UpdateDisplay(); } void CLlconClientDlg::OnSliderNetBufSiFact(int value) { pClient->SetNetwBufSizeFact ( value ); TextNetBufSiFact->setText("Fact.: " + QString().setNum(value)); + UpdateDisplay(); } void CLlconClientDlg::OnTimerSigMet () @@ -287,22 +291,26 @@ void CLlconClientDlg::OnTimerSigMet () ProgressBarInputLevelL->setProgress ( (int) ceil ( dCurSigLevelL ) ); ProgressBarInputLevelR->setProgress ( (int) ceil ( dCurSigLevelR ) ); } - -void CLlconClientDlg::OnTimerStatus () -{ - /* show connection status in status bar */ + +void CLlconClientDlg::UpdateDisplay() +{ + /* show connection status in status bar */ if ( pClient->IsConnected () && pClient->IsRunning () ) - { + { TextLabelStatus->setText ( tr ( "connected" ) ); - } + } else - { + { TextLabelStatus->setText ( tr ( "disconnected" ) ); - } + } /* response time */ TextLabelStdDevTimer->setText(QString(). setNum(pClient->GetTimingStdDev(), 'f', 2) + " ms"); + + // current network buffer size + TextLabelActNetwBufSize->setText(QString(). + setNum(double(pClient->GetNetwBufSizeFact() * MIN_BLOCK_DURATION_MS), 'f', 2) + " ms"); } void CLlconClientDlg::customEvent(QCustomEvent* Event) diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index aac3273d..7f8ab387 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -75,16 +75,18 @@ protected: CClient* pClient; bool bConnected; QTimer TimerSigMet; - QTimer TimerStatus; + QTimer TimerStatus; + virtual void customEvent ( QCustomEvent* Event ); virtual void closeEvent ( QCloseEvent * Event ); + void UpdateDisplay(); QMenuBar* pMenu; public slots: - void OnConnectDisconBut (); - void OnTimerSigMet (); - void OnTimerStatus (); + void OnConnectDisconBut(); + void OnTimerSigMet(); + void OnTimerStatus() { UpdateDisplay(); } void OnSliderSndBufInChange ( int value ); void OnSliderSndBufOutChange ( int value ); void OnSliderNetBuf ( int value ); @@ -92,6 +94,6 @@ public slots: void OnSliderAudInFader ( int value ) { pClient->SetAudioInFader(value); } void OnSliderAudReverb ( int value ) { pClient->SetReverbLevel ( AUD_REVERB_MAX - value ); } - void OnRevSelL () { pClient->SetReverbOnLeftChan(true); } - void OnRevSelR () { pClient->SetReverbOnLeftChan(false); } + void OnRevSelL() { pClient->SetReverbOnLeftChan(true); } + void OnRevSelR() { pClient->SetReverbOnLeftChan(false); } }; diff --git a/src/llconclientdlgbase.ui b/src/llconclientdlgbase.ui index a9eb4cb6..48328e64 100755 --- a/src/llconclientdlgbase.ui +++ b/src/llconclientdlgbase.ui @@ -1095,7 +1095,7 @@ title Measurement Results - + margin 11 @@ -1108,9 +1108,9 @@ QLayoutWidget name - Layout16 + Layout17 - + margin 0 @@ -1127,9 +1127,37 @@ text - StdDev: + StdDev: + + QLabel + + name + TextLabelActNetwBufSizeLabel + + + text + Netw. Buf. Size: + + + + + + QLayoutWidget + + name + Layout18 + + + + margin + 0 + + + spacing + 6 + QLabel @@ -1141,9 +1169,20 @@ val - + + QLabel + + name + TextLabelActNetwBufSize + + + text + val + + + - +