From eda8634b17133df5f3104d96ad56d3626a90aad8 Mon Sep 17 00:00:00 2001
From: Lynx Linden <lynx@lindenlab.com>
Date: Fri, 11 Dec 2009 15:06:32 +0000
Subject: [PATCH] EXT-3394: Remove manual voice gain controls.

The new Vivox SDK supports Automatic Gain Control (AGC), so we
shouldn't need to change the local gain level from the default of 50%.

This change sets the initial gain level to 50 (instead of 62) and
removes the local gain sliders from the Sound Preferences floater and
the Voice Controls floater. The latter was not hooked up yet anyway.
---
 .../newview/llfloatervoicedevicesettings.cpp  | 32 +--------------
 indra/newview/llfloatervoicedevicesettings.h  |  1 -
 indra/newview/llvoiceclient.cpp               | 12 +-----
 indra/newview/llvoiceclient.h                 |  2 +-
 .../default/xui/en/floater_voice_controls.xml | 20 ---------
 .../xui/en/panel_preferences_sound.xml        | 41 ++-----------------
 6 files changed, 8 insertions(+), 100 deletions(-)

diff --git a/indra/newview/llfloatervoicedevicesettings.cpp b/indra/newview/llfloatervoicedevicesettings.cpp
index 43024a4bd03..3951f4291f7 100644
--- a/indra/newview/llfloatervoicedevicesettings.cpp
+++ b/indra/newview/llfloatervoicedevicesettings.cpp
@@ -40,7 +40,6 @@
 #include "llcombobox.h"
 #include "llfocusmgr.h"
 #include "lliconctrl.h"
-#include "llsliderctrl.h"
 #include "llviewercontrol.h"
 #include "llvoiceclient.h"
 #include "llvoicechannel.h"
@@ -61,9 +60,6 @@ LLPanelVoiceDeviceSettings::LLPanelVoiceDeviceSettings()
 	mOutputDevice = gSavedSettings.getString("VoiceOutputAudioDevice");
 	mDevicesUpdated = FALSE;
 
-	// grab "live" mic volume level
-	mMicVolume = gSavedSettings.getF32("AudioLevelMic");
-
 	// ask for new device enumeration
 	// now do this in onOpen() instead...
 	//gVoiceClient->refreshDeviceLists();
@@ -75,10 +71,6 @@ LLPanelVoiceDeviceSettings::~LLPanelVoiceDeviceSettings()
 
 BOOL LLPanelVoiceDeviceSettings::postBuild()
 {
-	LLSlider* volume_slider = getChild<LLSlider>("mic_volume_slider");
-	// set mic volume tuning slider based on last mic volume setting
-	volume_slider->setValue(mMicVolume);
-
 	childSetCommitCallback("voice_input_device", onCommitInputDevice, this);
 	childSetCommitCallback("voice_output_device", onCommitOutputDevice, this);
 	
@@ -157,15 +149,6 @@ void LLPanelVoiceDeviceSettings::apply()
 		gSavedSettings.setString("VoiceOutputAudioDevice", s);
 		mOutputDevice = s;
 	}
-
-	// assume we are being destroyed by closing our embedding window
-	LLSlider* volume_slider = getChild<LLSlider>("mic_volume_slider");
-	if(volume_slider)
-	{
-		F32 slider_value = (F32)volume_slider->getValue().asReal();
-		gSavedSettings.setF32("AudioLevelMic", slider_value);
-		mMicVolume = slider_value;
-	}
 }
 
 void LLPanelVoiceDeviceSettings::cancel()
@@ -178,22 +161,12 @@ void LLPanelVoiceDeviceSettings::cancel()
 
 	if(mCtrlOutputDevices)
 		mCtrlOutputDevices->setSimple(mOutputDevice);
