Reformat stats display, protect against division by zero.

This commit is contained in:
Juliusz Chroboczek
2021-05-07 02:23:10 +02:00
parent b1bb427f06
commit 86b6c71ca0
3 changed files with 29 additions and 18 deletions
+5 -2
View File
@@ -23,8 +23,11 @@ func (c *webClient) GetStats() *stats.Client {
tracks := up.getTracks()
for _, t := range tracks {
s := t.cache.GetStats(false)
loss := float64(s.Expected - s.Received) /
float64(s.Expected)
var loss float64
if s.Expected > 0 {
loss = float64(s.Expected-s.Received) /
float64(s.Expected)
}
jitter := time.Duration(t.jitter.Jitter()) *
(time.Second / time.Duration(t.jitter.HZ()))
rate, _ := t.rate.Estimate()