From da1c6bdc26062118fd3f655d123eb685403de047 Mon Sep 17 00:00:00 2001 From: Brandon McGinty Date: Mon, 24 Aug 2026 12:31:25 -0400 Subject: [PATCH] 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 --- gumble/gumbleopenal/stream.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gumble/gumbleopenal/stream.go b/gumble/gumbleopenal/stream.go index 2994598..b00ba24 100644 --- a/gumble/gumbleopenal/stream.go +++ b/gumble/gumbleopenal/stream.go @@ -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 }