fixes for network buffer factor setting

This commit is contained in:
Volker Fischer 2006-03-12 13:19:41 +00:00
parent 614708c9c3
commit 95389cbf7a
4 changed files with 101 additions and 47 deletions

View file

@ -61,7 +61,7 @@ int CChannelSet::GetFreeChan()
/* look for a free channel */ /* look for a free channel */
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
if ( !vecChannels[i].IsConnected () ) if ( !vecChannels[i].IsConnected() )
{ {
return i; return i;
} }
@ -98,7 +98,7 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
{ {
bool bRet = false; bool bRet = false;
Mutex.lock (); Mutex.lock();
{ {
bool bChanOK = true; bool bChanOK = true;
@ -109,7 +109,7 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
if ( iCurChanID == INVALID_CHANNEL_ID ) if ( iCurChanID == INVALID_CHANNEL_ID )
{ {
/* a new client is calling, look for free channel */ /* a new client is calling, look for free channel */
iCurChanID = GetFreeChan (); iCurChanID = GetFreeChan();
if ( iCurChanID != INVALID_CHANNEL_ID ) if ( iCurChanID != INVALID_CHANNEL_ID )
{ {
@ -145,7 +145,7 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
} }
} }
} }
Mutex.unlock (); Mutex.unlock();
return bRet; return bRet;
} }
@ -161,7 +161,7 @@ void CChannelSet::GetBlockAllConC ( CVector<int>& vecChanID,
/* make put and get calls thread safe. Do not forget to unlock mutex /* make put and get calls thread safe. Do not forget to unlock mutex
afterwards! */ afterwards! */
Mutex.lock (); Mutex.lock();
{ {
/* Check all possible channels */ /* Check all possible channels */
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
@ -170,14 +170,14 @@ void CChannelSet::GetBlockAllConC ( CVector<int>& vecChanID,
disconnected channels */ disconnected channels */
const bool bGetOK = vecChannels[i].GetData ( vecdData ); const bool bGetOK = vecChannels[i].GetData ( vecdData );
if ( vecChannels[i].IsConnected () ) if ( vecChannels[i].IsConnected() )
{ {
/* add ID and data */ /* add ID and data */
vecChanID.Add ( i ); vecChanID.Add ( i );
const int iOldSize = vecvecdData.Size (); const int iOldSize = vecvecdData.Size();
vecvecdData.Enlarge ( 1 ); vecvecdData.Enlarge ( 1 );
vecvecdData[iOldSize].Init ( vecdData.Size () ); vecvecdData[iOldSize].Init ( vecdData.Size() );
vecvecdData[iOldSize] = vecdData; vecvecdData[iOldSize] = vecdData;
/* send message for get status (for GUI) */ /* send message for get status (for GUI) */
@ -192,7 +192,7 @@ void CChannelSet::GetBlockAllConC ( CVector<int>& vecChanID,
} }
} }
} }
Mutex.unlock (); /* release mutex */ Mutex.unlock(); /* release mutex */
} }
void CChannelSet::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses, void CChannelSet::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
@ -220,7 +220,7 @@ void CChannelSet::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
/******************************************************************************\ /******************************************************************************\
* CChannel * * CChannel *
\******************************************************************************/ \******************************************************************************/
CChannel::CChannel () CChannel::CChannel()
{ {
/* init time stamp index counter */ /* init time stamp index counter */
byTimeStampIdxCnt = 0; byTimeStampIdxCnt = 0;
@ -283,17 +283,21 @@ void CChannel::SetNetwOutBlSiFact ( const int iNewBlockSizeFactor )
void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage ) void CChannel::OnSendProtMessage ( CVector<uint8_t> 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 message to actually send the data
emit MessReadyForSending ( vecMessage ); emit MessReadyForSending ( vecMessage );
} // }
else // else
{ // {
// delete send message queue // // delete send message queue
Protocol.DeleteSendMessQueue(); // Protocol.DeleteSendMessQueue();
} // }
} }
@ -301,7 +305,7 @@ void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
void CChannel::SetSockBufSize ( const int iNumBlocks ) void CChannel::SetSockBufSize ( const int iNumBlocks )
{ {
/* this opperation must be done with mutex */ /* this opperation must be done with mutex */
Mutex.lock (); Mutex.lock();
{ {
iCurSockBufSize = iNumBlocks; iCurSockBufSize = iNumBlocks;
@ -314,7 +318,7 @@ void CChannel::SetSockBufSize ( const int iNumBlocks )
SockBuf.Init ( MIN_BLOCK_SIZE_SAMPLES, SockBuf.Init ( MIN_BLOCK_SIZE_SAMPLES,
iNumBlocks + iCurNetwInBlSiFact ); iNumBlocks + iCurNetwInBlSiFact );
} }
Mutex.unlock (); Mutex.unlock();
} }
void CChannel::OnJittBufSizeChange ( int iNewJitBufSize ) void CChannel::OnJittBufSizeChange ( int iNewJitBufSize )
@ -367,7 +371,7 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
/* only process if packet has correct size */ /* only process if packet has correct size */
if ( iNumBytes == iAudComprSizeIn ) if ( iNumBytes == iAudComprSizeIn )
{ {
Mutex.lock (); Mutex.lock();
{ {
/* decompress audio */ /* decompress audio */
CVector<short> vecsDecomprAudio ( AudioCompressionIn.Decode ( vecbyData ) ); CVector<short> vecsDecomprAudio ( AudioCompressionIn.Decode ( vecbyData ) );
@ -402,13 +406,14 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) {
// reset time-out counter // reset time-out counter
iConTimeOut = iConTimeOutStartVal; iConTimeOut = iConTimeOutStartVal;
} }
Mutex.unlock (); Mutex.unlock();
} }
else else
{ {
// only use protocol data if channel is connected // only use protocol data if channel is connected
// must be disabled to be able to receive network buffer size factor changes // 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() ) // if ( IsConnected() )
{ {
@ -442,7 +447,7 @@ bool CChannel::GetData ( CVector<double>& vecdData )
{ {
bool bGetOK = false; bool bGetOK = false;
Mutex.lock (); /* get mutex lock */ Mutex.lock(); /* get mutex lock */
{ {
bGetOK = SockBuf.Get ( vecdData ); bGetOK = SockBuf.Get ( vecdData );
@ -455,12 +460,12 @@ bool CChannel::GetData ( CVector<double>& vecdData )
} }
} }
} }
Mutex.unlock (); /* get mutex unlock */ Mutex.unlock(); /* get mutex unlock */
return bGetOK; return bGetOK;
} }
CVector<unsigned char> CChannel::PrepSendPacket(const CVector<short>& vecsNPacket) CVector<unsigned char> CChannel::PrepSendPacket ( const CVector<short>& vecsNPacket )
{ {
/* if the block is not ready we have to initialize with zero length to /* 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 */ tell the following network send routine that nothing should be sent */
@ -472,7 +477,7 @@ CVector<unsigned char> CChannel::PrepSendPacket(const CVector<short>& vecsNPacke
{ {
/* a packet is ready, compress audio */ /* a packet is ready, compress audio */
vecbySendBuf.Init ( iAudComprSizeOut ); 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 // if we are not connected, send network buffer size factor so that the

View file

@ -235,24 +235,28 @@ void CLlconClientDlg::OnSliderSndBufInChange(int value)
{ {
pClient->GetSndInterface()->SetInNumBuf(value); pClient->GetSndInterface()->SetInNumBuf(value);
TextSndBufIn->setText("In: " + QString().setNum(value)); TextSndBufIn->setText("In: " + QString().setNum(value));
UpdateDisplay();
} }
void CLlconClientDlg::OnSliderSndBufOutChange(int value) void CLlconClientDlg::OnSliderSndBufOutChange(int value)
{ {
pClient->GetSndInterface()->SetOutNumBuf(value); pClient->GetSndInterface()->SetOutNumBuf(value);
TextSndBufOut->setText("Out: " + QString().setNum(value)); TextSndBufOut->setText("Out: " + QString().setNum(value));
UpdateDisplay();
} }
void CLlconClientDlg::OnSliderNetBuf(int value) void CLlconClientDlg::OnSliderNetBuf(int value)
{ {
pClient->SetSockBufSize ( value ); pClient->SetSockBufSize ( value );
TextNetBuf->setText("Size: " + QString().setNum(value)); TextNetBuf->setText("Size: " + QString().setNum(value));
UpdateDisplay();
} }
void CLlconClientDlg::OnSliderNetBufSiFact(int value) void CLlconClientDlg::OnSliderNetBufSiFact(int value)
{ {
pClient->SetNetwBufSizeFact ( value ); pClient->SetNetwBufSizeFact ( value );
TextNetBufSiFact->setText("Fact.: " + QString().setNum(value)); TextNetBufSiFact->setText("Fact.: " + QString().setNum(value));
UpdateDisplay();
} }
void CLlconClientDlg::OnTimerSigMet () void CLlconClientDlg::OnTimerSigMet ()
@ -287,22 +291,26 @@ void CLlconClientDlg::OnTimerSigMet ()
ProgressBarInputLevelL->setProgress ( (int) ceil ( dCurSigLevelL ) ); ProgressBarInputLevelL->setProgress ( (int) ceil ( dCurSigLevelL ) );
ProgressBarInputLevelR->setProgress ( (int) ceil ( dCurSigLevelR ) ); ProgressBarInputLevelR->setProgress ( (int) ceil ( dCurSigLevelR ) );
} }
void CLlconClientDlg::OnTimerStatus () void CLlconClientDlg::UpdateDisplay()
{ {
/* show connection status in status bar */ /* show connection status in status bar */
if ( pClient->IsConnected () && pClient->IsRunning () ) if ( pClient->IsConnected () && pClient->IsRunning () )
{ {
TextLabelStatus->setText ( tr ( "connected" ) ); TextLabelStatus->setText ( tr ( "connected" ) );
} }
else else
{ {
TextLabelStatus->setText ( tr ( "disconnected" ) ); TextLabelStatus->setText ( tr ( "disconnected" ) );
} }
/* response time */ /* response time */
TextLabelStdDevTimer->setText(QString(). TextLabelStdDevTimer->setText(QString().
setNum(pClient->GetTimingStdDev(), 'f', 2) + " ms"); 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) void CLlconClientDlg::customEvent(QCustomEvent* Event)

View file

@ -75,16 +75,18 @@ protected:
CClient* pClient; CClient* pClient;
bool bConnected; bool bConnected;
QTimer TimerSigMet; QTimer TimerSigMet;
QTimer TimerStatus; QTimer TimerStatus;
virtual void customEvent ( QCustomEvent* Event ); virtual void customEvent ( QCustomEvent* Event );
virtual void closeEvent ( QCloseEvent * Event ); virtual void closeEvent ( QCloseEvent * Event );
void UpdateDisplay();
QMenuBar* pMenu; QMenuBar* pMenu;
public slots: public slots:
void OnConnectDisconBut (); void OnConnectDisconBut();
void OnTimerSigMet (); void OnTimerSigMet();
void OnTimerStatus (); void OnTimerStatus() { UpdateDisplay(); }
void OnSliderSndBufInChange ( int value ); void OnSliderSndBufInChange ( int value );
void OnSliderSndBufOutChange ( int value ); void OnSliderSndBufOutChange ( int value );
void OnSliderNetBuf ( int value ); void OnSliderNetBuf ( int value );
@ -92,6 +94,6 @@ public slots:
void OnSliderAudInFader ( int value ) { pClient->SetAudioInFader(value); } void OnSliderAudInFader ( int value ) { pClient->SetAudioInFader(value); }
void OnSliderAudReverb ( int value ) void OnSliderAudReverb ( int value )
{ pClient->SetReverbLevel ( AUD_REVERB_MAX - value ); } { pClient->SetReverbLevel ( AUD_REVERB_MAX - value ); }
void OnRevSelL () { pClient->SetReverbOnLeftChan(true); } void OnRevSelL() { pClient->SetReverbOnLeftChan(true); }
void OnRevSelR () { pClient->SetReverbOnLeftChan(false); } void OnRevSelR() { pClient->SetReverbOnLeftChan(false); }
}; };

View file

@ -1095,7 +1095,7 @@
<name>title</name> <name>title</name>
<string>Measurement Results</string> <string>Measurement Results</string>
</property> </property>
<vbox> <hbox>
<property stdset="1"> <property stdset="1">
<name>margin</name> <name>margin</name>
<number>11</number> <number>11</number>
@ -1108,9 +1108,9 @@
<class>QLayoutWidget</class> <class>QLayoutWidget</class>
<property stdset="1"> <property stdset="1">
<name>name</name> <name>name</name>
<cstring>Layout16</cstring> <cstring>Layout17</cstring>
</property> </property>
<hbox> <vbox>
<property stdset="1"> <property stdset="1">
<name>margin</name> <name>margin</name>
<number>0</number> <number>0</number>
@ -1127,9 +1127,37 @@
</property> </property>
<property stdset="1"> <property stdset="1">
<name>text</name> <name>text</name>
<string> StdDev:</string> <string>StdDev:</string>
</property> </property>
</widget> </widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabelActNetwBufSizeLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Netw. Buf. Size:</string>
</property>
</widget>
</vbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout18</cstring>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget> <widget>
<class>QLabel</class> <class>QLabel</class>
<property stdset="1"> <property stdset="1">
@ -1141,9 +1169,20 @@
<string>val</string> <string>val</string>
</property> </property>
</widget> </widget>
</hbox> <widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabelActNetwBufSize</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>val</string>
</property>
</widget>
</vbox>
</widget> </widget>
</vbox> </hbox>
</widget> </widget>
</hbox> </hbox>
</widget> </widget>