Prevent subscribing to track that's closing (#1454)
Due to the order of events in MediaTrackReceiver and friends, SubscribedTrack will be closed before the track is removed from RoomTrackManager. Because of this, when a track is unpublished, it's possible to be subscribed to the track as it's closing. By introducing a closing state, we'd prevent accidental subscription to closing tracks.
This commit is contained in:
@@ -82,7 +82,15 @@ func (r *RoomTrackManager) GetTrackInfo(trackID livekit.TrackID) *TrackInfo {
|
||||
r.lock.RLock()
|
||||
defer r.lock.RUnlock()
|
||||
|
||||
return r.tracks[trackID]
|
||||
info := r.tracks[trackID]
|
||||
if info == nil {
|
||||
return nil
|
||||
}
|
||||
// when track is about to close, do not resolve
|
||||
if info.Track != nil && !info.Track.IsOpen() {
|
||||
return nil
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func (r *RoomTrackManager) NotifyTrackChanged(trackID livekit.TrackID) {
|
||||
|
||||
Reference in New Issue
Block a user