mirror of
https://github.com/mumble-voip/mumble.git
synced 2025-10-26 11:19:16 +00:00
Fix bandwidth estimate for UserInformation and Ice
This commit is contained in:
parent
8463c822e7
commit
0fc5d5542d
@ -481,15 +481,26 @@ int BandwidthRecord::idleSeconds() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int BandwidthRecord::bandwidth() const {
|
int BandwidthRecord::bandwidth() const {
|
||||||
int sincelast = static_cast<int>(a_qtWhen[(iRecNum + N_BANDWIDTH_SLOTS - 1) % N_BANDWIDTH_SLOTS].elapsed() / 10000LL);
|
int sum = 0;
|
||||||
int todo = N_BANDWIDTH_SLOTS - sincelast;
|
int records = 0;
|
||||||
if (todo < 0)
|
quint64 elapsed = 0ULL;
|
||||||
|
|
||||||
|
for(int i=1;i<N_BANDWIDTH_SLOTS;++i) {
|
||||||
|
int idx = (iRecNum + N_BANDWIDTH_SLOTS - i) % N_BANDWIDTH_SLOTS;
|
||||||
|
quint64 e = a_qtWhen[idx].elapsed();
|
||||||
|
if (e > 1000000ULL) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
++records;
|
||||||
|
sum += a_iBW[idx];
|
||||||
|
elapsed = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elapsed < 250000ULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int sum = 0;
|
return static_cast<int>((sum * 1000000ULL) / elapsed);
|
||||||
for (int i=1;i<=todo;++i)
|
|
||||||
sum += a_iBW[(iRecNum+N_BANDWIDTH_SLOTS - i) % N_BANDWIDTH_SLOTS];
|
|
||||||
return (sum*100)/N_BANDWIDTH_SLOTS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecEvent::ExecEvent(boost::function<void ()> f) : QEvent(static_cast<QEvent::Type>(EXEC_QEVENT)) {
|
ExecEvent::ExecEvent(boost::function<void ()> f) : QEvent(static_cast<QEvent::Type>(EXEC_QEVENT)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user