Add outgoing audio packet interval option
This commit is contained in:
committed by
Brandon McGinty
parent
893908f9a1
commit
d338925da6
@@ -11,6 +11,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
barnlog "git.stormux.org/storm/barnard/log"
|
||||
|
||||
@@ -84,6 +85,7 @@ func main() {
|
||||
configSet := false
|
||||
certificateSet := false
|
||||
buffers := flag.Int("buffers", 16, "number of audio buffers to use")
|
||||
audioInterval := flag.Int("audio-interval", 10, "outgoing audio packet duration in ms (10, 20, 40, or 60)")
|
||||
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")
|
||||
@@ -94,6 +96,10 @@ func main() {
|
||||
logFile := flag.String("logfile", "", "write logs to this file (logging is disabled when omitted)")
|
||||
|
||||
flag.Parse()
|
||||
selectedAudioInterval, err := audioIntervalDuration(*audioInterval)
|
||||
if err != nil {
|
||||
handle_raw_error(err)
|
||||
}
|
||||
|
||||
// Set up logging
|
||||
var level barnlog.Level
|
||||
@@ -192,6 +198,7 @@ func main() {
|
||||
NoiseSuppressor: noise.NewSuppressor(),
|
||||
}
|
||||
b.Config.Buffers = *buffers
|
||||
b.Config.AudioInterval = selectedAudioInterval
|
||||
b.Config.DisableUDP = *tcpOnly
|
||||
|
||||
b.Hotkeys = b.UserConfig.GetHotkeys()
|
||||
@@ -238,6 +245,18 @@ func main() {
|
||||
handle_error(&b)
|
||||
}
|
||||
|
||||
// audioIntervalDuration converts the packet duration requested at startup to
|
||||
// one of the Opus durations supported by Mumble.
|
||||
func audioIntervalDuration(milliseconds int) (time.Duration, error) {
|
||||
interval := time.Duration(milliseconds) * time.Millisecond
|
||||
switch interval {
|
||||
case 10 * time.Millisecond, 20 * time.Millisecond, 40 * time.Millisecond, 60 * time.Millisecond:
|
||||
return interval, nil
|
||||
default:
|
||||
return 0, fmt.Errorf("audio interval must be 10, 20, 40, or 60 ms, got %d", milliseconds)
|
||||
}
|
||||
}
|
||||
|
||||
// serverAddress adds Mumble's default port without corrupting an IPv6 literal.
|
||||
func serverAddress(address string) string {
|
||||
if _, port, err := net.SplitHostPort(address); err == nil && port != "" {
|
||||
|
||||
Reference in New Issue
Block a user