release jitter buffer entries as they are consumed

Packets are removed from the jitter buffer by resliceing past them, which
leaves the popped entries in the backing array. Each one pins a decoded
audio frame until the array is next reallocated.

Clear the slot before resliceing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Brandon McGinty
2026-08-24 12:31:25 -04:00
co-authored by Claude Opus 5
parent 7647fdb233
commit da1c6bdc26
+4
View File
@@ -613,6 +613,9 @@ func (s *Stream) OnAudioStream(e *gumble.AudioStreamEvent) {
return nil
}
p := jitterBuf[0]
// Clear the slot before resliceing: the popped entries stay in
// the backing array otherwise, pinning a decoded frame each.
jitterBuf[0] = nil
jitterBuf = jitterBuf[1:]
jitterDuration -= audioPacketDuration(p)
// Frame numbers are Mumble timestamps in 10 ms units.
@@ -694,6 +697,7 @@ func (s *Stream) OnAudioStream(e *gumble.AudioStreamEvent) {
jitterBuf[0].Sequence, e.User.Name, jitterNextSeq, len(jitterBuf))
}
jitterDuration -= audioPacketDuration(jitterBuf[0])
jitterBuf[0] = nil
jitterBuf = jitterBuf[1:]
continue
}