diff options
author | Roxie Linden <roxie@lindenlab.com> | 2024-06-24 14:42:30 -0700 |
---|---|---|
committer | Roxie Linden <roxie@lindenlab.com> | 2024-06-24 14:42:30 -0700 |
commit | 34a2fd525f5dde075bfc5615e6deb241ae61b94c (patch) | |
tree | 7696d3de36f30897bce1eb9ce6ae5e5bed95c76c /indra/newview | |
parent | d8fdf5acf8f87bdcef591b4870d229ec34642aec (diff) |
[WebRTC] control microphone gain via custom audio processor.
Previously, there were two places audio gain could be controlled:
- the device manager
- the audio track
The device manager audio gain control sets the system gain for all applications,
not just the webrtc application.
The audio track gain happens well after the audio processing where we want it to happen.
So, gain control was added to the existing custom audio processor, which previously only
handled calculating and retrieving the audio levels.
After these changes, the microphone gain slider does impact the audio volume heard by peers.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llvoicewebrtc.cpp | 31 | ||||
-rw-r--r-- | indra/newview/llvoicewebrtc.h | 5 |
2 files changed, 2 insertions, 34 deletions
diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index ddad470149..36e998af89 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -87,7 +87,7 @@ namespace { const F32 VOLUME_SCALE_WEBRTC = 0.01f; const F32 LEVEL_SCALE_WEBRTC = 0.008f; - const F32 SPEAKING_AUDIO_LEVEL = 0.35; + const F32 SPEAKING_AUDIO_LEVEL = 0.30; static const std::string REPORTED_VOICE_SERVER_TYPE = "Secondlife WebRTC Gateway"; @@ -1484,14 +1484,10 @@ void LLWebRTCVoiceClient::setMicGain(F32 gain) if (gain != mMicGain) { mMicGain = gain; - sessionState::for_each(boost::bind(predSetMicGain, _1, gain)); + mWebRTCDeviceInterface->setPeerConnectionGain(gain); } } -void LLWebRTCVoiceClient::predSetMicGain(const LLWebRTCVoiceClient::sessionStatePtr_t &session, F32 gain) -{ - session->setMicGain(gain); -} void LLWebRTCVoiceClient::setVoiceEnabled(bool enabled) { @@ -1690,7 +1686,6 @@ std::map<std::string, LLWebRTCVoiceClient::sessionState::ptr_t> LLWebRTCVoiceCli LLWebRTCVoiceClient::sessionState::sessionState() : mHangupOnLastLeave(false), mNotifyOnFirstJoin(false), - mMicGain(1.0), mMuted(false), mSpeakerVolume(1.0), mShuttingDown(false) @@ -1735,15 +1730,6 @@ void LLWebRTCVoiceClient::sessionState::setMuteMic(bool muted) } } -void LLWebRTCVoiceClient::sessionState::setMicGain(F32 gain) -{ - mMicGain = gain; - for (auto &connection : mWebRTCConnections) - { - connection->setMicGain(gain); - } -} - void LLWebRTCVoiceClient::sessionState::setSpeakerVolume(F32 volume) { mSpeakerVolume = volume; @@ -1848,7 +1834,6 @@ LLWebRTCVoiceClient::sessionStatePtr_t LLWebRTCVoiceClient::addSession(const std LL_DEBUGS("Voice") << "adding new session with channel: " << channel_id << LL_ENDL; session->setMuteMic(mMuteMic); - session->setMicGain(mMicGain); session->setSpeakerVolume(mSpeakerVolume); sessionState::addSession(channel_id, session); @@ -1974,7 +1959,6 @@ bool LLWebRTCVoiceClient::estateSessionState::processConnectionStates() connectionPtr_t connection(new LLVoiceWebRTCSpatialConnection(neighbor, INVALID_PARCEL_ID, mChannelID)); mWebRTCConnections.push_back(connection); - connection->setMicGain(mMicGain); connection->setMuteMic(mMuted); connection->setSpeakerVolume(mSpeakerVolume); } @@ -2104,7 +2088,6 @@ LLVoiceWebRTCConnection::LLVoiceWebRTCConnection(const LLUUID ®ionID, const s mShutDown(false), mIceCompleted(false), mSpeakerVolume(0.0), - mMicGain(0.0), mOutstandingRequests(0), mChannelID(channelID), mRegionID(regionID), @@ -2367,15 +2350,6 @@ void LLVoiceWebRTCConnection::setMuteMic(bool muted) } } -void LLVoiceWebRTCConnection::setMicGain(F32 gain) -{ - mMicGain = gain; - if (mWebRTCAudioInterface) - { - mWebRTCAudioInterface->setSendVolume(gain); - } -} - void LLVoiceWebRTCConnection::setSpeakerVolume(F32 volume) { mSpeakerVolume = volume; @@ -2683,7 +2657,6 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() // this connection. mWebRTCAudioInterface->setMute(mMuted); mWebRTCAudioInterface->setReceiveVolume(mSpeakerVolume); - mWebRTCAudioInterface->setSendVolume(mMicGain); LLWebRTCVoiceClient::getInstance()->OnConnectionEstablished(mChannelID, mRegionID); setVoiceConnectionState(VOICE_STATE_WAIT_FOR_DATA_CHANNEL); break; diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h index 60724a4a2a..7042bbae00 100644 --- a/indra/newview/llvoicewebrtc.h +++ b/indra/newview/llvoicewebrtc.h @@ -282,7 +282,6 @@ public: virtual void sendData(const std::string &data); void setMuteMic(bool muted); - void setMicGain(F32 volume); void setSpeakerVolume(F32 volume); void setUserVolume(const LLUUID& id, F32 volume); @@ -303,7 +302,6 @@ public: std::string mName; bool mMuted; // this session is muted. - F32 mMicGain; // gain for this session. F32 mSpeakerVolume; // volume for this session. bool mShuttingDown; @@ -382,7 +380,6 @@ public: static void predSendData(const LLWebRTCVoiceClient::sessionStatePtr_t &session, const std::string& spatial_data); static void predUpdateOwnVolume(const LLWebRTCVoiceClient::sessionStatePtr_t &session, F32 audio_level); static void predSetMuteMic(const LLWebRTCVoiceClient::sessionStatePtr_t &session, bool mute); - static void predSetMicGain(const LLWebRTCVoiceClient::sessionStatePtr_t &session, F32 volume); static void predSetSpeakerVolume(const LLWebRTCVoiceClient::sessionStatePtr_t &session, F32 volume); static void predShutdownSession(const LLWebRTCVoiceClient::sessionStatePtr_t &session); static void predSetUserMute(const LLWebRTCVoiceClient::sessionStatePtr_t &session, const LLUUID& id, bool mute); @@ -607,7 +604,6 @@ class LLVoiceWebRTCConnection : void processIceUpdatesCoro(); virtual void setMuteMic(bool muted); - virtual void setMicGain(F32 volume); virtual void setSpeakerVolume(F32 volume); void setUserVolume(const LLUUID& id, F32 volume); @@ -686,7 +682,6 @@ class LLVoiceWebRTCConnection : std::string mRemoteChannelSDP; bool mMuted; - F32 mMicGain; F32 mSpeakerVolume; bool mShutDown; |