reuse the stereo Opus encoder across connections

Every connect built a fresh stereo encoder for file playback. Each one holds
a little under a megabyte of encoder state, so on a flaky link that is close
to a megabyte of churn per reconnect for no benefit; the encoder is already
reset when file playback ends.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Brandon McGinty
2026-08-24 12:32:30 -04:00
co-authored by Claude Opus 5
parent 5cdb2684b5
commit 0d62f745ca
2 changed files with 10 additions and 2 deletions
+4
View File
@@ -70,6 +70,10 @@ type Barnard struct {
// Added for file playback
FileStream *fileplayback.Player
FileStreamMutex sync.Mutex
// stereoEncoder is reused across connections. Each one holds a little
// under a megabyte of encoder state, so building a fresh one per
// reconnect is pure churn; it is reset when file playback ends.
stereoEncoder gumble.AudioEncoder
// Added for tone test mode (bypasses all soundcard/OpenAL)
ToneTest bool