moved ping time evaluation timer from settings dialog in main dialog, this is a preparation for the implementation that we make use of the ping result in the main windows for a display; we now always send ping messages, not only if the settings dialog is opened since we did not see performance degradations caused by the ping messages

This commit is contained in:
Volker Fischer 2011-01-09 14:20:58 +00:00
parent fcdc4daeac
commit 897da0c6bd
4 changed files with 61 additions and 55 deletions

View file

@ -330,9 +330,6 @@ cbGUIDesignFancy->setVisible ( false );
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
this, SLOT ( OnTimerStatus() ) );
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
this, SLOT ( OnTimerPing() ) );
// slider controls
QObject::connect ( SliderNetBuf, SIGNAL ( valueChanged ( int ) ),
this, SLOT ( OnSliderNetBuf ( int ) ) );
@ -374,9 +371,6 @@ cbGUIDesignFancy->setVisible ( false );
this, SLOT ( OnDriverSetupBut() ) );
// misc
QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ),
this, SLOT ( OnPingTimeResult ( int ) ) );
QObject::connect ( &SndCrdBufferDelayButtonGroup,
SIGNAL ( buttonClicked ( QAbstractButton* ) ), this,
SLOT ( OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* ) ) );
@ -494,20 +488,6 @@ void CClientSettingsDlg::UpdateSoundChannelSelectionFrame()
#endif
}
void CClientSettingsDlg::showEvent ( QShowEvent* )
{
// only activate ping timer if window is actually shown
TimerPing.start ( PING_UPDATE_TIME );
UpdateDisplay();
}
void CClientSettingsDlg::hideEvent ( QHideEvent* )
{
// if window is closed, stop timer for ping
TimerPing.stop();
}
void CClientSettingsDlg::OnDriverSetupBut()
{
pClient->OpenSndCrdDriverSetup();
@ -627,17 +607,10 @@ void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton
UpdateDisplay();
}
void CClientSettingsDlg::OnTimerPing()
void CClientSettingsDlg::SetPingTimeResult ( const int iPingTime,
const int iOverallDelayMs,
const int iOverallDelayLEDColor )
{
// send ping message to server
pClient->SendPingMess();
}
void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
{
// calculate overall delay
const int iOverallDelayMs = pClient->EstimatedOverallDelay ( iPingTime );
// apply values to GUI labels, take special care if ping time exceeds
// a certain value
if ( iPingTime > 500 )
@ -655,22 +628,8 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
QString().setNum ( iOverallDelayMs ) + " ms" );
}
// color definition: < 40 ms green, < 65 ms yellow, otherwise red
if ( iOverallDelayMs <= 40 )
{
CLEDOverallDelay->SetLight ( MUL_COL_LED_GREEN );
}
else
{
if ( iOverallDelayMs <= 65 )
{
CLEDOverallDelay->SetLight ( MUL_COL_LED_YELLOW );
}
else
{
CLEDOverallDelay->SetLight ( MUL_COL_LED_RED );
}
}
// set current LED status
CLEDOverallDelay->SetLight ( iOverallDelayLEDColor );
}
void CClientSettingsDlg::UpdateDisplay()

View file

@ -64,6 +64,9 @@ public:
Qt::WindowFlags f = 0 );
void SetStatus ( const int iMessType, const int iStatus );
void SetPingTimeResult ( const int iPingTime,
const int iOverallDelayMs,
const int iOverallDelayLEDColor );
protected:
void UpdateJitterBufferFrame();
@ -72,18 +75,15 @@ protected:
QString GenSndCrdBufferDelayString ( const int iFrameSize,
const QString strAddText = "" );
virtual void showEvent ( QShowEvent* );
virtual void hideEvent ( QHideEvent* );
virtual void showEvent ( QShowEvent* ) { UpdateDisplay(); }
CClient* pClient;
QTimer TimerStatus;
QTimer TimerPing;
QButtonGroup SndCrdBufferDelayButtonGroup;
void UpdateDisplay();
public slots:
void OnTimerStatus() { UpdateDisplay(); }
void OnTimerPing();
void OnSliderNetBuf ( int value );
void OnSliderSndCrdBufferDelay ( int value );
void OnAutoJitBuf ( int value );
@ -92,7 +92,6 @@ protected:
void OnUseHighQualityAudioStateChanged ( int value );
void OnUseStereoStateChanged ( int value );
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
void OnPingTimeResult ( int iPingTime );
void OnSoundCrdSelection ( int iSndDevIdx );
void OnSndCrdLeftInChannelSelection ( int iChanIdx );
void OnSndCrdRightInChannelSelection ( int iChanIdx );

