From d420e28024ad527390b43aa7f64e029083e11989 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 8 Jul 2017 11:09:04 -0400 Subject: [PATCH 1/5] voice.go: remove runtime.LockOSThread call from opusSender (#404) runtime.LockOSThread does not do anything for performance and is instead intended for interfacing with libraries that use thread local data structures. Closes #402 --- voice.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/voice.go b/voice.go index 8b566f4..da7b8c9 100644 --- a/voice.go +++ b/voice.go @@ -15,7 +15,6 @@ import ( "fmt" "log" "net" - "runtime" "strings" "sync" "time" @@ -659,8 +658,6 @@ func (v *VoiceConnection) opusSender(udpConn *net.UDPConn, close <-chan struct{} return } - runtime.LockOSThread() - // VoiceConnection is now ready to receive audio packets // TODO: this needs reviewed as I think there must be a better way. v.Lock() From 3f2c1311d592986bc1b49c35f6c07a28fc286e49 Mon Sep 17 00:00:00 2001 From: Jonas is my name Date: Mon, 14 Aug 2017 04:52:05 +0200 Subject: [PATCH 2/5] Export State.OnInterface (#417) --- event.go | 2 +- state.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/event.go b/event.go index 1524f32..3a03f46 100644 --- a/event.go +++ b/event.go @@ -224,7 +224,7 @@ func (s *Session) onInterface(i interface{}) { case *VoiceStateUpdate: go s.onVoiceStateUpdate(t) } - err := s.State.onInterface(s, i) + err := s.State.OnInterface(s, i) if err != nil { s.log(LogDebug, "error dispatching internal event, %s", err) } diff --git a/state.go b/state.go index b545c53..7627796 100644 --- a/state.go +++ b/state.go @@ -783,7 +783,7 @@ func (s *State) onReady(se *Session, r *Ready) (err error) { } // onInterface handles all events related to states. -func (s *State) onInterface(se *Session, i interface{}) (err error) { +func (s *State) OnInterface(se *Session, i interface{}) (err error) { if s == nil { return ErrNilState } From 308d058bf1db248cd559bf062ae2de3f23db23f5 Mon Sep 17 00:00:00 2001 From: Jonas is my name Date: Thu, 17 Aug 2017 15:55:02 +0200 Subject: [PATCH 3/5] Fix presence update after breaking API change (#427) --- structs.go | 2 +- wsapi.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/structs.go b/structs.go index e811e9e..5dde7aa 100644 --- a/structs.go +++ b/structs.go @@ -316,7 +316,7 @@ type Presence struct { type Game struct { Name string `json:"name"` Type int `json:"type"` - URL string `json:"url"` + URL string `json:"url,omitempty"` } // UnmarshalJSON unmarshals json to Game struct diff --git a/wsapi.go b/wsapi.go index baec234..ab37b5a 100644 --- a/wsapi.go +++ b/wsapi.go @@ -250,8 +250,10 @@ func (s *Session) heartbeat(wsConn *websocket.Conn, listening <-chan interface{} } type updateStatusData struct { - IdleSince *int `json:"idle_since"` - Game *Game `json:"game"` + IdleSince *int `json:"since"` + Game *Game `json:"game"` + AFK bool `json:"afk"` + Status string `json:"status"` } type updateStatusOp struct { @@ -274,7 +276,10 @@ func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err return ErrWSNotFound } - var usd updateStatusData + usd := updateStatusData{ + Status: "online", + } + if idle > 0 { usd.IdleSince = &idle } 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 4/5] 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: From d6b616c58fb2716439422750ac56655b529cefc9 Mon Sep 17 00:00:00 2001 From: robbix1206 Date: Sat, 19 Aug 2017 19:36:29 +0200 Subject: [PATCH 5/5] #429-Fix (#432) --- restapi.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/restapi.go b/restapi.go index 68e6afd..836e4a4 100644 --- a/restapi.go +++ b/restapi.go @@ -1863,14 +1863,9 @@ func (s *Session) WebhookEditWithToken(webhookID, token, name, avatar string) (s // WebhookDelete deletes a webhook for a given ID // webhookID: The ID of a webhook. -func (s *Session) WebhookDelete(webhookID string) (st *Webhook, err error) { +func (s *Session) WebhookDelete(webhookID string) (err error) { - body, err := s.RequestWithBucketID("DELETE", EndpointWebhook(webhookID), nil, EndpointWebhooks) - if err != nil { - return - } - - err = unmarshal(body, &st) + _, err = s.RequestWithBucketID("DELETE", EndpointWebhook(webhookID), nil, EndpointWebhooks) return }