Merge pull request #5 from Stieneee/issue-4
This commit is contained in:
commit
43cc6ad672
18
discord.go
18
discord.go
@ -153,10 +153,24 @@ func discordReceivePCM(v *discordgo.VoiceConnection, die chan bool) {
|
|||||||
OnError("Error decoding opus data", err)
|
OnError("Error decoding opus data", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if len(p.PCM) != 960 {
|
||||||
|
log.Println("Opus size error")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
discordMutex.Lock()
|
discordMutex.Lock()
|
||||||
fromDiscordMap[p.SSRC].pcm <- p.PCM[0:480]
|
select {
|
||||||
fromDiscordMap[p.SSRC].pcm <- p.PCM[480:960]
|
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()
|
discordMutex.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
main.go
7
main.go
@ -9,6 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
@ -88,6 +89,12 @@ func main() {
|
|||||||
log.Fatalln("missing discord cid")
|
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 Setup
|
||||||
|
|
||||||
discord, err := discordgo.New("Bot " + *discordToken)
|
discord, err := discordgo.New("Bot " + *discordToken)
|
||||||
|
Loading…
Reference in New Issue
Block a user