summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatervoicedevicesettings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatervoicedevicesettings.cpp')
-rw-r--r--indra/newview/llfloatervoicedevicesettings.cpp176
1 files changed, 110 insertions, 66 deletions
diff --git a/indra/newview/llfloatervoicedevicesettings.cpp b/indra/newview/llfloatervoicedevicesettings.cpp
index 12d12f37f2..34277001ee 100644
--- a/indra/newview/llfloatervoicedevicesettings.cpp
+++ b/indra/newview/llfloatervoicedevicesettings.cpp
@@ -3,31 +3,25 @@
* @author Richard Nelson
* @brief Voice communication set-up
*
- * $LicenseInfo:firstyear=2007&license=viewergpl$
- *
- * Copyright (c) 2007-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -36,7 +30,6 @@
#include "llfloatervoicedevicesettings.h"
// Viewer includes
-#include "llagent.h"
#include "llbutton.h"
#include "llcombobox.h"
#include "llfocusmgr.h"
@@ -44,12 +37,15 @@
#include "llsliderctrl.h"
#include "llviewercontrol.h"
#include "llvoiceclient.h"
-#include "llimpanel.h"
+#include "llvoicechannel.h"
// Library includes (after viewer)
#include "lluictrlfactory.h"
+static LLRegisterPanelClassWrapper<LLPanelVoiceDeviceSettings> t_panel_group_general("panel_voice_device_settings");
+
+
LLPanelVoiceDeviceSettings::LLPanelVoiceDeviceSettings()
: LLPanel()
{
@@ -62,9 +58,6 @@ LLPanelVoiceDeviceSettings::LLPanelVoiceDeviceSettings()
// grab "live" mic volume level
mMicVolume = gSavedSettings.getF32("AudioLevelMic");
- // ask for new device enumeration
- // now do this in onOpen() instead...
- //gVoiceClient->refreshDeviceLists();
}
LLPanelVoiceDeviceSettings::~LLPanelVoiceDeviceSettings()
@@ -83,40 +76,58 @@ BOOL LLPanelVoiceDeviceSettings::postBuild()
return TRUE;
}
-void LLPanelVoiceDeviceSettings::draw()
+// virtual
+void LLPanelVoiceDeviceSettings::handleVisibilityChange ( BOOL new_visibility )
{
- // let user know that volume indicator is not yet available
- bool is_in_tuning_mode = gVoiceClient->inTuningMode();
- childSetVisible("wait_text", !is_in_tuning_mode);
-
- LLPanel::draw();
-
- F32 voice_power = gVoiceClient->tuningGetEnergy();
- S32 discrete_power = 0;
-
- if (!is_in_tuning_mode)
+ if (new_visibility)
{
- discrete_power = 0;
+ initialize();
}
else
{
- discrete_power = llmin(4, llfloor((voice_power / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 4.f));
+ cleanup();
+ // when closing this window, turn of visiblity control so that
+ // next time preferences is opened we don't suspend voice
+ gSavedSettings.setBOOL("ShowDeviceSettings", FALSE);
}
-
+}
+void LLPanelVoiceDeviceSettings::draw()
+{
+ refresh();
+
+ // let user know that volume indicator is not yet available
+ bool is_in_tuning_mode = LLVoiceClient::getInstance()->inTuningMode();
+ getChildView("wait_text")->setVisible( !is_in_tuning_mode);
+
+ LLPanel::draw();
+
if (is_in_tuning_mode)
{
- for(S32 power_bar_idx = 0; power_bar_idx < 5; power_bar_idx++)
+ const S32 num_bars = 5;
+ F32 voice_power = LLVoiceClient::getInstance()->tuningGetEnergy() / LLVoiceClient::OVERDRIVEN_POWER_LEVEL;
+ S32 discrete_power = llmin(num_bars, llfloor(voice_power * (F32)num_bars + 0.1f));
+
+ for(S32 power_bar_idx = 0; power_bar_idx < num_bars; power_bar_idx++)
{
std::string view_name = llformat("%s%d", "bar", power_bar_idx);
LLView* bar_view = getChild<LLView>(view_name);
if (bar_view)
{
+ gl_rect_2d(bar_view->getRect(), LLColor4::grey, TRUE);
+
+ LLColor4 color;
if (power_bar_idx < discrete_power)
{
- LLColor4 color = (power_bar_idx >= 3) ? gSavedSkinSettings.getColor4("OverdrivenColor") : gSavedSkinSettings.getColor4("SpeakingColor");
- gl_rect_2d(bar_view->getRect(), color, TRUE);
+ color = (power_bar_idx >= 3) ? LLUIColorTable::instance().getColor("OverdrivenColor") : LLUIColorTable::instance().getColor("SpeakingColor");
+ }
+ else
+ {
+ color = LLUIColorTable::instance().getColor("PanelFocusBackgroundColor");
}
- gl_rect_2d(bar_view->getRect(), LLColor4::grey, FALSE);
+
+ LLRect color_rect = bar_view->getRect();
+ color_rect.stretch(-1);
+ gl_rect_2d(color_rect, color, TRUE);
}
}
}
@@ -174,13 +185,13 @@ void LLPanelVoiceDeviceSettings::refresh()
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);
+ LLVoiceClient::getInstance()->tuningSetMicVolume(current_volume);
// Fill in popup menus
mCtrlInputDevices = getChild<LLComboBox>("voice_input_device");
mCtrlOutputDevices = getChild<LLComboBox>("voice_output_device");
- if(!gVoiceClient->deviceSettingsAvailable())
+ if(!LLVoiceClient::getInstance()->deviceSettingsAvailable())
{
// The combo boxes are disabled, since we can't get the device settings from the daemon just now.
// Put the currently set default (ONLY) in the box, and select it.
@@ -199,19 +210,34 @@ void LLPanelVoiceDeviceSettings::refresh()
}
else if (!mDevicesUpdated)
{
- LLVoiceClient::deviceList *devices;
-
- LLVoiceClient::deviceList::iterator iter;
+ LLVoiceDeviceList::const_iterator iter;
if(mCtrlInputDevices)
{
mCtrlInputDevices->removeall();
mCtrlInputDevices->add( getString("default_text"), ADD_BOTTOM );
- devices = gVoiceClient->getCaptureDevices();
- for(iter=devices->begin(); iter != devices->end(); iter++)
+ for(iter=LLVoiceClient::getInstance()->getCaptureDevices().begin();
+ iter != LLVoiceClient::getInstance()->getCaptureDevices().end();
+ iter++)
{
- mCtrlInputDevices->add( *iter, ADD_BOTTOM );
+ // Lets try to localize some system device names. EXT-8375
+ std::string device_name = *iter;
+ LLStringUtil::toLower(device_name); //compare in low case
+ if ("default system device" == device_name)
+ {
+ device_name = getString(device_name);
+ }
+ else if ("no device" == device_name)
+ {
+ device_name = getString(device_name);
+ }
+ else
+ {
+ // restore original value
+ device_name = *iter;
+ }
+ mCtrlInputDevices->add(device_name, ADD_BOTTOM );
}
if(!mCtrlInputDevices->setSimple(mInputDevice))
@@ -225,10 +251,26 @@ void LLPanelVoiceDeviceSettings::refresh()
mCtrlOutputDevices->removeall();
mCtrlOutputDevices->add( getString("default_text"), ADD_BOTTOM );
- devices = gVoiceClient->getRenderDevices();
- for(iter=devices->begin(); iter != devices->end(); iter++)
+ for(iter= LLVoiceClient::getInstance()->getRenderDevices().begin();
+ iter != LLVoiceClient::getInstance()->getRenderDevices().end(); iter++)
{
- mCtrlOutputDevices->add( *iter, ADD_BOTTOM );
+ // Lets try to localize some system device names. EXT-8375
+ std::string device_name = *iter;
+ LLStringUtil::toLower(device_name); //compare in low case
+ if ("default system device" == device_name)
+ {
+ device_name = getString(device_name);
+ }
+ else if ("no device" == device_name)
+ {
+ device_name = getString(device_name);
+ }
+ else
+ {
+ // restore original value
+ device_name = *iter;
+ }
+ mCtrlOutputDevices->add(device_name, ADD_BOTTOM );
}
if(!mCtrlOutputDevices->setSimple(mOutputDevice))
@@ -248,34 +290,34 @@ void LLPanelVoiceDeviceSettings::initialize()
mDevicesUpdated = FALSE;
// ask for new device enumeration
- gVoiceClient->refreshDeviceLists();
+ LLVoiceClient::getInstance()->refreshDeviceLists();
// put voice client in "tuning" mode
- gVoiceClient->tuningStart();
+ LLVoiceClient::getInstance()->tuningStart();
LLVoiceChannel::suspend();
}
void LLPanelVoiceDeviceSettings::cleanup()
{
- gVoiceClient->tuningStop();
+ LLVoiceClient::getInstance()->tuningStop();
LLVoiceChannel::resume();
}
// static
void LLPanelVoiceDeviceSettings::onCommitInputDevice(LLUICtrl* ctrl, void* user_data)
{
- if(gVoiceClient)
+ if(LLVoiceClient::getInstance())
{
- gVoiceClient->setCaptureDevice(ctrl->getValue().asString());
+ LLVoiceClient::getInstance()->setCaptureDevice(ctrl->getValue().asString());
}
}
// static
void LLPanelVoiceDeviceSettings::onCommitOutputDevice(LLUICtrl* ctrl, void* user_data)
{
- if(gVoiceClient)
+ if(LLVoiceClient::getInstance())
{
- gVoiceClient->setRenderDevice(ctrl->getValue().asString());
+ LLVoiceClient::getInstance()->setRenderDevice(ctrl->getValue().asString());
}
}
@@ -284,7 +326,7 @@ void LLPanelVoiceDeviceSettings::onCommitOutputDevice(LLUICtrl* ctrl, void* user
//
LLFloaterVoiceDeviceSettings::LLFloaterVoiceDeviceSettings(const LLSD& seed)
- : LLFloater(),
+ : LLFloater(seed),
mDevicePanel(NULL)
{
mFactoryMap["device_settings"] = LLCallbackMap(createPanelVoiceDeviceSettings, this);
@@ -297,6 +339,8 @@ BOOL LLFloaterVoiceDeviceSettings::postBuild()
center();
return TRUE;
}
+
+// virtual
void LLFloaterVoiceDeviceSettings::onOpen(const LLSD& key)
{
if(mDevicePanel)
@@ -305,14 +349,14 @@ void LLFloaterVoiceDeviceSettings::onOpen(const LLSD& key)
}
}
-void LLFloaterVoiceDeviceSettings::onClose(bool app_quitting)
+// virtual
+void LLFloaterVoiceDeviceSettings::onClose(bool app_settings)
{
if(mDevicePanel)
{
+ mDevicePanel->apply();
mDevicePanel->cleanup();
}
-
- setVisible(FALSE);
}
void LLFloaterVoiceDeviceSettings::apply()