diff --git a/gumble/gumble/client.go b/gumble/gumble/client.go index fe8291a..4ef3f5c 100644 --- a/gumble/gumble/client.go +++ b/gumble/gumble/client.go @@ -387,6 +387,14 @@ func (c *Client) WriteAudio(format, target byte, sequence int64, final bool, dat return c.Conn.WriteAudio(format, target, sequence, final, data, X, Y, Z) } +// UDPActive reports whether an authenticated UDP packet has confirmed the +// return path and outgoing audio may use native UDP. +func (c *Client) UDPActive() bool { + c.udpMu.RLock() + defer c.udpMu.RUnlock() + return c.udpActive +} + // DisableStereoEncoder switches back to mono encoding for voice and // resets the stereo encoder so stale state does not bleed into the // next file playback. diff --git a/gumble/gumble/integration_audio_test.go b/gumble/gumble/integration_audio_test.go index 89da4a9..e578e2a 100644 --- a/gumble/gumble/integration_audio_test.go +++ b/gumble/gumble/integration_audio_test.go @@ -35,7 +35,7 @@ func TestLocalMumbleAudioRoundTrip(t *testing.T) { c := gumble.NewConfig() c.Address = "localhost:64738" c.Username = name - c.DisableUDP = true + c.DisableUDP = false return c } tlsConfig := &tls.Config{InsecureSkipVerify: true} @@ -56,7 +56,10 @@ func TestLocalMumbleAudioRoundTrip(t *testing.T) { if sender.AudioEncoder == nil { t.Fatal("no negotiated audio encoder") } - time.Sleep(500 * time.Millisecond) + time.Sleep(1500 * time.Millisecond) + if !sender.UDPActive() || !receiver.UDPActive() { + t.Fatalf("native UDP did not become active: sender=%v receiver=%v", sender.UDPActive(), receiver.UDPActive()) + } frame := make([]int16, sendConfig.AudioFrameSize()) for i := 0; i < 8; i++ { for sample := range frame {