diff options
| author | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2025-10-21 23:19:52 +0300 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2025-10-22 22:43:57 +0300 |
| commit | bb26aa3c2cb8ff961668cf0ad8180d3e9c57f941 (patch) | |
| tree | 5234aecd40591493a5d18c450e90b21b57868614 /indra/newview | |
| parent | 6a5d4e0e3de5448835b58177ce7a64119facbd28 (diff) | |
#4652 Improve switching of webrtc devices
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llvoicewebrtc.cpp | 34 | ||||
| -rw-r--r-- | indra/newview/llvoicewebrtc.h | 1 |
2 files changed, 34 insertions, 1 deletions
diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index fba7098906..93f8f0d14a 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -699,6 +699,7 @@ void LLWebRTCVoiceClient::setCaptureDevice(const std::string& name) { if (mWebRTCDeviceInterface) { + LL_DEBUGS("Voice") << "new capture device is " << name << LL_ENDL; mWebRTCDeviceInterface->setCaptureDevice(name); } } @@ -727,10 +728,15 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi return; } LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; + + LL_DEBUGS("Voice") << "Reiniting " << LL_ENDL; + std::string inputDevice = gSavedSettings.getString("VoiceInputAudioDevice"); std::string outputDevice = gSavedSettings.getString("VoiceOutputAudioDevice"); LL_DEBUGS("Voice") << "Setting devices to-input: '" << inputDevice << "' output: '" << outputDevice << "'" << LL_ENDL; + bool update_render = false; + bool update_capture = false; // only set the render device if the device list has changed. if (mRenderDevices.size() != render_devices.size() || !std::equal(mRenderDevices.begin(), @@ -744,7 +750,7 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi { addRenderDevice(LLVoiceDevice(device.mDisplayName, device.mID)); } - setRenderDevice(outputDevice); + update_render = true; } // only set the capture device if the device list has changed. @@ -761,6 +767,22 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi addCaptureDevice(LLVoiceDevice(device.mDisplayName, device.mID)); } + update_capture = true; + } + + if (update_render && update_capture) + { + // Do both in one go to avoid multiple deployDevices calls. + // And to avoid situation where workerDeployDevices has an + // obsolete device id + setDevices(inputDevice, outputDevice); + } + else if (update_render) + { + setRenderDevice(outputDevice); + } + else if (update_capture) + { setCaptureDevice(inputDevice); } @@ -789,10 +811,20 @@ void LLWebRTCVoiceClient::setRenderDevice(const std::string& name) { if (mWebRTCDeviceInterface) { + LL_DEBUGS("Voice") << "new render device is " << name << LL_ENDL; mWebRTCDeviceInterface->setRenderDevice(name); } } +void LLWebRTCVoiceClient::setDevices(const std::string& capture_name, const std::string& render_name) +{ + if (mWebRTCDeviceInterface) + { + LL_DEBUGS("Voice") << "new capture device: " << capture_name << " New render device: " << render_name << LL_ENDL; + mWebRTCDeviceInterface->setDevices(capture_name, render_name); + } +} + void LLWebRTCVoiceClient::tuningStart() { if (!mIsInTuningMode) diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h index 2ce575852a..54d8e54ce2 100644 --- a/indra/newview/llvoicewebrtc.h +++ b/indra/newview/llvoicewebrtc.h @@ -124,6 +124,7 @@ public: void setCaptureDevice(const std::string& name) override; void setRenderDevice(const std::string& name) override; + void setDevices(const std::string& capture_name, const std::string& render_name); LLVoiceDeviceList& getCaptureDevices() override; LLVoiceDeviceList& getRenderDevices() override; |
