Additional case of subscribing to a closed track (#1465)

When the publisher stops publishing, the individual receivers would close
attached DownTracks first before notifying MediaTrackReceiver callbacks.

This means #1454 does not fix the issue entirely since there is still a window
when we can subscribe to a closing track.
This commit is contained in:
David Zhao
2023-02-23 17:07:16 -08:00
committed by GitHub
parent 3ac2a35c23
commit 34fcf9e496
5 changed files with 31 additions and 1 deletions
+4
View File
@@ -88,6 +88,10 @@ func (r *RedPrimaryReceiver) DeleteDownTrack(subscriberID livekit.ParticipantID)
r.downTrackSpreader.Free(subscriberID)
}
func (r *RedPrimaryReceiver) IsClosed() bool {
return r.closed.Load()
}
func (r *RedPrimaryReceiver) CanClose() bool {
return r.closed.Load() || r.downTrackSpreader.DownTrackCount() == 0
}