Record dynacast requirement of a subscriber synchronously. (#834)
With rapid changes to subscription settings, use of a goroutine could end up processing dynacast needs for that subscriber in a different order. So, record the susbcription needs of a subscriber in the callback and process the data in a go routine.
This commit is contained in:
@@ -301,7 +301,7 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, wr *
|
||||
})
|
||||
|
||||
downTrack.OnMaxLayerChanged(func(dt *sfu.DownTrack, layer int32) {
|
||||
go t.notifySubscriberMaxQuality(subscriberID, dt.Codec(), utils.QualityForSpatialLayer(layer))
|
||||
t.notifySubscriberMaxQuality(subscriberID, dt.Codec(), utils.QualityForSpatialLayer(layer))
|
||||
})
|
||||
|
||||
downTrack.OnRttUpdate(func(_ *sfu.DownTrack, rtt uint32) {
|
||||
@@ -517,7 +517,7 @@ func (t *MediaTrackSubscriptions) notifySubscriberMaxQuality(subscriberID liveki
|
||||
}
|
||||
t.maxQualityLock.Unlock()
|
||||
|
||||
t.UpdateQualityChange(false)
|
||||
go t.UpdateQualityChange(false)
|
||||
}
|
||||
|
||||
func (t *MediaTrackSubscriptions) NotifySubscriberNodeMaxQuality(nodeID livekit.NodeID, qualities []types.SubscribedCodecQuality) {
|
||||
@@ -563,7 +563,7 @@ func (t *MediaTrackSubscriptions) NotifySubscriberNodeMaxQuality(nodeID livekit.
|
||||
}
|
||||
t.maxQualityLock.Unlock()
|
||||
|
||||
t.UpdateQualityChange(false)
|
||||
go t.UpdateQualityChange(false)
|
||||
}
|
||||
|
||||
func (t *MediaTrackSubscriptions) UpdateQualityChange(force bool) {
|
||||
|
||||
Reference in New Issue
Block a user