From 2b275d43fb70f396bba4249c34442e7d70a76e19 Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Fri, 17 May 2024 13:27:45 -0700 Subject: Clean up some shutdown code. --- indra/llwebrtc/llwebrtc.cpp | 35 ++++++++++++++++++++++------------- indra/llwebrtc/llwebrtc_impl.h | 2 -- 2 files changed, 22 insertions(+), 15 deletions(-) (limited to 'indra/llwebrtc') diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index 5c71831c65..c72841e9e5 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -627,7 +627,6 @@ void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_conn std::find(mPeerConnections.begin(), mPeerConnections.end(), peer_connection); if (it != mPeerConnections.end()) { - (*it)->terminate(); mPeerConnections.erase(it); } if (mPeerConnections.empty()) @@ -645,7 +644,6 @@ void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_conn LLWebRTCPeerConnectionImpl::LLWebRTCPeerConnectionImpl() : mWebRTCImpl(nullptr), - mClosing(false), mPeerConnection(nullptr), mMute(false), mAnswerReceived(false) @@ -673,20 +671,32 @@ void LLWebRTCPeerConnectionImpl::terminate() mWebRTCImpl->PostSignalingTask( [=]() { - if (mDataChannel) - { - mDataChannel->UnregisterObserver(); - mDataChannel->Close(); - mDataChannel = nullptr; - } if (mPeerConnection) { + if (mDataChannel) + { + { + mDataChannel->Close(); + mDataChannel = nullptr; + } + } + mPeerConnection->Close(); + if (mLocalStream) + { + auto tracks = mLocalStream->GetAudioTracks(); + for (auto& track : tracks) + { + mLocalStream->RemoveTrack(track); + } + mLocalStream = nullptr; + } mPeerConnection = nullptr; - } - for (auto &observer : mSignalingObserverList) - { - observer->OnPeerConnectionClosed(); + + for (auto &observer : mSignalingObserverList) + { + observer->OnPeerConnectionClosed(); + } } }); } @@ -810,7 +820,6 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection(const LLWebRTCPeerConnecti bool LLWebRTCPeerConnectionImpl::shutdownConnection() { - mClosing = true; terminate(); return true; } diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h index 984aaef734..448d36e3ea 100644 --- a/indra/llwebrtc/llwebrtc_impl.h +++ b/indra/llwebrtc/llwebrtc_impl.h @@ -355,8 +355,6 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnectionInterface, LLWebRTCImpl * mWebRTCImpl; - bool mClosing; - rtc::scoped_refptr mPeerConnectionFactory; bool mMute; -- cgit v1.2.3