mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-20 16:54:25 +00:00
Fix high CPU due to nonstop loop (#191)
This commit is contained in:
parent
d84503fa75
commit
bf5b622b1a
1 changed files with 14 additions and 13 deletions
|
|
@ -198,21 +198,22 @@ func (w *WebRTC) StartClient(isMobile bool, iceCB OnIceCallback) (string, error)
|
|||
})
|
||||
|
||||
w.connection.OnTrack(func(remoteTrack *webrtc.Track, receiver *webrtc.RTPReceiver) {
|
||||
rtpBuf := make([]byte, 1400)
|
||||
//NOTE: High CPU due to constantly for loop. Turn it off first, Fix it later.
|
||||
//rtpBuf := make([]byte, 1400)
|
||||
|
||||
log.Println("Received Voice from Client")
|
||||
for {
|
||||
if w.RoomID == "" {
|
||||
// skip sending voice when game is not running
|
||||
continue
|
||||
}
|
||||
//log.Println("Received Voice from Client")
|
||||
//for {
|
||||
//if w.RoomID == "" {
|
||||
//// skip sending voice when game is not running
|
||||
//continue
|
||||
//}
|
||||
|
||||
i, err := remoteTrack.Read(rtpBuf)
|
||||
// TODO: can receive track but the voice doesn't work
|
||||
if err == nil {
|
||||
w.VoiceInChannel <- rtpBuf[:i]
|
||||
}
|
||||
}
|
||||
//i, err := remoteTrack.Read(rtpBuf)
|
||||
//// TODO: can receive track but the voice doesn't work
|
||||
//if err == nil {
|
||||
//w.VoiceInChannel <- rtpBuf[:i]
|
||||
//}
|
||||
//}
|
||||
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue