Add configurable incoming audio jitter buffer
This commit is contained in:
committed by
Brandon McGinty
parent
d338925da6
commit
c0ef036934
@@ -86,6 +86,7 @@ func main() {
|
||||
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)")
|
||||
jitterBuffer := flag.Int("jitter-buffer", 40, "incoming per-user audio buffer in ms (0, 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")
|
||||
@@ -100,6 +101,10 @@ func main() {
|
||||
if err != nil {
|
||||
handle_raw_error(err)
|
||||
}
|
||||
selectedJitterBuffer, err := jitterBufferDuration(*jitterBuffer)
|
||||
if err != nil {
|
||||
handle_raw_error(err)
|
||||
}
|
||||
|
||||
// Set up logging
|
||||
var level barnlog.Level
|
||||
@@ -199,6 +204,7 @@ func main() {
|
||||
}
|
||||
b.Config.Buffers = *buffers
|
||||
b.Config.AudioInterval = selectedAudioInterval
|
||||
b.Config.IncomingAudioBuffer = selectedJitterBuffer
|
||||
b.Config.DisableUDP = *tcpOnly
|
||||
|
||||
b.Hotkeys = b.UserConfig.GetHotkeys()
|
||||
@@ -257,6 +263,18 @@ func audioIntervalDuration(milliseconds int) (time.Duration, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// jitterBufferDuration converts the requested incoming playout delay to a
|
||||
// supported duration. Zero starts playback without an initial safety buffer.
|
||||
func jitterBufferDuration(milliseconds int) (time.Duration, error) {
|
||||
interval := time.Duration(milliseconds) * time.Millisecond
|
||||
switch interval {
|
||||
case 0, 20 * time.Millisecond, 40 * time.Millisecond, 60 * time.Millisecond:
|
||||
return interval, nil
|
||||
default:
|
||||
return 0, fmt.Errorf("jitter buffer must be 0, 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