make the ping times reported in the server list more stable

This commit is contained in:
Volker Fischer 2020-04-16 22:22:53 +02:00
parent 3fd5dda19b
commit f6123abaed
4 changed files with 55 additions and 57 deletions

View file

@ -8,6 +8,8 @@
* improved auto jitter buffer for 64 samples frame size * improved auto jitter buffer for 64 samples frame size
* the ping times in the server list are now more stable
TODO offer the Jamulus ASIO settingspanel in case of an ASIO ERROR to fix, e.g., incorrect sample rate (https://sourceforge.net/p/llcon/discussion/533517/thread/777663cf94/#035f) TODO offer the Jamulus ASIO settingspanel in case of an ASIO ERROR to fix, e.g., incorrect sample rate (https://sourceforge.net/p/llcon/discussion/533517/thread/777663cf94/#035f)

View file

@ -1031,29 +1031,9 @@ void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
int iPingTime, int iPingTime,
int iNumClients ) int iNumClients )
{ {
// color definition: <= 25 ms green, <= 50 ms yellow, otherwise red
CMultiColorLED::ELightColor ePingTimeLEDColor;
if ( iPingTime <= 25 )
{
ePingTimeLEDColor = CMultiColorLED::RL_GREEN;
}
else
{
if ( iPingTime <= 50 )
{
ePingTimeLEDColor = CMultiColorLED::RL_YELLOW;
}
else
{
ePingTimeLEDColor = CMultiColorLED::RL_RED;
}
}
// update connection dialog server list // update connection dialog server list
ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr, ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr,
iPingTime, iPingTime,
ePingTimeLEDColor,
iNumClients ); iNumClients );
} }

View file

@ -652,9 +652,8 @@ void CConnectDlg::OnTimerPing()
} }
} }
void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr, void CConnectDlg::SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr,
const int iPingTime, const int iPingTime,
const CMultiColorLED::ELightColor ePingTimeLEDColor,
const int iNumClients ) const int iNumClients )
{ {
// apply the received ping time to the correct server list entry // apply the received ping time to the correct server list entry
@ -664,33 +663,62 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress&
{ {
// check if this is the first time a ping time is set // check if this is the first time a ping time is set
const bool bIsFirstPing = pCurListViewItem->text ( 1 ).isEmpty(); const bool bIsFirstPing = pCurListViewItem->text ( 1 ).isEmpty();
bool bDoSorting = false;
// update the color of the ping time font // update minimum ping time column (invisible, used for sorting) if
switch ( ePingTimeLEDColor ) // the new value is smaller than the old value
int iMinPingTime = pCurListViewItem->text ( 4 ).toInt();
if ( iMinPingTime > iPingTime )
{
// update the minimum ping time with the new lowest value
iMinPingTime = iPingTime;
// we pad to a total of 8 characters with zeros to make sure the
// sorting is done correctly
pCurListViewItem->setText ( 4, QString ( "%1" ).arg (
iPingTime, 8, 10, QLatin1Char ( '0' ) ) );
// update the sorting (lowest number on top)
bDoSorting = true;
}
// for debugging it is good to see the current ping time in the list
// and not the minimum ping time -> overwrite the value for debugging
if ( bShowCompleteRegList )
{
iMinPingTime = iPingTime;
}
// Only show minimum ping time in the list since this is the important
// value. Temporary bad ping measurements are of no interest.
// Color definition: <= 25 ms green, <= 50 ms yellow, otherwise red
if ( iMinPingTime <= 25 )
{ {
case CMultiColorLED::RL_GREEN:
pCurListViewItem->setForeground ( 1, Qt::darkGreen ); pCurListViewItem->setForeground ( 1, Qt::darkGreen );
break; }
else
case CMultiColorLED::RL_YELLOW: {
if ( iMinPingTime <= 50 )
{
pCurListViewItem->setForeground ( 1, Qt::darkYellow ); pCurListViewItem->setForeground ( 1, Qt::darkYellow );
break; }
else
default: // including "CMultiColorLED::RL_RED" {
pCurListViewItem->setForeground ( 1, Qt::red ); pCurListViewItem->setForeground ( 1, Qt::red );
break; }
} }
// update ping text, take special care if ping time exceeds a // update ping text, take special care if ping time exceeds a
// certain value // certain value
if ( iPingTime > 500 ) if ( iMinPingTime > 500 )
{ {
pCurListViewItem->setText ( 1, ">500 ms" ); pCurListViewItem->setText ( 1, ">500 ms" );
} }
else else
{ {
pCurListViewItem-> pCurListViewItem->
setText ( 1, QString().setNum ( iPingTime ) + " ms" ); setText ( 1, QString().setNum ( iMinPingTime ) + " ms" );
} }
// update number of clients text // update number of clients text
@ -714,24 +742,13 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress&
pCurListViewItem->setHidden ( false ); pCurListViewItem->setHidden ( false );
} }
// update minimum ping time column (invisible, used for sorting) if // Update sorting. Note that the sorting must be the last action for the
// the new value is smaller than the old value // current item since the topLevelItem ( iIdx ) is then no longer valid.
if ( pCurListViewItem->text ( 4 ).toInt() > iPingTime ) if ( bDoSorting && !bShowCompleteRegList ) // do not sort if "show all servers"
{
// we pad to a total of 8 characters with zeros to make sure the
// sorting is done correctly
pCurListViewItem->setText ( 4, QString ( "%1" ).arg (
iPingTime, 8, 10, QLatin1Char ( '0' ) ) );
// Update the sorting (lowest number on top).
// Note that the sorting must be the last action for the current
// item since the topLevelItem ( iIdx ) is then no longer valid.
if ( !bShowCompleteRegList ) // do not sort if "show all servers"
{ {
lvwServers->sortByColumn ( 4, Qt::AscendingOrder ); lvwServers->sortByColumn ( 4, Qt::AscendingOrder );
} }
} }
}
// if no server item has childs, do not show decoration // if no server item has childs, do not show decoration
bool bAnyListItemHasChilds = false; bool bAnyListItemHasChilds = false;

View file

@ -60,9 +60,8 @@ public:
void SetConnClientsList ( const CHostAddress& InetAddr, void SetConnClientsList ( const CHostAddress& InetAddr,
const CVector<CChannelInfo>& vecChanInfo ); const CVector<CChannelInfo>& vecChanInfo );
void SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr, void SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr,
const int iPingTime, const int iPingTime,
const CMultiColorLED::ELightColor ePingTimeLEDColor,
const int iNumClients ); const int iNumClients );
#ifdef ENABLE_CLIENT_VERSION_AND_OS_DEBUGGING #ifdef ENABLE_CLIENT_VERSION_AND_OS_DEBUGGING