diff options
author | Roxie Linden <roxie@lindenlab.com> | 2023-12-04 14:22:40 -0800 |
---|---|---|
committer | Roxie Linden <roxie@lindenlab.com> | 2024-02-08 18:34:01 -0800 |
commit | e92e4d762ec5b2c122f17edb1a18b21ef6166e8b (patch) | |
tree | b5b6c918865415c0d0729c9af9a304e201a87d2d | |
parent | b10731f6f9f357907b7ba53d7531cfa3552c46cf (diff) |
Mute using enable.
Muting using the device module microphone mute was muting other
applications, speakers, and so on. Instead, we mute by enabling/disabling
the input and output streams.
-rw-r--r-- | indra/llwebrtc/llwebrtc.cpp | 34 | ||||
-rw-r--r-- | indra/newview/llvoicewebrtc.cpp | 16 | ||||
-rw-r--r-- | indra/newview/llvoicewebrtc.h | 1 |
3 files changed, 18 insertions, 33 deletions
diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index 2bcbb135c0..9fd8fd8ee6 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -287,16 +287,11 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id) break; } } - mTuningDeviceModule->SetSpeakerMute(true); bool was_tuning_playing = mTuningDeviceModule->Playing(); if (was_tuning_playing) { mTuningDeviceModule->StopPlayout(); } - if (mPeerDeviceModule) - { - mPeerDeviceModule->SetSpeakerMute(true); - } mTuningDeviceModule->SetPlayoutDevice(tuningPlayoutDevice); mTuningDeviceModule->InitSpeaker(); @@ -326,10 +321,8 @@ void LLWebRTCImpl::setRenderDevice(const std::string &id) mPeerDeviceModule->InitSpeaker(); mPeerDeviceModule->InitPlayout(); mPeerDeviceModule->StartPlayout(); - mPeerDeviceModule->SetSpeakerMute(false); } - mTuningDeviceModule->SetSpeakerMute(false); }); } @@ -369,29 +362,25 @@ void LLWebRTCImpl::setTuningMode(bool enable) { mTuningDeviceModule->StartRecording(); - mTuningDeviceModule->SetMicrophoneMute(false); - - - mTuningDeviceModule->SetSpeakerMute(false); if (mPeerDeviceModule) { mPeerDeviceModule->StopRecording(); - mPeerDeviceModule->SetSpeakerMute(true); } } else { + mTuningDeviceModule->StartRecording(); if (mPeerDeviceModule) { mPeerDeviceModule->StartRecording(); - mPeerDeviceModule->SetSpeakerMute(false); } } }); for (auto& connection : mPeerConnections) { - connection->enableTracks(enable ? false : !mMute); + connection->enableSenderTracks(enable ? false : !mMute); + connection->enableReceiverTracks(!enable); } } @@ -409,7 +398,7 @@ LLWebRTCPeerConnection * LLWebRTCImpl::newPeerConnection() peerConnection->init(this); mPeerConnections.emplace_back(peerConnection); - peerConnection->enableTracks(!mMute); + peerConnection->enableSenderTracks(!mMute); return peerConnection.get(); } @@ -570,7 +559,7 @@ void LLWebRTCPeerConnectionImpl::shutdownConnection() }); } -void LLWebRTCPeerConnectionImpl::enableTracks(bool enable) +void LLWebRTCPeerConnectionImpl::enableSenderTracks(bool enable) { // set_enabled shouldn't be done on the worker thread if (mPeerConnection) @@ -583,6 +572,19 @@ void LLWebRTCPeerConnectionImpl::enableTracks(bool enable) } } +void LLWebRTCPeerConnectionImpl::enableReceiverTracks(bool enable) +{ + // set_enabled shouldn't be done on the worker thread + if (mPeerConnection) + { + auto receivers = mPeerConnection->GetReceivers(); + for (auto &receiver : receivers) + { + receiver->track()->set_enabled(enable); + } + } +} + void LLWebRTCPeerConnectionImpl::AnswerAvailable(const std::string &sdp) { RTC_LOG(LS_INFO) << __FUNCTION__ << " Remote SDP: " << sdp; diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 435e2e1245..ddd757c39f 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -261,7 +261,6 @@ LLWebRTCVoiceClient::LLWebRTCVoiceClient() : mEarLocation(0), mSpeakerVolumeDirty(true), - mSpeakerMuteDirty(true), mMicVolume(0), mMicVolumeDirty(true), @@ -583,16 +582,7 @@ LLVoiceDeviceList& LLWebRTCVoiceClient::getCaptureDevices() void LLWebRTCVoiceClient::setCaptureDevice(const std::string& name) { - bool inTuningMode = mIsInTuningMode; - if (inTuningMode) - { - tuningStop(); - } mWebRTCDeviceInterface->setCaptureDevice(name); - if (inTuningMode) - { - tuningStart(); - } } void LLWebRTCVoiceClient::setDevicesListUpdated(bool state) { @@ -1863,12 +1853,6 @@ void LLWebRTCVoiceClient::setVoiceVolume(F32 volume) if (volume != mSpeakerVolume) { { - int min_volume = 0.0; - if ((volume == min_volume) || (mSpeakerVolume == min_volume)) - { - mSpeakerMuteDirty = true; - } - mSpeakerVolume = volume; mSpeakerVolumeDirty = true; } diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h index f0549495e1..2eb74ed2cb 100644 --- a/indra/newview/llvoicewebrtc.h +++ b/indra/newview/llvoicewebrtc.h @@ -645,7 +645,6 @@ private: S32 mEarLocation; bool mSpeakerVolumeDirty; - bool mSpeakerMuteDirty; float mSpeakerVolume; int mMicVolume; |