Merge pull request #340 from jonas747/fix-receive-racey-packet

Fix race-y packet in opusReceiver
This commit is contained in:
Bruce 2017-03-16 08:01:40 -05:00 committed by GitHub
commit 197f24b96a

View file

@ -769,7 +769,6 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct
return return
} }
p := Packet{}
recvbuf := make([]byte, 1024) recvbuf := make([]byte, 1024)
var nonce [24]byte var nonce [24]byte
@ -805,6 +804,7 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct
} }
// build a audio packet struct // build a audio packet struct
p := Packet{}
p.Type = recvbuf[0:2] p.Type = recvbuf[0:2]
p.Sequence = binary.BigEndian.Uint16(recvbuf[2:4]) p.Sequence = binary.BigEndian.Uint16(recvbuf[2:4])
p.Timestamp = binary.BigEndian.Uint32(recvbuf[4:8]) p.Timestamp = binary.BigEndian.Uint32(recvbuf[4:8])