Updated barnard to use openal for sound by default. This should bring with it pipewire or pulseaudio support.

This commit is contained in:
Storm Dragon
2025-12-16 15:44:10 -05:00
parent 9fe7d7ad87
commit cfbefd3f7d
3 changed files with 297 additions and 259 deletions
+12
View File
@@ -141,6 +141,18 @@ Pass the -list_devices parameter to barnard to be given a list of audio input an
Copy lines from the above list into inputdevice and outputdevice as desired. Copy lines from the above list into inputdevice and outputdevice as desired.
To clear your inputdevice or outputdevice options and set them to defaults, set them to "" or delete them entirely. To clear your inputdevice or outputdevice options and set them to defaults, set them to "" or delete them entirely.
### Audio Backends (ALSA, PipeWire, PulseAudio)
Barnard uses OpenAL Soft for audio. By default it will pick the first available backend (often ALSA), but you can force a specific driver:
- Command line: `./barnard --audio-driver pipewire` (or `pulse`, `alsa`, `jack`)
- Config file: add `audiodriver = "pipewire"` to your `~/.barnard.toml`
- Environment: `ALSOFT_DRIVERS=pipewire ./barnard` (takes precedence over config)
If PipeWire or PulseAudio support is missing, install OpenAL Soft with the corresponding backend enabled (e.g., `libopenal1` or `openal-soft` packages built with PipeWire). After changing drivers, rerun with `--list_devices` to confirm the desired devices appear.
Leaving `audiodriver` empty in the config keeps the OpenAL default ordering (PipeWire/Pulse first if available, then ALSA).
## Keystrokes ## Keystrokes
You can see the below keystrokes in your config file. You can see the below keystrokes in your config file.
+13 -1
View File
@@ -2,9 +2,9 @@ package config
import ( import (
"fmt" "fmt"
"git.stormux.org/storm/barnard/gumble/gumble"
"git.stormux.org/storm/barnard/uiterm" "git.stormux.org/storm/barnard/uiterm"
"github.com/pelletier/go-toml/v2" "github.com/pelletier/go-toml/v2"
"git.stormux.org/storm/barnard/gumble/gumble"
"io/ioutil" "io/ioutil"
"os" "os"
"os/user" "os/user"
@@ -19,6 +19,7 @@ type Config struct {
type exportableConfig struct { type exportableConfig struct {
Hotkeys *Hotkeys Hotkeys *Hotkeys
AudioDriver *string
MicVolume *float32 MicVolume *float32
InputDevice *string InputDevice *string
OutputDevice *string OutputDevice *string
@@ -98,6 +99,10 @@ func (c *Config) LoadConfig() {
micvol := float32(1.0) micvol := float32(1.0)
jc.MicVolume = &micvol jc.MicVolume = &micvol
} }
if c.config.AudioDriver == nil {
driver := string("")
jc.AudioDriver = &driver
}
if c.config.InputDevice == nil { if c.config.InputDevice == nil {
idev := string("") idev := string("")
jc.InputDevice = &idev jc.InputDevice = &idev
@@ -203,6 +208,13 @@ func (c *Config) GetNotifyCommand() *string {
return c.config.NotifyCommand return c.config.NotifyCommand
} }
func (c *Config) GetAudioDriver() string {
if c.config.AudioDriver == nil {
return ""
}
return *c.config.AudioDriver
}
func (c *Config) GetInputDevice() *string { func (c *Config) GetInputDevice() *string {
return c.config.InputDevice return c.config.InputDevice
} }
+16 -2
View File
@@ -15,15 +15,15 @@ import (
//"github.com/google/shlex" //"github.com/google/shlex"
"crypto/tls" "crypto/tls"
"flag" "flag"
"github.com/alessio/shellescape"
"git.stormux.org/storm/barnard/audio" "git.stormux.org/storm/barnard/audio"
"git.stormux.org/storm/barnard/config" "git.stormux.org/storm/barnard/config"
"git.stormux.org/storm/barnard/noise" "git.stormux.org/storm/barnard/noise"
"github.com/alessio/shellescape"
"git.stormux.org/storm/barnard/gumble/go-openal/openal"
"git.stormux.org/storm/barnard/gumble/gumble" "git.stormux.org/storm/barnard/gumble/gumble"
_ "git.stormux.org/storm/barnard/gumble/opus" _ "git.stormux.org/storm/barnard/gumble/opus"
"git.stormux.org/storm/barnard/uiterm" "git.stormux.org/storm/barnard/uiterm"
"git.stormux.org/storm/barnard/gumble/go-openal/openal"
) )
func show_devs(name string, args []string) { func show_devs(name string, args []string) {
@@ -109,6 +109,7 @@ func main() {
insecure := flag.Bool("insecure", false, "skip server certificate verification") insecure := flag.Bool("insecure", false, "skip server certificate verification")
certificate := flag.String("certificate", "", "PEM encoded certificate and private key") certificate := flag.String("certificate", "", "PEM encoded certificate and private key")
cfgfn := flag.String("config", "~/.barnard.toml", "Path to TOML formatted configuration file") cfgfn := flag.String("config", "~/.barnard.toml", "Path to TOML formatted configuration file")
audioDriver := flag.String("audio-driver", "", "preferred OpenAL backend (pipewire, pulse, alsa, jack)")
list_devices := flag.Bool("list_devices", false, "do not connect; instead, list available audio devices and exit") list_devices := flag.Bool("list_devices", false, "do not connect; instead, list available audio devices and exit")
fifo := flag.String("fifo", "", "path of a FIFO from which to read commands") fifo := flag.String("fifo", "", "path of a FIFO from which to read commands")
serverSet := false serverSet := false
@@ -149,6 +150,19 @@ func main() {
certificate = userConfig.GetCertificate() certificate = userConfig.GetCertificate()
} }
driver := strings.TrimSpace(*audioDriver)
if driver == "" {
// Environment variable takes precedence over config
if envDriver := os.Getenv("ALSOFT_DRIVERS"); envDriver != "" {
driver = envDriver
} else {
driver = strings.TrimSpace(userConfig.GetAudioDriver())
}
}
if driver != "" {
os.Setenv("ALSOFT_DRIVERS", driver)
}
if os.Getenv("ALSOFT_LOGLEVEL") == "" { if os.Getenv("ALSOFT_LOGLEVEL") == "" {
os.Setenv("ALSOFT_LOGLEVEL", "0") os.Setenv("ALSOFT_LOGLEVEL", "0")
} }