move close downtrack to goroutine (#810)

This commit is contained in:
cnderrauber
2022-07-05 17:26:47 +08:00
committed by GitHub
parent 937882c364
commit 4242205ede
+4 -4
View File
@@ -717,10 +717,6 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea
} }
p.lock.Unlock() p.lock.Unlock()
for _, dt := range downTracksToClose {
dt.Close()
}
p.updateState(livekit.ParticipantInfo_DISCONNECTED) p.updateState(livekit.ParticipantInfo_DISCONNECTED)
// ensure this is synchronized // ensure this is synchronized
@@ -735,6 +731,10 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea
// Close peer connections without blocking participant close. If peer connections are gathering candidates // Close peer connections without blocking participant close. If peer connections are gathering candidates
// Close will block. // Close will block.
go func() { go func() {
for _, dt := range downTracksToClose {
dt.Close()
}
p.publisher.Close() p.publisher.Close()
p.subscriber.Close() p.subscriber.Close()
}() }()