Fix calculate headroom

This commit is contained in:
世界 2022-09-30 21:02:14 +08:00
parent 9a83e35b71
commit cb9b17d6a4
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -68,12 +68,11 @@ func CalculateFrontHeadroom(writer any) int {
if headroomWriter, needHeadroom := writer.(FrontHeadroom); needHeadroom {
headroom = headroomWriter.FrontHeadroom()
}
if upstream, hasUpstream := writer.(common.WithUpstream); hasUpstream {
if upstreamWriter, hasUpstreamWriter := writer.(WithUpstreamWriter); hasUpstreamWriter {
headroom += CalculateFrontHeadroom(upstreamWriter.UpstreamWriter())
} else if upstream, hasUpstream := writer.(common.WithUpstream); hasUpstream {
headroom += CalculateFrontHeadroom(upstream.Upstream())
}
if upstream, hasUpstream := writer.(WithUpstreamWriter); hasUpstream {
headroom += CalculateFrontHeadroom(upstream.UpstreamWriter())
}
return headroom
}
@ -82,12 +81,11 @@ func CalculateRearHeadroom(writer any) int {
if headroomWriter, needHeadroom := writer.(RearHeadroom); needHeadroom {
headroom = headroomWriter.RearHeadroom()
}
if upstream, hasUpstream := writer.(common.WithUpstream); hasUpstream {
if upstreamWriter, hasUpstreamWriter := writer.(WithUpstreamWriter); hasUpstreamWriter {
headroom += CalculateRearHeadroom(upstreamWriter.UpstreamWriter())
} else if upstream, hasUpstream := writer.(common.WithUpstream); hasUpstream {
headroom += CalculateRearHeadroom(upstream.Upstream())
}
if upstream, hasUpstream := writer.(WithUpstreamWriter); hasUpstream {
headroom += CalculateRearHeadroom(upstream.UpstreamWriter())
}
return headroom
}