From c826aea079c59950a4064a94825534884fed8bf8 Mon Sep 17 00:00:00 2001 From: Roxie Linden Date: Mon, 1 Apr 2024 21:39:17 -0700 Subject: Fix "default" audio device handling. Windows and Mac/Linux behave slightly differently with respect to Default devices, in that mac/linux (I think) simply assumes the device at index 0 is the default one, and windows has a separate API for enabling the default device. --- indra/newview/llvoicewebrtc.cpp | 66 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 34 deletions(-) (limited to 'indra/newview/llvoicewebrtc.cpp') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index f3d3460022..3cc4aa113c 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -294,19 +294,31 @@ void LLWebRTCVoiceClient::updateSettings() LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE setVoiceEnabled(LLVoiceClient::getInstance()->voiceEnabled()); - setEarLocation(gSavedSettings.getS32("VoiceEarLocation")); + static LLCachedControl sVoiceEarLocation(gSavedSettings, "VoiceEarLocation"); + setEarLocation(sVoiceEarLocation); + + static LLCachedControl sInputDevice(gSavedSettings, "VoiceInputAudioDevice"); + setCaptureDevice(sInputDevice); + + static LLCachedControl sOutputDevice(gSavedSettings, "VoiceOutputAudioDevice"); + setRenderDevice(sOutputDevice); + + static LLCachedControl sMicLevel(gSavedSettings, "AudioLevelMic"); + setMicGain(sMicLevel); - std::string inputDevice = gSavedSettings.getString("VoiceInputAudioDevice"); - setCaptureDevice(inputDevice); - std::string outputDevice = gSavedSettings.getString("VoiceOutputAudioDevice"); - setRenderDevice(outputDevice); - F32 mic_level = gSavedSettings.getF32("AudioLevelMic"); - setMicGain(mic_level); - llwebrtc::LLWebRTCDeviceInterface::AudioConfig config; - config.mEchoCancellation = gSavedSettings.getBOOL("VoiceEchoCancellation"); - config.mAGC = gSavedSettings.getBOOL("VoiceAutomaticGainControl"); - config.mNoiseSuppressionLevel = (llwebrtc::LLWebRTCDeviceInterface::AudioConfig::ENoiseSuppressionLevel)gSavedSettings.getU32("VoiceNoiseSuppressionLevel"); + + static LLCachedControl sEchoCancellation(gSavedSettings, "VoiceEchoCancellation", true); + config.mEchoCancellation = sEchoCancellation; + + static LLCachedControl sAGC(gSavedSettings, "VoiceAutomaticGainControl", true); + config.mAGC = sAGC; + + static LLCachedControl sNoiseSuppressionLevel(gSavedSettings, + "VoiceNoiseSuppressionLevel", + llwebrtc::LLWebRTCDeviceInterface::AudioConfig::ENoiseSuppressionLevel::NOISE_SUPPRESSION_LEVEL_VERY_HIGH); + config.mNoiseSuppressionLevel = (llwebrtc::LLWebRTCDeviceInterface::AudioConfig::ENoiseSuppressionLevel) (U32)sNoiseSuppressionLevel; + mWebRTCDeviceInterface->setAudioConfig(config); } @@ -607,6 +619,7 @@ void LLWebRTCVoiceClient::setDevicesListUpdated(bool state) void LLWebRTCVoiceClient::OnDevicesChanged(const llwebrtc::LLWebRTCVoiceDeviceList& render_devices, const llwebrtc::LLWebRTCVoiceDeviceList& capture_devices) { + LL::WorkQueue::postMaybe(mMainQueue, [=] { @@ -618,43 +631,25 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi const llwebrtc::LLWebRTCVoiceDeviceList &capture_devices) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE - std::string inputDevice = gSavedSettings.getString("VoiceInputAudioDevice"); std::string outputDevice = gSavedSettings.getString("VoiceOutputAudioDevice"); LL_DEBUGS("Voice") << "Setting devices to-input: '" << inputDevice << "' output: '" << outputDevice << "'" << LL_ENDL; clearRenderDevices(); - bool renderDeviceSet = false; for (auto &device : render_devices) { addRenderDevice(LLVoiceDevice(device.mDisplayName, device.mID)); - LL_DEBUGS("Voice") << "Checking render device" << "'" << device.mID << "'" << LL_ENDL; - if (outputDevice == device.mID) - { - renderDeviceSet = true; - } - } - if (!renderDeviceSet) - { - setRenderDevice("Default"); } + setRenderDevice(outputDevice); clearCaptureDevices(); - bool captureDeviceSet = false; for (auto &device : capture_devices) { LL_DEBUGS("Voice") << "Checking capture device:'" << device.mID << "'" << LL_ENDL; addCaptureDevice(LLVoiceDevice(device.mDisplayName, device.mID)); - if (inputDevice == device.mID) - { - captureDeviceSet = true; - } - } - if (!captureDeviceSet) - { - setCaptureDevice("Default"); } + setCaptureDevice(inputDevice); setDevicesListUpdated(true); } @@ -1559,10 +1554,13 @@ F32 LLWebRTCVoiceClient::getUserVolume(const LLUUID& id) // Minimum volume will be returned for users with voice disabled F32 result = LLVoiceClient::VOLUME_MIN; - participantStatePtr_t participant(mSession->findParticipantByID(id)); - if(participant) + if (mSession) { - result = participant->mVolume; + participantStatePtr_t participant(mSession->findParticipantByID(id)); + if (participant) + { + result = participant->mVolume; + } } return result; -- cgit v1.2.3