diff options
author | Roxie Linden <roxie@lindenlab.com> | 2024-02-03 18:53:04 -0800 |
---|---|---|
committer | Roxie Linden <roxie@lindenlab.com> | 2024-02-08 18:35:55 -0800 |
commit | 8ab0bb9a41850bd03a9cdc1624a822d8eb24f712 (patch) | |
tree | c8c826c980b9bef7dbbc87592cca0614c1a7a95e /indra/llwebrtc | |
parent | 56fdc19e9521bca1387acbe8ac92eabad17d2d31 (diff) |
fix locking race condition
Diffstat (limited to 'indra/llwebrtc')
-rw-r--r-- | indra/llwebrtc/llwebrtc.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index fca490e8c2..900698aa56 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -673,20 +673,24 @@ void LLWebRTCPeerConnectionImpl::AnswerAvailable(const std::string &sdp) void LLWebRTCPeerConnectionImpl::setMute(bool mute) { mMute = mute; - if (mPeerConnection) - { - auto senders = mPeerConnection->GetSenders(); - - RTC_LOG(LS_INFO) << __FUNCTION__ << (mute ? "disabling" : "enabling") << " streams count " << senders.size(); - for (auto &sender : senders) + mWebRTCImpl->PostSignalingTask( + [this]() + { + if (mPeerConnection) { - auto track = sender->track(); - if(track) + auto senders = mPeerConnection->GetSenders(); + + RTC_LOG(LS_INFO) << __FUNCTION__ << (mMute ? "disabling" : "enabling") << " streams count " << senders.size(); + for (auto &sender : senders) { - track->set_enabled(!mMute); + auto track = sender->track(); + if (track) + { + track->set_enabled(!mMute); + } } } - } + }); } void LLWebRTCPeerConnectionImpl::resetMute() @@ -719,13 +723,17 @@ void LLWebRTCPeerConnectionImpl::setReceiveVolume(float volume) void LLWebRTCPeerConnectionImpl::setSendVolume(float volume) { - if (mLocalStream) - { - for (auto &track : mLocalStream->GetAudioTracks()) + mWebRTCImpl->PostSignalingTask( + [this, volume]() { - track->GetSource()->SetVolume(volume); - } - } + if (mLocalStream) + { + for (auto &track : mLocalStream->GetAudioTracks()) + { + track->GetSource()->SetVolume(volume); + } + } + }); } // |