Use unbounded buffer for track actions.

Without that, we might deadlock if the reader is blocked in read.
This commit is contained in:
Juliusz Chroboczek
2021-07-16 02:57:48 +02:00
parent 0d2ca28ae1
commit 6ae79f21d6
3 changed files with 27 additions and 18 deletions
+6 -6
View File
@@ -29,10 +29,12 @@ func readLoop(track *rtpUpTrack) {
var packet rtp.Packet
for {
inner:
for {
select {
case action := <-track.localCh:
select {
case <-track.actionCh:
track.mu.Lock()
actions := track.actions
track.mu.Unlock()
for _, action := range actions {
switch action.action {
case trackActionAdd, trackActionDel:
err := writers.add(
@@ -50,8 +52,6 @@ func readLoop(track *rtpUpTrack) {
default:
log.Printf("Unknown action")
}
default:
break inner
}
}