Skip to content

Commit c306cc2

Browse files
Convert BandwithProbing's bytesLeftOver to double. (#2323)
So partial-byte leftovers accumulate properly.
1 parent ec7d461 commit c306cc2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

jvb/src/main/kotlin/org/jitsi/videobridge/cc/BandwidthProbing.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class BandwidthProbing(
5454
* bandwidth, and also handles the use when the number of bytes we want to
5555
* send is less than the size of an RTP header.
5656
*/
57-
private var bytesLeftOver = 0
57+
private var bytesLeftOver: Double = 0.0
5858

5959
private var latestBwe: Long = -1
6060

@@ -80,7 +80,7 @@ class BandwidthProbing(
8080
val totalNeededBps = bitrateControllerStatus.currentIdealBps - bitrateControllerStatus.currentTargetBps
8181
if (totalNeededBps < 1 || !bitrateControllerStatus.hasNonIdealLayer) {
8282
// Don't need to send any probing.
83-
bytesLeftOver = 0
83+
bytesLeftOver = 0.0
8484
zeroStats()
8585
return
8686
}
@@ -121,10 +121,10 @@ class BandwidthProbing(
121121
if (bytesNeeded >= 1) {
122122
val bytesSent = probingDataSender.sendProbing(bitrateControllerStatus.activeSsrcs, bytesNeeded.toInt())
123123
probingBitrate.update(bytesSent.bytes)
124-
bytesLeftOver = (bytesNeeded - bytesSent).coerceAtLeast(0.0).toInt()
124+
bytesLeftOver = (bytesNeeded - bytesSent).coerceAtLeast(0.0)
125125
timeSeriesPoint?.addField("bytes_sent", bytesSent)?.addField("new_bytes_left_over", bytesLeftOver)
126126
} else {
127-
bytesLeftOver = bytesNeeded.coerceAtLeast(0.0).toInt()
127+
bytesLeftOver = bytesNeeded.coerceAtLeast(0.0)
128128
}
129129

130130
if (timeSeriesLogger.isTraceEnabled) {

0 commit comments

Comments
 (0)