ci-platforms / windows amd64 smoke (push) Skipped
ci / release (push) Successful in 8m58s
ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
ci / checks (push) Successful in 4m46s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 13m28s
18 lines
573 B
Go
18 lines
573 B
Go
package web
|
|
|
|
import "math"
|
|
|
|
const messageMinimumBlocks = 6
|
|
|
|
// messageTargetBlocks adds one block beyond reported browser processing latency, with a six-block minimum and twelve-block cap; posted messages have no SAB ring bound.
|
|
func messageTargetBlocks(latency float64, rate, frames int) int {
|
|
if rate <= 0 || frames <= 0 || latency <= 0 || math.IsNaN(latency) || math.IsInf(latency, 0) {
|
|
return messageMinimumBlocks
|
|
}
|
|
blocks := latency * float64(rate) / float64(frames)
|
|
if blocks >= 11 {
|
|
return 12
|
|
}
|
|
return max(messageMinimumBlocks, int(math.Ceil(blocks))+1)
|
|
}
|