From a0baf124b1b6ea7d5694899094d36652d80eb840 Mon Sep 17 00:00:00 2001 From: prlanzarin <4529051+prlanzarin@users.noreply.github.com> Date: Thu, 11 May 2023 13:27:25 -0300 Subject: [PATCH 1/2] fix: CPU lock when reading packets from JB Move JB packet reading out of the for-select goroutine so it doesnt run non-stop and CPU-locks a core Moved it alongside RTP packet reading - maybe not ideal, but good enough for now --- internal/webrtc/webrtc.go | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/internal/webrtc/webrtc.go b/internal/webrtc/webrtc.go index d63880a..6eca42f 100644 --- a/internal/webrtc/webrtc.go +++ b/internal/webrtc/webrtc.go @@ -176,6 +176,7 @@ func (w WebRTC) Init( } jb := utils.NewJitterBuffer(w.cfg.JitterBuffer) + var s1, s2 uint16 if true { done := make(chan bool) @@ -185,7 +186,6 @@ func (w WebRTC) Init( go func() { ticker := time.NewTicker(time.Millisecond * 100) var wasFlowing, isFlowing bool - var s1, s2 uint16 for { select { case <-done: @@ -212,20 +212,6 @@ func (w WebRTC) Init( } } wasFlowing = isFlowing - default: - packets := jb.NextPackets() - if packets == nil { - continue - } - for _, p := range packets { - s2 = p.SequenceNumber - switch { - case isAudio: - r.PushAudio(p) - case isVideo: - r.PushVideo(p) - } - } } } }() @@ -249,6 +235,21 @@ func (w WebRTC) Init( seq = su.Unwrap(uint64(rtp.SequenceNumber)) jb.Add(seq, rtp) rl.Add(rtp.SequenceNumber) + packets := jb.NextPackets() + + if packets == nil { + continue + } + + for _, p := range packets { + s2 = p.SequenceNumber + switch { + case isAudio: + r.PushAudio(p) + case isVideo: + r.PushVideo(p) + } + } } }) From 2d93ad61b14e0f893ec70ee5431675ba7d03c384 Mon Sep 17 00:00:00 2001 From: prlanzarin <4529051+prlanzarin@users.noreply.github.com> Date: Thu, 11 May 2023 13:28:08 -0300 Subject: [PATCH 2/2] build: bump VERSION@0.3 1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2aef3b2..cc15c62 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2 1 \ No newline at end of file +0.3 1