Skip to content

Commit

Permalink
remove goroutine on tracklist
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohan Totting committed Jul 16, 2024
1 parent 6eb44a4 commit b9e50be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ func NewClient(s *SFU, id string, name string, peerConnectionConfig webrtc.Confi
defer cancel()
<-ctx.Done()
client.stats.removeReceiverStats(remoteTrack.ID() + remoteTrack.RID())
client.tracks.remove([]string{remoteTrack.ID()})
}()

if err := client.tracks.Add(track); err != nil {
Expand Down Expand Up @@ -539,6 +540,8 @@ func NewClient(s *SFU, id string, name string, peerConnectionConfig webrtc.Confi
if simulcastTrack.remoteTrackLow != nil {
client.stats.removeReceiverStats(simulcastTrack.remoteTrackLow.track.ID() + simulcastTrack.remoteTrackLow.track.RID())
}

client.tracks.remove([]string{remoteTrack.ID()})
}()

} else if simulcast, ok = track.(*SimulcastTrack); ok {
Expand Down Expand Up @@ -1005,6 +1008,7 @@ func (c *Client) setClientTrack(t ITrack) iClientTrack {
defer func() {
c.muTracks.Lock()
delete(c.clientTracks, outputTrack.ID())
c.publishedTracks.remove([]string{outputTrack.ID()})
c.muTracks.Unlock()

c.renegotiate()
Expand Down
7 changes: 0 additions & 7 deletions track.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,13 +897,6 @@ func (t *trackList) Add(track ITrack) error {

t.tracks[id] = track

go func() {
ctx, cancel := context.WithCancel(track.Context())
defer cancel()
<-ctx.Done()
t.remove([]string{id})
}()

return nil
}

Expand Down

0 comments on commit b9e50be

Please sign in to comment.