1
0
mirror of https://github.com/stryan/mumble-discord-bridge.git synced 2024-11-23 05:45:41 -05:00

check if fromDiscordMap channel is full

This commit is contained in:
Tyler Stiene 2020-12-31 22:11:08 -05:00
parent d9d30929ff
commit f8518176d5

View File

@ -153,10 +153,22 @@ 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")
}
select {
case fromDiscordMap[p.SSRC].pcm <- p.PCM[480:960]:
default:
log.Println("fromDiscordMap buffer full. Dropping packet")
}
discordMutex.Unlock() discordMutex.Unlock()
} }
} }