make per-user audio state thread-safe

Move volume, boost, mute, and OpenAL source behind accessors guarded
by a per-user mutex.
The audio goroutine reads these fields on every decoded packet while
the UI writes them from key handlers, which is a data race on the
gain a stream is currently rendering with.

Also add the per-user sequence fields the decoder needs to notice
gaps in a user's audio stream.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Brandon McGinty
2026-08-20 14:22:33 -04:00
co-authored by Claude Opus 5
parent b67940ddbc
commit 60470ad091
6 changed files with 117 additions and 50 deletions
+3 -3
View File
@@ -179,11 +179,11 @@ func (b *Barnard) OnUserChange(e *gumble.UserChangeEvent) {
// If the channel is muted, ensure the user is muted
if b.MutedChannels[e.User.Channel.ID] {
// Only mute if not already muted
if !e.User.LocallyMuted {
if !e.User.LocallyMuted() {
b.UserConfig.ToggleMute(e.User)
}
if e.User.AudioSource != nil {
e.User.AudioSource.SetGain(0)
if source := e.User.AudioSource(); source != nil {
source.SetGain(0)
}
}
}