diff --git a/barnard.go b/barnard.go index c5a4fe8..ece9aa2 100644 --- a/barnard.go +++ b/barnard.go @@ -28,8 +28,9 @@ type Barnard struct { TLSConfig tls.Config Stream *gumbleopenal.Stream - Tx bool - Connected bool + Tx bool + AutoTransmit bool // auto-start transmission on connect + Connected bool Ui *uiterm.Ui UiOutput uiterm.Textview diff --git a/client.go b/client.go index f3732f0..f12c113 100644 --- a/client.go +++ b/client.go @@ -110,6 +110,18 @@ func (b *Barnard) OnConnect(e *gumble.ConnectEvent) { b.AddOutputLine(fmt.Sprintf("Welcome message: %s", wmsg)) } b.Ui.Refresh() + + // Auto-start transmission if requested + if b.AutoTransmit && b.Stream != nil && !b.Tx { + err := b.Stream.StartSource(b.UserConfig.GetInputDevice()) + if err != nil { + b.AddOutputLine(fmt.Sprintf("auto-transmit failed: %s", err.Error())) + } else { + b.Tx = true + b.UpdateGeneralStatus(" AutoTx ", true) + b.AddOutputLine("Auto-transmit started") + } + } } func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) { diff --git a/main.go b/main.go index 8963dc5..164414b 100644 --- a/main.go +++ b/main.go @@ -116,6 +116,7 @@ func main() { buffers := flag.Int("buffers", 16, "number of audio buffers to use") profile := flag.Bool("profile", false, "add http server to serve profiles") noiseSuppressionEnabled := flag.Bool("noise-suppression", false, "enable noise suppression for microphone input") + autoTransmit := flag.Bool("auto-transmit", false, "start transmitting immediately on connect") logLevel := flag.String("log", "warn", "log level: debug, info, warn, error") logFile := flag.String("logfile", "", "write logs to this file (in addition to stderr)") @@ -208,6 +209,7 @@ func main() { Config: gumble.NewConfig(), UserConfig: userConfig, Address: *server, + AutoTransmit: *autoTransmit, MutedChannels: make(map[uint32]bool), NoiseSuppressor: noise.NewSuppressor(), }