View file

@ -324,6 +324,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
this, SLOT ( OnTimerStatus() ) );
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
this, SLOT ( OnTimerPing() ) );
// sliders
QObject::connect ( SliderAudInFader, SIGNAL ( valueChanged ( int ) ),
this, SLOT ( OnSliderAudInFader ( int ) ) );
@ -365,6 +368,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
SIGNAL ( ChatTextReceived ( QString ) ),
this, SLOT ( OnChatTextReceived ( QString ) ) );
QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ),
this, SLOT ( OnPingTimeResult ( int ) ) );
QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ),
this, SLOT ( OnGUIDesignChanged() ) );
@ -646,6 +652,41 @@ void CLlconClientDlg::OnTimerSigMet()
MultiColorLEDBarInputLevelR->setValue ( (int) ceil ( dCurSigLevelR ) );
}
void CLlconClientDlg::OnTimerPing()
{
// send ping message to server
pClient->SendPingMess();
}
void CLlconClientDlg::OnPingTimeResult ( int iPingTime )
{
// calculate overall delay
const int iOverallDelayMs = pClient->EstimatedOverallDelay ( iPingTime );
// color definition: <= 40 ms green, <= 65 ms yellow, otherwise red
int iOverallDelayLEDColor;
if ( iOverallDelayMs <= 40 )
{
iOverallDelayLEDColor = MUL_COL_LED_GREEN;
}
else
{
if ( iOverallDelayMs <= 65 )
{
iOverallDelayLEDColor = MUL_COL_LED_YELLOW;
}
else
{
iOverallDelayLEDColor = MUL_COL_LED_RED;
}
}
// set ping time result to general settings dialog
ClientSettingsDlg.SetPingTimeResult ( iPingTime,
iOverallDelayMs,
iOverallDelayLEDColor );
}
void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
{
// start/stop client, set button text
@ -675,8 +716,9 @@ void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
{
PushButtonConnect->setText ( CON_BUT_DISCONNECTTEXT );
// start timer for level meter bar
// start timer for level meter bar and ping time measurement
TimerSigMet.start ( LEVELMETER_UPDATE_TIME );
TimerPing.start ( PING_UPDATE_TIME );
}
}
else
@ -707,6 +749,9 @@ void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
MultiColorLEDBarInputLevelL->setValue ( 0 );
MultiColorLEDBarInputLevelR->setValue ( 0 );
// stop ping time measurement timer
TimerPing.stop();
// immediately update status bar
OnTimerStatus();

View file

@ -87,6 +87,7 @@ protected:
bool bUnreadChatMessage;
QTimer TimerSigMet;
QTimer TimerStatus;
QTimer TimerPing;
virtual void customEvent ( QEvent* Event );
virtual void closeEvent ( QCloseEvent* Event );
@ -102,6 +103,8 @@ public slots:
void OnConnectDisconBut();
void OnTimerSigMet();
void OnTimerStatus() { UpdateDisplay(); }
void OnTimerPing();
void OnPingTimeResult ( int iPingTime );
void OnOpenGeneralSettings();
void OnOpenChatDialog() { ShowChatWindow(); }
void OnSliderAudInFader ( int value );