Serialize OpenAL playback on a dedicated thread

This commit is contained in:
Brandon McGinty (chatgpt)
2026-08-09 12:55:55 -04:00
committed by Brandon McGinty
parent 0f2eb4408f
commit 8c0887d562
4 changed files with 105 additions and 62 deletions
+6 -15
View File
@@ -35,17 +35,13 @@ func (ti TreeItem) TreeItemStyle(fg, bg uiterm.Attribute, active bool) (uiterm.A
func (b *Barnard) changeVolume(users []*gumble.User, change float32) {
for _, u := range users {
au := u.AudioSource()
if au == nil {
if b.Stream == nil {
continue
}
var boost uint16
var cv float32
var ng float32
var curboost float32
curboost = float32((u.Boost() - 1)) / 10
cv = au.GetGain() + curboost
ng = cv + change
curboost := float32((u.Boost() - 1)) / 10
ng = u.Volume() + curboost + change
boost = uint16(1)
if ng > 1.0 {
perc := uint16((ng * 10)) - 10
@@ -58,9 +54,7 @@ func (b *Barnard) changeVolume(users []*gumble.User, change float32) {
}
u.SetBoost(boost)
u.SetVolume(ng)
if !u.LocallyMuted() {
au.SetGain(ng)
}
b.Stream.UpdateUserGain(u)
b.UserConfig.UpdateConfig(u)
}
b.UserConfig.SaveConfig()
@@ -68,16 +62,13 @@ func (b *Barnard) changeVolume(users []*gumble.User, change float32) {
func (b *Barnard) resetVolume(users []*gumble.User) {
for _, u := range users {
au := u.AudioSource()
if au == nil {
if b.Stream == nil {
continue
}
// Reset to original volume (1.0) and boost (1)
u.SetBoost(uint16(1))
u.SetVolume(1.0)
if !u.LocallyMuted() {
au.SetGain(1.0)
}
b.Stream.UpdateUserGain(u)
b.UserConfig.UpdateConfig(u)
}
b.UserConfig.SaveConfig()