From 181b325c2d3b950fa665b203f3ca60092b9a3fb4 Mon Sep 17 00:00:00 2001 From: "Brandon McGinty (deepseek)" Date: Sat, 8 Aug 2026 19:18:35 -0400 Subject: [PATCH] fix: add minimum Opus bitrate floor in encoder Add a defensive floor of 8000 bps in the Encode method, preventing the encoder from being configured with an invalidly low bitrate even if AudioDataBytes is somehow set to a very small value. --- gumble/opus/opus.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gumble/opus/opus.go b/gumble/opus/opus.go index 23e8eee..39eb8c4 100644 --- a/gumble/opus/opus.go +++ b/gumble/opus/opus.go @@ -68,6 +68,9 @@ func (e *Encoder) Encode(pcm []int16, _, maxDataBytes int) ([]byte, error) { // Opus encodes best when the bitrate target is set properly rather than // relying on truncation, which can produce incomplete or corrupt frames. bitrate := maxDataBytes * 8 * 100 + if bitrate < 8000 { + bitrate = 8000 // Opus minimum viable bitrate for voice + } _ = e.Encoder.SetBitrate(bitrate) buf := make([]byte, maxDataBytes)