From 3c8a0dd940b7ca98488d829131d9cf14cb838766 Mon Sep 17 00:00:00 2001 From: Jonas is my name Date: Fri, 18 Aug 2017 17:35:27 +0200 Subject: [PATCH] Fix receiving voice after client sets extended header bit (#428) --- voice.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/voice.go b/voice.go index 5bbd0ad..0dc81ff 100644 --- a/voice.go +++ b/voice.go @@ -799,7 +799,7 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct } // For now, skip anything except audio. - if rlen < 12 || recvbuf[0] != 0x80 { + if rlen < 12 || (recvbuf[0] != 0x80 && recvbuf[0] != 0x90) { continue } @@ -813,6 +813,11 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct copy(nonce[:], recvbuf[0:12]) p.Opus, _ = secretbox.Open(nil, recvbuf[12:rlen], &nonce, &v.op4.SecretKey) + if len(p.Opus) > 8 && recvbuf[0] == 0x90 { + // Extension bit is set, first 8 bytes is the extended header + p.Opus = p.Opus[8:] + } + if c != nil { select { case c <- &p: