summaryrefslogtreecommitdiff
path: root/indra/llwebrtc
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2026-09-22 14:47:19 +0800
committerErik Kundiman <erik@megapahit.org>2026-09-22 14:47:19 +0800
commit8557e9659ca5b71aabcbb21758be03a959c2098d (patch)
treee9c2cb659b646169e8d0c502b0ff873fec05ac02 /indra/llwebrtc
parent235a9d87ecf0447bd4aca3287548c715f1ada2ad (diff)
parentf767219366b8dbaeea95a22bd9953a587f473298 (diff)
Merge tag 'Second_Life_Release#f7672193-26.4' into 26.4
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r--indra/llwebrtc/llwebrtc.cpp38
-rw-r--r--indra/llwebrtc/llwebrtc_impl.h5
2 files changed, 29 insertions, 14 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp
index 4b98944d10..15eee9b39c 100644
--- a/indra/llwebrtc/llwebrtc.cpp
+++ b/indra/llwebrtc/llwebrtc.cpp
@@ -496,7 +496,7 @@ bool LLWebRTCImpl::terminate()
{
for (auto& connection : connections)
{
- connection->closeOnSignalingThread();
+ connection->closeOnSignalingThread(true);
}
// Destroy the connections here, on the signaling thread, while
// it's still running.
@@ -792,8 +792,14 @@ void LLWebRTCImpl::workerDeployDevices()
// Stop first so the start helpers (which no-op when already running) will
// re-select the now-current device.
- mDeviceModule->StopPlayout();
- mDeviceModule->ForceStopRecording();
+ if (mDeviceModule->Playing())
+ {
+ mDeviceModule->StopPlayout();
+ }
+ if (mDeviceModule->Recording())
+ {
+ mDeviceModule->ForceStopRecording();
+ }
workerStartRecording();
workerStartPlayout();
@@ -1085,7 +1091,10 @@ void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_conn
{
if (mDeviceModule)
{
- mDeviceModule->StopPlayout();
+ if (mDeviceModule->Playing())
+ {
+ mDeviceModule->StopPlayout();
+ }
if (!mVoiceEnabled)
{
mDeviceModule->ForceStopRecording();
@@ -1161,13 +1170,13 @@ void LLWebRTCPeerConnectionImpl::terminate()
mWebRTCImpl->PostSignalingTask(
[self]()
{
- self->closeOnSignalingThread();
+ self->closeOnSignalingThread(false);
self->mPendingJobs--;
});
}
// Signaling thread only.
-void LLWebRTCPeerConnectionImpl::closeOnSignalingThread()
+void LLWebRTCPeerConnectionImpl::closeOnSignalingThread(bool webrtc_terminate)
{
// Stop issuing stats requests; one may already be in flight, and
// Close() below will flush it.
@@ -1218,13 +1227,16 @@ void LLWebRTCPeerConnectionImpl::closeOnSignalingThread()
observer->OnPeerConnectionClosed();
}
- // Nothing may call back into the viewer past this point. Connections
- // closed while the viewer is still running unset themselves as observers
- // when they're destroyed, but any that are left for llwebrtc::terminate()
- // to close deliberately don't -- they're torn down as soon as it returns,
- // so a late callback would be reaching into freed memory.
- mSignalingObserverList.clear();
- mDataObserverList.clear();
+ if (webrtc_terminate)
+ {
+ // Nothing may call back into the viewer past this point. Connections
+ // closed while the viewer is still running unset themselves as observers
+ // when they're destroyed, but any that are left for llwebrtc::terminate()
+ // to close deliberately don't -- they're torn down as soon as it returns,
+ // so a late callback would be reaching into freed memory.
+ mSignalingObserverList.clear();
+ mDataObserverList.clear();
+ }
}
void LLWebRTCPeerConnectionImpl::setSignalingObserver(LLWebRTCSignalingObserver *observer) { mSignalingObserverList.emplace_back(observer); }
diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h
index f78b129da5..8bf72890cf 100644
--- a/indra/llwebrtc/llwebrtc_impl.h
+++ b/indra/llwebrtc/llwebrtc_impl.h
@@ -610,10 +610,13 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnectionInterface,
void init(LLWebRTCImpl * webrtc_impl);
// Posts closeOnSignalingThread() and returns immediately.
void terminate();
+
// The actual close. Signaling thread only. Callable directly (via a
// BlockingCall) when the caller needs the connection to be fully closed
// before it continues -- see LLWebRTCImpl::terminate().
- void closeOnSignalingThread();
+ // webrtc_terminate indicates we're shutting down the webrtc library,
+ // if not, we'll be reusing the peer connection for a reconnection
+ void closeOnSignalingThread(bool webrtc_terminate);
virtual void AddRef() const override = 0;
virtual webrtc::RefCountReleaseStatus Release() const override = 0;