From 4ab4bfb2c7bd79a89b347969c7812db366538ed9 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Sun, 15 Apr 2018 09:41:47 -0400 Subject: VOICE-59: better fix for display human-friendly names for voice input and output devices --- indra/newview/llpanelvoicedevicesettings.cpp | 33 ++++++++-------------------- indra/newview/llvoiceclient.h | 15 +++++++++++-- indra/newview/llvoicevivox.cpp | 33 ++++++++++------------------ indra/newview/llvoicevivox.h | 4 ++-- 4 files changed, 35 insertions(+), 50 deletions(-) diff --git a/indra/newview/llpanelvoicedevicesettings.cpp b/indra/newview/llpanelvoicedevicesettings.cpp index 3dfa559dac..28631e2b7b 100644 --- a/indra/newview/llpanelvoicedevicesettings.cpp +++ b/indra/newview/llpanelvoicedevicesettings.cpp @@ -38,8 +38,6 @@ // Library includes (after viewer) #include "lluictrlfactory.h" -#include "llmemorystream.h" -#include "llsdserialize.h" static LLPanelInjector t_panel_group_general("panel_voice_device_settings"); static const std::string DEFAULT_DEVICE("Default"); @@ -234,25 +232,18 @@ void LLPanelVoiceDeviceSettings::refresh() } else if (LLVoiceClient::getInstance()->deviceSettingsUpdated()) { - LLVoiceDeviceList::const_iterator iter; + LLVoiceDeviceList::const_iterator device; if(mCtrlInputDevices) { mCtrlInputDevices->removeall(); mCtrlInputDevices->add(getLocalizedDeviceName(DEFAULT_DEVICE), DEFAULT_DEVICE, ADD_BOTTOM); - for(iter=LLVoiceClient::getInstance()->getCaptureDevices().begin(); - iter != LLVoiceClient::getInstance()->getCaptureDevices().end(); - iter++) + for(device=LLVoiceClient::getInstance()->getCaptureDevices().begin(); + device != LLVoiceClient::getInstance()->getCaptureDevices().end(); + device++) { - // the devices in the list are serialized as an LLSD map - // deserialize to separate the display and device names - std::string device_names(*iter); - size_t len = device_names.size(); - LLMemoryStream device_stream((U8*)device_names.c_str(), len); - LLSD device = LLSDSerialize::fromNotation(device_stream, len); - - mCtrlInputDevices->add(getLocalizedDeviceName(device["display"]), device["device"], ADD_BOTTOM); + mCtrlInputDevices->add(getLocalizedDeviceName(device->display_name), device->full_name, ADD_BOTTOM); } // Fix invalid input audio device preference. @@ -269,17 +260,11 @@ void LLPanelVoiceDeviceSettings::refresh() mCtrlOutputDevices->removeall(); mCtrlOutputDevices->add(getLocalizedDeviceName(DEFAULT_DEVICE), DEFAULT_DEVICE, ADD_BOTTOM); - for(iter= LLVoiceClient::getInstance()->getRenderDevices().begin(); - iter != LLVoiceClient::getInstance()->getRenderDevices().end(); iter++) + for(device = LLVoiceClient::getInstance()->getRenderDevices().begin(); + device != LLVoiceClient::getInstance()->getRenderDevices().end(); + device++) { - // the devices in the list are serialized as an LLSD map - // deserialize to separate the display and device names - std::string device_names(*iter); - size_t len = device_names.size(); - LLMemoryStream device_stream((U8*)device_names.c_str(), len); - LLSD device = LLSDSerialize::fromNotation(device_stream, len); - - mCtrlOutputDevices->add(getLocalizedDeviceName(device["display"]), device["display"], ADD_BOTTOM); + mCtrlOutputDevices->add(getLocalizedDeviceName(device->display_name), device->full_name, ADD_BOTTOM); } // Fix invalid output audio device preference. diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index 32637dcf42..337f01f3e5 100644 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -40,8 +40,19 @@ class LLVOAvatar; // devices -typedef std::vector LLVoiceDeviceList; - +class LLVoiceDevice +{ + public: + std::string display_name; // friendly value for the user + std::string full_name; // internal value for selection + + LLVoiceDevice(const std::string& display_name, const std::string& full_name) + :display_name(display_name) + ,full_name(full_name) + { + }; +}; +typedef std::vector LLVoiceDeviceList; class LLVoiceClientParticipantObserver { diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 90e106b000..741c04ac8b 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -48,7 +48,6 @@ #include "llviewercontrol.h" #include "llappviewer.h" // for gDisconnected, gDisableVoice #include "llprocess.h" -#include "llsdserialize.h" // Viewer includes #include "llmutelist.h" // to check for muted avatars @@ -2323,15 +2322,10 @@ void LLVivoxVoiceClient::clearCaptureDevices() mCaptureDevices.clear(); } -void LLVivoxVoiceClient::addCaptureDevice(const std::string& display_name, const std::string& device_name) +void LLVivoxVoiceClient::addCaptureDevice(const LLVoiceDevice& device) { - LL_DEBUGS("Voice") << "display: '" << display_name << "' device: '" << device_name << "'" << LL_ENDL; - LLSD device(LLSD::emptyMap()); - device["display"]=display_name; - device["device"]=device_name; - std::ostringstream device_names; - LLSDSerialize::toNotation(device, device_names); - mCaptureDevices.push_back(device_names.str()); + LL_DEBUGS("Voice") << "display: '" << device.display_name << "' device: '" << device.full_name << "'" << LL_ENDL; + mCaptureDevices.push_back(device); } LLVoiceDeviceList& LLVivoxVoiceClient::getCaptureDevices() @@ -2369,15 +2363,10 @@ void LLVivoxVoiceClient::clearRenderDevices() mRenderDevices.clear(); } -void LLVivoxVoiceClient::addRenderDevice(const std::string& display_name, const std::string& device_name) +void LLVivoxVoiceClient::addRenderDevice(const LLVoiceDevice& device) { - LL_DEBUGS("Voice") << "display: '" << display_name << "' device: '" << device_name << "'" << LL_ENDL; - LLSD device(LLSD::emptyMap()); - device["display"]=display_name; - device["device"]=device_name; - std::ostringstream device_names; - LLSDSerialize::toNotation(device, device_names); - mRenderDevices.push_back(device_names.str()); + LL_DEBUGS("Voice") << "display: '" << device.display_name << "' device: '" << device.full_name << "'" << LL_ENDL; + mRenderDevices.push_back(device); } LLVoiceDeviceList& LLVivoxVoiceClient::getRenderDevices() @@ -2525,13 +2514,13 @@ bool LLVivoxVoiceClient::deviceSettingsAvailable() } bool LLVivoxVoiceClient::deviceSettingsUpdated() { + bool updated = mDevicesListUpdated; if (mDevicesListUpdated) { // a hot swap event or a polling of the audio devices has been parsed since the last redraw of the input and output device panel. - mDevicesListUpdated = !mDevicesListUpdated; // toggle the setting - return true; + mDevicesListUpdated = false; // toggle the setting } - return false; + return updated; } void LLVivoxVoiceClient::refreshDeviceLists(bool clearCurrentList) @@ -7026,11 +7015,11 @@ void LLVivoxProtocolParser::EndTag(const char *tag) } else if (!stricmp("CaptureDevice", tag)) { - LLVivoxVoiceClient::getInstance()->addCaptureDevice(displayNameString, deviceString); + LLVivoxVoiceClient::getInstance()->addCaptureDevice(LLVoiceDevice(displayNameString, deviceString)); } else if (!stricmp("RenderDevice", tag)) { - LLVivoxVoiceClient::getInstance()->addRenderDevice(displayNameString, deviceString); + LLVivoxVoiceClient::getInstance()->addRenderDevice(LLVoiceDevice(displayNameString, deviceString)); } else if (!stricmp("BlockMask", tag)) blockMask = string; diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h index b4cf94444b..50862cea1e 100644 --- a/indra/newview/llvoicevivox.h +++ b/indra/newview/llvoicevivox.h @@ -432,10 +432,10 @@ protected: //---------------------------------- // devices void clearCaptureDevices(); - void addCaptureDevice(const std::string& display_name, const std::string& device_name); + void addCaptureDevice(const LLVoiceDevice& device); void clearRenderDevices(); void setDevicesListUpdated(bool state); - void addRenderDevice(const std::string& display_name, const std::string& device_name); + void addRenderDevice(const LLVoiceDevice& device); void buildSetAudioDevices(std::ostringstream &stream); void getCaptureDevicesSendMessage(); -- cgit v1.2.3