-
-	gSavedSettings.setF32("AudioLevelMic", mMicVolume);
-	LLSlider* volume_slider = getChild<LLSlider>("mic_volume_slider");
-	if(volume_slider)
-	{
-		volume_slider->setValue(mMicVolume);
-	}
 }
 
 void LLPanelVoiceDeviceSettings::refresh()
 {
-	//grab current volume
-	LLSlider* volume_slider = getChild<LLSlider>("mic_volume_slider");
-	// set mic volume tuning slider based on last mic volume setting
-	F32 current_volume = (F32)volume_slider->getValue().asReal();
-	gVoiceClient->tuningSetMicVolume(current_volume);
+	// update the live input level display
+	gVoiceClient->tuningSetMicVolume();
 
 	// Fill in popup menus
 	mCtrlInputDevices = getChild<LLComboBox>("voice_input_device");
@@ -263,7 +236,6 @@ void LLPanelVoiceDeviceSettings::initialize()
 {
 	mInputDevice = gSavedSettings.getString("VoiceInputAudioDevice");
 	mOutputDevice = gSavedSettings.getString("VoiceOutputAudioDevice");
-	mMicVolume = gSavedSettings.getF32("AudioLevelMic");
 	mDevicesUpdated = FALSE;
 
 	// ask for new device enumeration
diff --git a/indra/newview/llfloatervoicedevicesettings.h b/indra/newview/llfloatervoicedevicesettings.h
index d67283d0a22..20958af780c 100644
--- a/indra/newview/llfloatervoicedevicesettings.h
+++ b/indra/newview/llfloatervoicedevicesettings.h
@@ -56,7 +56,6 @@ class LLPanelVoiceDeviceSettings : public LLPanel
 	static void onCommitInputDevice(LLUICtrl* ctrl, void* user_data);
 	static void onCommitOutputDevice(LLUICtrl* ctrl, void* user_data);
 
-	F32 mMicVolume;
 	std::string mInputDevice;
 	std::string mOutputDevice;
 	class LLComboBox		*mCtrlInputDevices;
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index 63acba50e75..aa69b468579 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -128,16 +128,8 @@ static int scale_mic_volume(float volume)
 static int scale_speaker_volume(float volume)
 {
 	// incoming volume has the range [0.0 ... 1.0], with 0.5 as the default.
-	// Map it as follows: 0.0 -> 0, 0.5 -> 62, 1.0 -> 75
-	
-	volume -= 0.5f;		// offset volume to the range [-0.5 ... 0.5], with 0 at the default.
-	int scaled_volume = 62;	// offset scaled_volume by its default level
-	if(volume < 0.0f)
-		scaled_volume += ((int)(volume * 124.0f));	// (62 - 0) * 2
-	else
-		scaled_volume += ((int)(volume * 26.0f));	// (75 - 62) * 2
-	
-	return scaled_volume;
+	// Map it as follows: 0.0 -> 0, 0.5 -> 50, 1.0 -> 100
+	return (int)(volume * 100.0f);
 }
 
 class LLViewerVoiceAccountProvisionResponder :
diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h
index edfe0173f8d..92e79a004d8 100644
--- a/indra/newview/llvoiceclient.h
+++ b/indra/newview/llvoiceclient.h
@@ -125,7 +125,7 @@ class LLVoiceClient: public LLSingleton<LLVoiceClient>
 		void tuningCaptureStartSendMessage(int duration);
 		void tuningCaptureStopSendMessage();
 		
-		void tuningSetMicVolume(float volume);
+		void tuningSetMicVolume(float volume=0.5f);
 		void tuningSetSpeakerVolume(float volume);
 		float tuningGetEnergy(void);
 				
diff --git a/indra/newview/skins/default/xui/en/floater_voice_controls.xml b/indra/newview/skins/default/xui/en/floater_voice_controls.xml
index 1ebc51f504e..c1a211967c1 100644
--- a/indra/newview/skins/default/xui/en/floater_voice_controls.xml
+++ b/indra/newview/skins/default/xui/en/floater_voice_controls.xml
@@ -105,26 +105,6 @@
                  top="0"
                  width="24" />
             </layout_panel>
-            <layout_panel
-             layout="topleft"
-             name="volume_slider_panel"
-             top="0"
-             user_resize="false"
-             width="138">
-                <slider_bar
-                 control_name="AudioLevelMic"
-                 follows="left|right|top"
-                 height="24"
-                 increment="0.05"
-                 layout="topleft"
-                 left="0"
-                 max_val="2"
-                 name="volume_slider_bar"
-                 tool_tip="Master Volume"
-                 top="0"
-                 value="0.75"
-                 width="138" />
-            </layout_panel>
             <layout_panel
              auto_resize="false"
              layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_sound.xml b/indra/newview/skins/default/xui/en/panel_preferences_sound.xml
index 102a53ad902..5332007bafa 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_sound.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_sound.xml
@@ -399,31 +399,6 @@
      name="voice_input_device"
      top_pad="0"
      width="200" />
-   <text
-     type="string"
-     length="1"
-     follows="left|top"
-     height="16"
-     layout="topleft"
-     left="165"
-     name="My volume label"
-     top_pad="10"
-     width="200">
-        My volume:
-    </text>
-      <slider_bar
-        control_name="AudioLevelMic"
-     follows="left|top"
-     height="17"
-     increment="0.05"
-     initial_value="1.0"
-     layout="topleft"
-     left="160"
-     max_val="2"
-     name="mic_volume_slider"
-     tool_tip="Change the volume using this slider"
-     top_pad="0"
-     width="220" />
     <text
      type="string"
      text_color="EmphasisColor"
@@ -433,7 +408,7 @@
      layout="topleft"
      left_pad="5"
      name="wait_text"
-     top_delta="0"
+     top_delta="5"
      width="110">
         Please wait
     </text>
@@ -442,7 +417,7 @@
      layout="topleft"
      left_delta="0"
      name="bar0"
-     top_delta="5"
+     top_delta="-5"
      width="20" />
     <locate
      height="20"
@@ -472,23 +447,13 @@
      name="bar4"
      top_delta="0"
      width="20" />
-  <!--  <text
-     type="string"
-     height="37"
-     left="30"
-     name="voice_intro_text1"
-     top_pad="-4"
-     width="410"
-     word_wrap="true">
-        Adjust the slider to control how loud you sound to other people. To test your volume, simply speak into your microphone
-    </text>-->
           <icon
              height="18"
              image_name="Parcel_Voice_Light"
              left="80"
              name="speaker_icon"
              mouse_opaque="false"
-             top_pad="-8"
+             top_pad="4"
              visible="true"
              width="22" />
     <text
-- 
GitLab