Skip to content

Commit

Permalink
Merge pull request #5 from Stieneee/issue-4
Browse files Browse the repository at this point in the history
  • Loading branch information
Stieneee authored Jan 5, 2021
2 parents d9d3092 + 7947e93 commit 43cc6ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 16 additions & 2 deletions discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,24 @@ func discordReceivePCM(v *discordgo.VoiceConnection, die chan bool) {
OnError("Error decoding opus data", err)
continue
}
if len(p.PCM) != 960 {
log.Println("Opus size error")
continue
}

discordMutex.Lock()
fromDiscordMap[p.SSRC].pcm <- p.PCM[0:480]
fromDiscordMap[p.SSRC].pcm <- p.PCM[480:960]
select {
case fromDiscordMap[p.SSRC].pcm <- p.PCM[0:480]:
default:
log.Println("fromDiscordMap buffer full. Dropping packet")
discordMutex.Unlock()
continue
}
select {
case fromDiscordMap[p.SSRC].pcm <- p.PCM[480:960]:
default:
log.Println("fromDiscordMap buffer full. Dropping packet")
}
discordMutex.Unlock()
}
}
Expand Down
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/signal"
"strconv"
"syscall"
"time"

"github.com/bwmarrin/discordgo"
Expand Down Expand Up @@ -88,6 +89,12 @@ func main() {
log.Fatalln("missing discord cid")
}

// Attempt to set the nice value of the process
err := syscall.Setpriority(syscall.PRIO_PROCESS, os.Getpid(), -5)
if err != nil {
log.Println("Unable to set priority. ", err)
}

// DISCORD Setup

discord, err := discordgo.New("Bot " + *discordToken)
Expand Down Expand Up @@ -131,7 +138,7 @@ func main() {
tlsConfig.InsecureSkipVerify = true
}

mumble, err := gumble.DialWithDialer(new(net.Dialer),*mumbleAddr+":"+strconv.Itoa(*mumblePort),config, &tlsConfig)
mumble, err := gumble.DialWithDialer(new(net.Dialer), *mumbleAddr+":"+strconv.Itoa(*mumblePort), config, &tlsConfig)

if err != nil {
log.Println(err)
Expand Down

0 comments on commit 43cc6ad

Please sign in to comment.