From 4242205ede6b270ac3e71f8211f2089daf066e0b Mon Sep 17 00:00:00 2001 From: cnderrauber Date: Tue, 5 Jul 2022 17:26:47 +0800 Subject: [PATCH] move close downtrack to goroutine (#810) --- pkg/rtc/participant.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 3b3eeb66..68baad36 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -717,10 +717,6 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea } p.lock.Unlock() - for _, dt := range downTracksToClose { - dt.Close() - } - p.updateState(livekit.ParticipantInfo_DISCONNECTED) // 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 will block. go func() { + for _, dt := range downTracksToClose { + dt.Close() + } + p.publisher.Close() p.subscriber.Close() }()