aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/viewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/viewer.cpp944
1 files changed, 369 insertions, 575 deletions
diff --git a/linden/indra/newview/viewer.cpp b/linden/indra/newview/viewer.cpp
index 9bfa373..2890269 100644
--- a/linden/indra/newview/viewer.cpp
+++ b/linden/indra/newview/viewer.cpp
@@ -71,7 +71,7 @@
71#include "smrtheap/smrtheap.h" 71#include "smrtheap/smrtheap.h"
72#endif // LL_WINDOWS && LL_RELEASE_FOR_DOWNLOAD && LL_USE_SMARTHEAP 72#endif // LL_WINDOWS && LL_RELEASE_FOR_DOWNLOAD && LL_USE_SMARTHEAP
73 73
74#elif LL_DARWIN || LL_LINUX 74#elif LL_DARWIN || LL_LINUX || LL_SOLARIS
75 75
76 # include <sys/socket.h> 76 # include <sys/socket.h>
77// # include <sys/stat.h> // mkdir() 77// # include <sys/stat.h> // mkdir()
@@ -88,6 +88,11 @@
88 # include <cxxabi.h> // for symbol demangling 88 # include <cxxabi.h> // for symbol demangling
89 # include "ELFIO.h" // for better backtraces 89 # include "ELFIO.h" // for better backtraces
90 # endif // LL_ELFBIN 90 # endif // LL_ELFBIN
91 #elif LL_SOLARIS
92 # include <sys/types.h>
93 # include <unistd.h>
94 # include <fcntl.h>
95 # include <ucontext.h>
91 #endif 96 #endif
92 97
93 #if LL_DARWIN 98 #if LL_DARWIN
@@ -164,6 +169,7 @@
164#include "llfasttimerview.h" 169#include "llfasttimerview.h"
165#include "llfeaturemanager.h" 170#include "llfeaturemanager.h"
166#include "llfirstuse.h" 171#include "llfirstuse.h"
172#include "llfloateractivespeakers.h"
167#include "llfloatertools.h" 173#include "llfloatertools.h"
168#include "llfloaterworldmap.h" 174#include "llfloaterworldmap.h"
169#include "llfloaterhtmlhelp.h" 175#include "llfloaterhtmlhelp.h"
@@ -177,6 +183,7 @@
177#include "llhudmanager.h" 183#include "llhudmanager.h"
178#include "llhttpclient.h" 184#include "llhttpclient.h"
179#include "llimview.h" 185#include "llimview.h"
186#include "llimpanel.h"
180#include "llinventorymodel.h" 187#include "llinventorymodel.h"
181#include "llinventoryview.h" 188#include "llinventoryview.h"
182#include "llkeyboard.h" 189#include "llkeyboard.h"
@@ -202,9 +209,11 @@
202#include "lltoolmgr.h" 209#include "lltoolmgr.h"
203#include "lltracker.h" 210#include "lltracker.h"
204#include "llurlwhitelist.h" 211#include "llurlwhitelist.h"
212#include "llv4math.h" // LL_VECTORIZE
205#include "llviewerbuild.h" 213#include "llviewerbuild.h"
206#include "llviewercamera.h" 214#include "llviewercamera.h"
207#include "llviewercontrol.h" 215#include "llviewercontrol.h"
216#include "llviewerjointmesh.h"
208#include "llviewerimagelist.h" 217#include "llviewerimagelist.h"
209#include "llviewerkeyboard.h" 218#include "llviewerkeyboard.h"
210#include "llviewermenu.h" 219#include "llviewermenu.h"
@@ -234,6 +243,7 @@
234#include "llface.h" 243#include "llface.h"
235#include "audiosettings.h" 244#include "audiosettings.h"
236#include "res/resource.h" 245#include "res/resource.h"
246#include "llvoiceclient.h"
237 247
238#if LL_WINDOWS 248#if LL_WINDOWS
239#include "llwindebug.h" 249#include "llwindebug.h"
@@ -253,6 +263,12 @@
253#endif 263#endif
254#endif 264#endif
255 265
266#if LL_GSTREAMER_ENABLED
267// ugh, do this instead of pulling in the gstreamer headers which indirectly
268// clash with expat in the monster that is viewer.cpp ... sigh.
269void UnloadGStreamer();
270#endif // LL_GSTREAMER_ENABLED
271
256#include "llmediaengine.h" 272#include "llmediaengine.h"
257 273
258#if LL_LIBXUL_ENABLED 274#if LL_LIBXUL_ENABLED
@@ -267,6 +283,7 @@ void errorCallback(const std::string &error_string);
267S32 gCrashBehavior = CRASH_BEHAVIOR_ASK; 283S32 gCrashBehavior = CRASH_BEHAVIOR_ASK;
268void (*gCrashCallback)(void) = NULL; 284void (*gCrashCallback)(void) = NULL;
269BOOL gReportedCrash = FALSE; 285BOOL gReportedCrash = FALSE;
286
270bool gVerifySSLCert = true; 287bool gVerifySSLCert = true;
271 288
272BOOL gHandleKeysAsync = FALSE; 289BOOL gHandleKeysAsync = FALSE;
@@ -295,15 +312,9 @@ const F32 DEFAULT_AFK_TIMEOUT = 5.f * 60.f; // time with no input before user fl
295const char *VFS_DATA_FILE_BASE = "data.db2.x."; 312const char *VFS_DATA_FILE_BASE = "data.db2.x.";
296const char *VFS_INDEX_FILE_BASE = "index.db2.x."; 313const char *VFS_INDEX_FILE_BASE = "index.db2.x.";
297 314
298const F32 MAX_USER_FOG_RATIO = 4.f;
299const F32 MIN_USER_FOG_RATIO = 0.5f;
300
301F32 gSimLastTime; 315F32 gSimLastTime;
302F32 gSimFrames; 316F32 gSimFrames;
303 317
304const S32 MAX_USER_COMPOSITE_LIMIT = 100;
305const S32 MIN_USER_COMPOSITE_LIMIT = 0;
306
307//#define RENDER_CLOUD_DENSITY // uncomment to look at cloud density 318//#define RENDER_CLOUD_DENSITY // uncomment to look at cloud density
308 319
309///////////////////////////////////////////////////////////////////////////////// 320/////////////////////////////////////////////////////////////////////////////////
@@ -321,9 +332,6 @@ LLString gDisabledMessage;
321BOOL gHideLinks = FALSE; 332BOOL gHideLinks = FALSE;
322 333
323// This is whether or not we are connect to a production grid. 334// This is whether or not we are connect to a production grid.
324// HACK/TEMP - the code that used to set this based on the userserver selection
325// is gone, so there is no code that currently sets this to TRUE. Since we don't
326// want to ship as "FALSE", hardcoding it to TRUE for now. Please fix.
327BOOL gInProductionGrid = FALSE; 335BOOL gInProductionGrid = FALSE;
328 336
329//#define APPLE_PREVIEW // Define this if you're doing a preview build on the Mac 337//#define APPLE_PREVIEW // Define this if you're doing a preview build on the Mac
@@ -365,6 +373,7 @@ BOOL gMultipleViewersOK = FALSE;
365BOOL gMultipleViewersOK = TRUE; 373BOOL gMultipleViewersOK = TRUE;
366#endif 374#endif
367BOOL gSecondInstance = FALSE; 375BOOL gSecondInstance = FALSE;
376BOOL gDisableVoice = FALSE;
368 377
369LLString gArgs; 378LLString gArgs;
370 379
@@ -514,6 +523,7 @@ static const char USAGE[] = "\n"
514" -noinvlib Do not request inventory library\n" 523" -noinvlib Do not request inventory library\n"
515" -multiple allow multiple viewers\n" 524" -multiple allow multiple viewers\n"
516" -nomultiple block multiple viewers\n" 525" -nomultiple block multiple viewers\n"
526" -novoice disable voice\n"
517" -ignorepixeldepth ignore pixel depth settings\n" 527" -ignorepixeldepth ignore pixel depth settings\n"
518" -cooperative [ms] yield some idle time to local host\n" 528" -cooperative [ms] yield some idle time to local host\n"
519" -skin ui/branding skin folder to use\n" 529" -skin ui/branding skin folder to use\n"
@@ -633,10 +643,11 @@ OSStatus simpleDialogHandler(EventHandlerCallRef handler, EventRef event, void *
633OSStatus DisplayReleaseNotes(void); 643OSStatus DisplayReleaseNotes(void);
634#endif // LL_DARWIN 644#endif // LL_DARWIN
635 645
636void ui_audio_callback(const LLUUID& uuid, F32 volume) 646void ui_audio_callback(const LLUUID& uuid)
637{ 647{
638 if (gAudiop) 648 if (gAudiop)
639 { 649 {
650 F32 volume = gSavedSettings.getF32("AudioLevelUI");
640 gAudiop->triggerSound(uuid, gAgent.getID(), volume); 651 gAudiop->triggerSound(uuid, gAgent.getID(), volume);
641 } 652 }
642} 653}
@@ -793,6 +804,10 @@ int main( int argc, char **argv )
793#endif 804#endif
794{ 805{
795 LLMemType mt1(LLMemType::MTYPE_STARTUP); 806 LLMemType mt1(LLMemType::MTYPE_STARTUP);
807
808#if LL_SOLARIS && defined(__sparc)
809 asm ("ta\t6"); // NOTE: Make sure memory alignment is enforced on SPARC
810#endif
796 811
797#if 1 812#if 1
798 // This will eventually be done in LLApp 813 // This will eventually be done in LLApp
@@ -924,6 +939,11 @@ int main( int argc, char **argv )
924 // Hack to detect -multiple so we can disable the marker file check (which will always fail) 939 // Hack to detect -multiple so we can disable the marker file check (which will always fail)
925 gMultipleViewersOK = TRUE; 940 gMultipleViewersOK = TRUE;
926 } 941 }
942 else if (!strcmp(argv[j], "-novoice"))
943 {
944 // May need to know this early also
945 gDisableVoice = TRUE;
946 }
927 else if (!strcmp(argv[j], "-url") && (++j < argc)) 947 else if (!strcmp(argv[j], "-url") && (++j < argc))
928 { 948 {
929 LLURLSimString::setString(argv[j]); 949 LLURLSimString::setString(argv[j]);
@@ -1084,8 +1104,10 @@ int main( int argc, char **argv )
1084 // Initialize apple menubar and various callbacks 1104 // Initialize apple menubar and various callbacks
1085 init_apple_menu(gSecondLife.c_str()); 1105 init_apple_menu(gSecondLife.c_str());
1086 1106
1107#if __ppc__
1087 // If the CPU doesn't have Altivec (i.e. it's not at least a G4), don't go any further. 1108 // If the CPU doesn't have Altivec (i.e. it's not at least a G4), don't go any further.
1088 if(!gSysCPU.hasSSE()) 1109 // Only test PowerPC - all Intel Macs have SSE.
1110 if(!gSysCPU.hasAltivec())
1089 { 1111 {
1090 std::ostringstream msg; 1112 std::ostringstream msg;
1091 msg << gSecondLife << " requires a processor with AltiVec (G4 or later)."; 1113 msg << gSecondLife << " requires a processor with AltiVec (G4 or later).";
@@ -1096,6 +1118,7 @@ int main( int argc, char **argv )
1096 remove_marker_file(); 1118 remove_marker_file();
1097 return 1; 1119 return 1;
1098 } 1120 }
1121#endif
1099 1122
1100#endif // LL_DARWIN 1123#endif // LL_DARWIN
1101 1124
@@ -1218,10 +1241,14 @@ int main( int argc, char **argv )
1218 // XXX -- We need to exit fullscreen mode for this to work. 1241 // XXX -- We need to exit fullscreen mode for this to work.
1219 // XXX -- system() also doesn't wait for completion. Hmm... 1242 // XXX -- system() also doesn't wait for completion. Hmm...
1220 system(command_str.c_str()); /* Flawfinder: Ignore */ 1243 system(command_str.c_str()); /* Flawfinder: Ignore */
1221#elif LL_LINUX 1244#elif LL_LINUX || LL_SOLARIS
1222 std::string cmd =gDirUtilp->getAppRODataDir(); 1245 std::string cmd =gDirUtilp->getAppRODataDir();
1223 cmd += gDirUtilp->getDirDelimiter(); 1246 cmd += gDirUtilp->getDirDelimiter();
1247#if LL_LINUX
1224 cmd += "linux-crash-logger.bin"; 1248 cmd += "linux-crash-logger.bin";
1249#else // LL_SOLARIS
1250 cmd += "bin/solaris-crash-logger";
1251#endif
1225 char* const cmdargv[] = 1252 char* const cmdargv[] =
1226 {(char*)cmd.c_str(), 1253 {(char*)cmd.c_str(),
1227 (char*)"-previous", 1254 (char*)"-previous",
@@ -1259,17 +1286,18 @@ int main( int argc, char **argv )
1259 { 1286 {
1260 gSecondInstance = another_instance_running(); 1287 gSecondInstance = another_instance_running();
1261 1288
1262 /* Don't start another instance if using -multiple
1263 if (gSecondInstance) 1289 if (gSecondInstance)
1264 { 1290 {
1291 gDisableVoice = TRUE;
1292 /* Don't start another instance if using -multiple
1265 //RN: if we received a URL, hand it off to the existing instance 1293 //RN: if we received a URL, hand it off to the existing instance
1266 if (LLURLSimString::parse()) 1294 if (LLURLSimString::parse())
1267 { 1295 {
1268 LLURLSimString::send_to_other_instance(); 1296 LLURLSimString::send_to_other_instance();
1269 return 1; 1297 return 1;
1270 } 1298 }
1299 */
1271 } 1300 }
1272 */
1273 1301
1274 init_marker_file(); 1302 init_marker_file();
1275 } 1303 }
@@ -1377,22 +1405,20 @@ int main( int argc, char **argv )
1377 if (gUserServerChoice == USERSERVER_NONE) 1405 if (gUserServerChoice == USERSERVER_NONE)
1378 { 1406 {
1379 // Development version: load last server choice by default (overridden by cmd line args) 1407 // Development version: load last server choice by default (overridden by cmd line args)
1380 if (gSavedSettings.getBOOL("UseDebugLogin")) 1408
1409 S32 server = gSavedSettings.getS32("ServerChoice");
1410 if (server != 0)
1411 gUserServerChoice = (EUserServerDomain)llclamp(server, 0, (S32)USERSERVER_COUNT - 1);
1412 if (server == USERSERVER_OTHER)
1381 { 1413 {
1382 S32 server = gSavedSettings.getS32("ServerChoice"); 1414 LLString custom_server = gSavedSettings.getString("CustomServer");
1383 if (server != 0) 1415 if (custom_server.empty())
1384 gUserServerChoice = (EUserServerDomain)llclamp(server, 0, (S32)USERSERVER_COUNT - 1);
1385 if (server == USERSERVER_OTHER)
1386 { 1416 {
1387 LLString custom_server = gSavedSettings.getString("CustomServer"); 1417 snprintf(gUserServerName, MAX_STRING, "none"); /* Flawfinder: ignore */
1388 if (custom_server.empty()) 1418 }
1389 { 1419 else
1390 snprintf(gUserServerName, MAX_STRING, "none"); /* Flawfinder: ignore */ 1420 {
1391 } 1421 snprintf(gUserServerName, MAX_STRING, "%s", custom_server.c_str()); /* Flawfinder: ignore */
1392 else
1393 {
1394 snprintf(gUserServerName, MAX_STRING, "%s", custom_server.c_str()); /* Flawfinder: ignore */
1395 }
1396 } 1422 }
1397 } 1423 }
1398 } 1424 }
@@ -1785,7 +1811,10 @@ void check_for_events()
1785 1811
1786#include "moviemaker.h" 1812#include "moviemaker.h"
1787extern BOOL gbCapturing; 1813extern BOOL gbCapturing;
1814
1815#if !LL_SOLARIS
1788extern MovieMaker gMovieMaker; 1816extern MovieMaker gMovieMaker;
1817#endif
1789 1818
1790void main_loop() 1819void main_loop()
1791{ 1820{
@@ -1793,7 +1822,14 @@ void main_loop()
1793 gServicePump = new LLPumpIO(gAPRPoolp); 1822 gServicePump = new LLPumpIO(gAPRPoolp);
1794 LLHTTPClient::setPump(*gServicePump); 1823 LLHTTPClient::setPump(*gServicePump);
1795 LLHTTPClient::setCABundle(gDirUtilp->getCAFile()); 1824 LLHTTPClient::setCABundle(gDirUtilp->getCAFile());
1825
1826 // initialize voice stuff here
1827 gLocalSpeakerMgr = new LLLocalSpeakerMgr();
1828 gActiveChannelSpeakerMgr = new LLActiveSpeakerMgr();
1796 1829
1830 LLVoiceChannel::initClass();
1831 LLVoiceClient::init(gServicePump);
1832
1797 LLMemType mt1(LLMemType::MTYPE_MAIN); 1833 LLMemType mt1(LLMemType::MTYPE_MAIN);
1798 LLTimer frameTimer,idleTimer; 1834 LLTimer frameTimer,idleTimer;
1799 LLTimer debugTime; 1835 LLTimer debugTime;
@@ -1853,10 +1889,12 @@ void main_loop()
1853 1889
1854 LLFloaterSnapshot::update(); // take snapshots 1890 LLFloaterSnapshot::update(); // take snapshots
1855 1891
1892#if !LL_SOLARIS
1856 if (gbCapturing) 1893 if (gbCapturing)
1857 { 1894 {
1858 gMovieMaker.Snap(); 1895 gMovieMaker.Snap();
1859 } 1896 }
1897#endif
1860 } 1898 }
1861 1899
1862 } 1900 }
@@ -2023,6 +2061,12 @@ void remove_marker_file()
2023 2061
2024void init_marker_file() 2062void init_marker_file()
2025{ 2063{
2064#if LL_SOLARIS
2065 struct flock fl;
2066 fl.l_whence = SEEK_SET;
2067 fl.l_start = 0;
2068 fl.l_len = 1;
2069#endif
2026 // We create a marker file when the program starts and remove the file when it finishes. 2070 // We create a marker file when the program starts and remove the file when it finishes.
2027 // If the file is currently locked, that means another process is already running. 2071 // If the file is currently locked, that means another process is already running.
2028 // If the file exists and isn't locked, we crashed on the last run. 2072 // If the file exists and isn't locked, we crashed on the last run.
@@ -2069,7 +2113,12 @@ void init_marker_file()
2069 { 2113 {
2070 int fd = fileno(gMarkerFile); 2114 int fd = fileno(gMarkerFile);
2071 // Attempt to lock 2115 // Attempt to lock
2116#if LL_SOLARIS
2117 fl.l_type = F_WRLCK;
2118 if (fcntl(fd, F_SETLK, &fl) == -1)
2119#else
2072 if (flock(fd, LOCK_EX | LOCK_NB) == -1) 2120 if (flock(fd, LOCK_EX | LOCK_NB) == -1)
2121#endif
2073 { 2122 {
2074 llinfos << "Failed to lock file." << llendl; 2123 llinfos << "Failed to lock file." << llendl;
2075 } 2124 }
@@ -2121,12 +2170,12 @@ void init_logging()
2121 "SecondLife.old"); 2170 "SecondLife.old");
2122 LLFile::remove(old_log_file.c_str()); 2171 LLFile::remove(old_log_file.c_str());
2123 2172
2124#if LL_LINUX 2173#if LL_LINUX || LL_SOLARIS
2125 // Remove the last stack trace, if any 2174 // Remove the last stack trace, if any
2126 std::string old_stack_file = 2175 std::string old_stack_file =
2127 gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log"); 2176 gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log");
2128 LLFile::remove(old_stack_file.c_str()); 2177 LLFile::remove(old_stack_file.c_str());
2129#endif // LL_LINUX 2178#endif // LL_LINUX || LL_SOLARIS
2130 2179
2131 // Rename current log file to ".old" 2180 // Rename current log file to ".old"
2132 std::string log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, 2181 std::string log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,
@@ -2245,7 +2294,7 @@ std::string get_serial_number()
2245 } 2294 }
2246 return serial_md5; 2295 return serial_md5;
2247 2296
2248#elif LL_DARWIN 2297#elif LL_DARWIN
2249 // JC: Sample code from http://developer.apple.com/technotes/tn/tn1103.html 2298 // JC: Sample code from http://developer.apple.com/technotes/tn/tn1103.html
2250 CFStringRef serialNumber = NULL; 2299 CFStringRef serialNumber = NULL;
2251 io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, 2300 io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault,
@@ -2270,7 +2319,7 @@ std::string get_serial_number()
2270 2319
2271 return serial_md5; 2320 return serial_md5;
2272 2321
2273#elif LL_LINUX 2322#elif LL_LINUX || LL_SOLARIS
2274 // TODO 2323 // TODO
2275 return serial_md5; 2324 return serial_md5;
2276 2325
@@ -2481,6 +2530,29 @@ static inline bool being_debugged()
2481 return debugged == yes; 2530 return debugged == yes;
2482} 2531}
2483 2532
2533#ifdef LL_SOLARIS
2534static inline BOOL do_basic_glibc_backtrace()
2535{
2536 BOOL success = FALSE;
2537
2538 std::string strace_filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log");
2539 llinfos << "Opening stack trace file " << strace_filename << llendl;
2540 FILE* StraceFile = LLFile::fopen(strace_filename.c_str(), "w");
2541 if (!StraceFile)
2542 {
2543 llinfos << "Opening stack trace file " << strace_filename << " failed. Using stderr." << llendl;
2544 StraceFile = stderr;
2545 }
2546
2547 printstack(fileno(StraceFile));
2548
2549 if (StraceFile != stderr)
2550 fclose(StraceFile);
2551
2552 return success;
2553}
2554#endif // LL_SOLARIS
2555
2484void viewer_crash_callback() 2556void viewer_crash_callback()
2485{ 2557{
2486 // This will drop us into the debugger. 2558 // This will drop us into the debugger.
@@ -2575,7 +2647,7 @@ void viewer_crash_callback()
2575 // Sometimes signals don't seem to quit the viewer. 2647 // Sometimes signals don't seem to quit the viewer.
2576 // Make sure we exit so as to not totally confuse the user. 2648 // Make sure we exit so as to not totally confuse the user.
2577 exit(1); 2649 exit(1);
2578#elif LL_LINUX 2650#elif LL_LINUX || LL_SOLARIS
2579 // Always generate the report, have the logger do the asking, and 2651 // Always generate the report, have the logger do the asking, and
2580 // don't wait for the logger before exiting (-> total cleanup). 2652 // don't wait for the logger before exiting (-> total cleanup).
2581 if (CRASH_BEHAVIOR_NEVER_SEND != gCrashBehavior) 2653 if (CRASH_BEHAVIOR_NEVER_SEND != gCrashBehavior)
@@ -2895,6 +2967,7 @@ OSErr AEGURLHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn)
2895 LLURLSimString::sInstance.mX, 2967 LLURLSimString::sInstance.mX,
2896 LLURLSimString::sInstance.mY, 2968 LLURLSimString::sInstance.mY,
2897 LLURLSimString::sInstance.mZ); 2969 LLURLSimString::sInstance.mZ);
2970 LLFloaterWorldMap::show(NULL, TRUE);
2898 } 2971 }
2899 } 2972 }
2900 } 2973 }
@@ -3218,9 +3291,9 @@ void idle_shutdown()
3218 } 3291 }
3219 3292
3220 // close IM interface 3293 // close IM interface
3221 if(gIMView) 3294 if(gIMMgr)
3222 { 3295 {
3223 gIMView->disconnectAllSessions(); 3296 gIMMgr->disconnectAllSessions();
3224 } 3297 }
3225 3298
3226 // Wait for all floaters to get resolved 3299 // Wait for all floaters to get resolved
@@ -3933,78 +4006,22 @@ void idle()
3933 gObjectList.updateApparentAngles(gAgent); 4006 gObjectList.updateApparentAngles(gAgent);
3934 } 4007 }
3935 4008
3936 //////////////////////////////////////
3937 //
3938 // Audio stuff
3939 //
3940 //
3941
3942 if (gSavedSettings.getBOOL("MuteAudio"))
3943 { 4009 {
3944 LLMediaEngine::updateClass( 0.0f );
3945 }
3946 else
3947 {
3948 // only restore the volume if we're not minimized
3949 if ( ! gViewerWindow->mWindow->getMinimized() )
3950 LLMediaEngine::updateClass( gSavedSettings.getF32( "MediaAudioVolume" ) );
3951 };
3952
3953 if (gAudiop)
3954 {
3955 LLFastTimer t(LLFastTimer::FTM_AUDIO_UPDATE);
3956
3957 gFrameStats.start(LLFrameStats::AUDIO); 4010 gFrameStats.start(LLFrameStats::AUDIO);
3958 // update listener position because agent has moved 4011 LLFastTimer t(LLFastTimer::FTM_AUDIO_UPDATE);
3959
3960 LLVector3d lpos_global = gAgent.getCameraPositionGlobal();
3961 LLVector3 lpos_global_f;
3962 lpos_global_f.setVec(lpos_global);
3963
3964 gAudiop->setListener(lpos_global_f,
3965 // gCameraVelocitySmoothed,
3966 // LLVector3::zero,
3967 gAgent.getVelocity(), // !!! BUG need to replace this with smoothed velocity!
3968 gCamera->getUpAxis(),
3969 gCamera->getAtAxis());
3970 4012
3971 // this line rotates the wind vector to be listener (agent) relative 4013 audio_update_volume(false);
3972 // unfortunately we have to pre-translate to undo the translation that 4014 audio_update_listener();
3973 // occurs in the transform call 4015 audio_update_wind(false);
3974 gRelativeWindVec = gAgent.getFrameAgent().rotateToLocal(gWindVec - gAgent.getVelocity());
3975 4016
3976#ifdef kAUDIO_ENABLE_WIND 4017 if (gAudiop)
3977 //
3978 // Extract height above water to modulate filter by whether above/below water
3979 //
3980 static F32 last_camera_water_height = -1000.f;
3981 LLVector3 camera_pos = gAgent.getCameraPositionAgent();
3982 F32 camera_water_height = camera_pos.mV[VZ] - gAgent.getRegion()->getWaterHeight();
3983
3984 //
3985 // Don't update rolloff factor unless water surface has been crossed
3986 //
3987 if ((last_camera_water_height * camera_water_height) < 0.f)
3988 { 4018 {
3989 if (camera_water_height < 0.f) 4019 // this line actually commits the changes we've made to source positions, etc.
3990 { 4020 const F32 max_audio_decode_time = 0.002f; // 2 ms decode time
3991 gAudiop->setRolloffFactor(gSavedSettings.getF32("AudioLevelRolloff") * LL_ROLLOFF_MULTIPLIER_UNDER_WATER); 4021 gAudiop->idle(max_audio_decode_time);
3992 }
3993 else
3994 {
3995 gAudiop->setRolloffFactor(gSavedSettings.getF32("AudioLevelRolloff"));
3996 }
3997 } 4022 }
3998 last_camera_water_height = camera_water_height;
3999 gAudiop->updateWind(gRelativeWindVec, camera_water_height);
4000#endif
4001
4002
4003 // this line actually commits the changes we've made to source positions, etc.
4004 const F32 max_audio_decode_time = 0.002f; // 2 ms decode time
4005 gAudiop->idle(max_audio_decode_time);
4006 } 4023 }
4007 4024
4008 // Handle shutdown process, for example, 4025 // Handle shutdown process, for example,
4009 // wait for floaters to close, send quit message, 4026 // wait for floaters to close, send quit message,
4010 // forcibly quit if it has taken too long 4027 // forcibly quit if it has taken too long
@@ -4031,35 +4048,6 @@ F32 mouse_y_from_center(S32 y)
4031 4048
4032///////////////////////////////////////////////////////// 4049/////////////////////////////////////////////////////////
4033 4050
4034class AudioSettingsListener: public LLSimpleListener
4035{
4036 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4037 {
4038 // Note: Ignore the specific event value, look up the ones we want
4039 if (!gAudiop) return true;
4040 gAudiop->setDopplerFactor(gSavedSettings.getF32("AudioLevelDoppler"));
4041 gAudiop->setDistanceFactor(gSavedSettings.getF32("AudioLevelDistance"));
4042#ifdef kAUDIO_ENABLE_WIND
4043 // Wind Gain
4044 gAudiop->mMaxWindGain = gSavedSettings.getF32("AudioLevelWind");
4045 // Rolloff
4046 LLVector3 camera_pos = gAgent.getCameraPositionAgent();
4047 LLViewerRegion* region = gAgent.getRegion();
4048 F32 camera_water_height = region ? camera_pos.mV[VZ] - region->getWaterHeight() : 0.f;
4049 if (camera_water_height < 0.f)
4050 {
4051 gAudiop->setRolloffFactor(gSavedSettings.getF32("AudioLevelRolloff") * LL_ROLLOFF_MULTIPLIER_UNDER_WATER);
4052 }
4053 else
4054 {
4055 gAudiop->setRolloffFactor(gSavedSettings.getF32("AudioLevelRolloff"));
4056 }
4057#endif
4058 return true;
4059 }
4060};
4061static AudioSettingsListener audio_settings_listener;
4062
4063void init_audio() 4051void init_audio()
4064{ 4052{
4065 if (!gAudiop) 4053 if (!gAudiop)
@@ -4125,24 +4113,133 @@ void init_audio()
4125 gAudiop->preloadSound(LLUUID(gSavedSettings.getString("UISndWindowOpen"))); 4113 gAudiop->preloadSound(LLUUID(gSavedSettings.getString("UISndWindowOpen")));
4126 } 4114 }
4127 4115
4116 audio_update_volume(true);
4117}
4118
4119void audio_update_volume(bool force_update)
4120{
4121 F32 master_volume = gSavedSettings.getF32("AudioLevelMaster");
4122 BOOL mute_audio = gSavedSettings.getBOOL("MuteAudio");
4123 if (!gViewerWindow->getActive() && (gSavedSettings.getBOOL("MuteWhenMinimized")))
4124 {
4125 mute_audio = TRUE;
4126 }
4127 F32 mute_volume = mute_audio ? 0.0f : 1.0f;
4128
4129 // Sound Effects
4130 if (gAudiop)
4131 {
4132 gAudiop->setMasterGain ( master_volume );
4133
4134 gAudiop->setDopplerFactor(gSavedSettings.getF32("AudioLevelDoppler"));
4135 gAudiop->setDistanceFactor(gSavedSettings.getF32("AudioLevelDistance"));
4136 gAudiop->setRolloffFactor(gSavedSettings.getF32("AudioLevelRolloff"));
4128#ifdef kAUDIO_ENABLE_WIND 4137#ifdef kAUDIO_ENABLE_WIND
4129 gAudiop->enableWind(!mute_audio); 4138 gAudiop->enableWind(!mute_audio);
4130 gAudiop->mMaxWindGain = gSavedSettings.getF32("AudioLevelWind");
4131 gSavedSettings.getControl("AudioLevelWind")->addListener(&audio_settings_listener);
4132 gSavedSettings.getControl("AudioLevelRolloff")->addListener(&audio_settings_listener);
4133 // don't use the setter setMaxWindGain() because we don't
4134 // want to screw up the fade-in on startup by setting actual source gain
4135 // outside the fade-in.
4136#endif 4139#endif
4137 4140
4138 gAudiop->setMasterGain ( gSavedSettings.getF32 ( "AudioLevelMaster" ) ); 4141 gAudiop->setMuted(mute_audio);
4142
4143 if (force_update)
4144 {
4145 audio_update_wind(true);
4146 }
4147 }
4148
4149 // Streaming Music
4150 if (gAudiop)
4151 {
4152 F32 music_volume = gSavedSettings.getF32("AudioLevelMusic");
4153 music_volume = mute_volume * master_volume * (music_volume*music_volume);
4154 gAudiop->setInternetStreamGain ( music_volume );
4155 }
4156
4157 // Streaming Media
4158 if(LLMediaEngine::getInstance())
4159 {
4160 F32 media_volume = gSavedSettings.getF32("AudioLevelMedia");
4161 media_volume = mute_volume * master_volume * (media_volume*media_volume);
4162 LLMediaEngine::getInstance()->setVolume(media_volume);
4163 }
4164
4165 // Voice
4166 if (gVoiceClient)
4167 {
4168 F32 voice_volume = gSavedSettings.getF32("AudioLevelVoice");
4169 voice_volume = mute_volume * master_volume * voice_volume;
4170 gVoiceClient->setVoiceVolume(voice_volume);
4171 gVoiceClient->setMicGain(gSavedSettings.getF32("AudioLevelMic"));
4172
4173 if (!gViewerWindow->getActive() && (gSavedSettings.getBOOL("MuteWhenMinimized")))
4174 {
4175 gVoiceClient->setMuteMic(true);
4176 }
4177 else
4178 {
4179 gVoiceClient->setMuteMic(false);
4180 }
4181 }
4182}
4183
4184void audio_update_listener()
4185{
4186 if (gAudiop)
4187 {
4188 // update listener position because agent has moved
4189 LLVector3d lpos_global = gAgent.getCameraPositionGlobal();
4190 LLVector3 lpos_global_f;
4191 lpos_global_f.setVec(lpos_global);
4192
4193 gAudiop->setListener(lpos_global_f,
4194 // gCameraVelocitySmoothed,
4195 // LLVector3::zero,
4196 gAgent.getVelocity(), // !!! *TODO: need to replace this with smoothed velocity!
4197 gCamera->getUpAxis(),
4198 gCamera->getAtAxis());
4199 }
4200}
4201
4202void audio_update_wind(bool force_update)
4203{
4204#ifdef kAUDIO_ENABLE_WIND
4205 //
4206 // Extract height above water to modulate filter by whether above/below water
4207 //
4208 LLViewerRegion* region = gAgent.getRegion();
4209 if (region)
4210 {
4211 static F32 last_camera_water_height = -1000.f;
4212 LLVector3 camera_pos = gAgent.getCameraPositionAgent();
4213 F32 camera_water_height = camera_pos.mV[VZ] - region->getWaterHeight();
4214
4215 //
4216 // Don't update rolloff factor unless water surface has been crossed
4217 //
4218 if (force_update || (last_camera_water_height * camera_water_height) < 0.f)
4219 {
4220 if (camera_water_height < 0.f)
4221 {
4222 gAudiop->setRolloffFactor(gSavedSettings.getF32("AudioLevelRolloff") * LL_ROLLOFF_MULTIPLIER_UNDER_WATER);
4223 }
4224 else
4225 {
4226 gAudiop->setRolloffFactor(gSavedSettings.getF32("AudioLevelRolloff"));
4227 }
4228 }
4229 // this line rotates the wind vector to be listener (agent) relative
4230 // unfortunately we have to pre-translate to undo the translation that
4231 // occurs in the transform call
4232 gRelativeWindVec = gAgent.getFrameAgent().rotateToLocal(gWindVec - gAgent.getVelocity());
4139 4233
4140 gAudiop->setDopplerFactor(gSavedSettings.getF32("AudioLevelDoppler")); 4234 // don't use the setter setMaxWindGain() because we don't
4141 gSavedSettings.getControl("AudioLevelDoppler")->addListener(&audio_settings_listener); 4235 // want to screw up the fade-in on startup by setting actual source gain
4142 gAudiop->setDistanceFactor(gSavedSettings.getF32("AudioLevelDistance")); 4236 // outside the fade-in.
4143 gSavedSettings.getControl("AudioLevelDistance")->addListener(&audio_settings_listener); 4237 gAudiop->mMaxWindGain = gSavedSettings.getF32("AudioLevelAmbient");
4144 gAudiop->setRolloffFactor(gSavedSettings.getF32("AudioLevelRolloff")); 4238
4145 gAudiop->setMuted(mute_audio); 4239 last_camera_water_height = camera_water_height;
4240 gAudiop->updateWind(gRelativeWindVec, camera_water_height);
4241 }
4242#endif
4146} 4243}
4147 4244
4148 4245
@@ -4291,7 +4388,8 @@ BOOL add_object( LLPCode pcode, S32 x, S32 y, U8 use_physics )
4291 // Play creation sound 4388 // Play creation sound
4292 if (gAudiop) 4389 if (gAudiop)
4293 { 4390 {
4294 gAudiop->triggerSound( LLUUID(gSavedSettings.getString("UISndObjectCreate")), gAgent.getID(), 1.f); 4391 F32 volume = gSavedSettings.getF32("AudioLevelUI");
4392 gAudiop->triggerSound( LLUUID(gSavedSettings.getString("UISndObjectCreate")), gAgent.getID(), volume);
4295 } 4393 }
4296 4394
4297 gMessageSystem->newMessageFast(_PREHASH_ObjectAdd); 4395 gMessageSystem->newMessageFast(_PREHASH_ObjectAdd);
@@ -4547,422 +4645,89 @@ void create_console()
4547} 4645}
4548#endif 4646#endif
4549 4647
4550class LLAFKTimeoutListener: public LLSimpleListener
4551{
4552 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4553 {
4554 gAFKTimeout = (F32) event->getValue().asReal();
4555 return true;
4556 }
4557};
4558static LLAFKTimeoutListener afk_timeout_listener;
4559
4560class LLMouseSensitivityListener: public LLSimpleListener
4561{
4562 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4563 {
4564 gMouseSensitivity = (F32) event->getValue().asReal();
4565 return true;
4566 }
4567};
4568static LLMouseSensitivityListener mouse_sensitivity_listener;
4569
4570
4571class LLInvertMouseListener: public LLSimpleListener
4572{
4573 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4574 {
4575 gInvertMouse = event->getValue().asBoolean();
4576 return true;
4577 }
4578};
4579static LLInvertMouseListener invert_mouse_listener;
4580
4581class LLRenderAvatarMouselookListener: public LLSimpleListener
4582{
4583 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4584 {
4585 LLVOAvatar::sVisibleInFirstPerson = event->getValue().asBoolean();
4586 return true;
4587 }
4588};
4589static LLRenderAvatarMouselookListener render_avatar_mouselook_listener;
4590
4591class LLRenderFarClipListener: public LLSimpleListener
4592{
4593 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4594 {
4595 F32 draw_distance = (F32) event->getValue().asReal();
4596 gAgent.mDrawDistance = draw_distance;
4597 if (gWorldPointer)
4598 {
4599 gWorldPointer->setLandFarClip(draw_distance);
4600 }
4601 return true;
4602 }
4603};
4604static LLRenderFarClipListener render_far_clip_listener;
4605
4606class LLTerrainDetailListener: public LLSimpleListener
4607{
4608 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4609 {
4610 LLDrawPoolTerrain::sDetailMode = event->getValue().asInteger();
4611 return true;
4612 }
4613};
4614static LLTerrainDetailListener terrain_detail_listener;
4615
4616
4617class LLSetShaderListener: public LLSimpleListener
4618{
4619 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4620 {
4621 LLShaderMgr::setShaders();
4622 return true;
4623 }
4624};
4625static LLSetShaderListener set_shader_listener;
4626
4627class LLReleaseGLBufferListener: public LLSimpleListener
4628{
4629 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4630 {
4631 gPipeline.releaseGLBuffers();
4632 LLShaderMgr::setShaders();
4633 return true;
4634 }
4635};
4636static LLReleaseGLBufferListener release_gl_buffer_listener;
4637 4648
4638class LLVolumeLODListener: public LLSimpleListener
4639{
4640 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4641 {
4642 LLVOVolume::sLODFactor = (F32) event->getValue().asReal();
4643 LLVOVolume::sDistanceFactor = 1.f-LLVOVolume::sLODFactor * 0.1f;
4644 return true;
4645 }
4646};
4647static LLVolumeLODListener volume_lod_listener;
4648 4649
4649class LLAvatarLODListener: public LLSimpleListener 4650//-------------------------------------------------------------------
4650{ 4651//-------------------------------------------------------------------
4651 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 4652// Vector Performance Options
4652 { 4653//-------------------------------------------------------------------
4653 LLVOAvatar::sLODFactor = (F32) event->getValue().asReal(); 4654//-------------------------------------------------------------------
4654 return true;
4655 }
4656};
4657static LLAvatarLODListener avatar_lod_listener;
4658 4655
4659class LLTreeLODListener: public LLSimpleListener 4656// Initially, we test the performance of the vectorization code, then
4660{ 4657// turn it off if it ends up being slower. JC
4661 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 4658BOOL gVectorizePerfTest = TRUE;
4662 { 4659BOOL gVectorizeEnable = FALSE;
4663 LLVOTree::sTreeFactor = (F32) event->getValue().asReal(); 4660U32 gVectorizeProcessor = 0;
4664 return true; 4661BOOL gVectorizeSkin = FALSE;
4665 }
4666};
4667static LLTreeLODListener tree_lod_listener;
4668 4662
4669class LLFlexLODListener: public LLSimpleListener 4663void update_vector_performances(void)
4670{ 4664{
4671 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 4665 char *vp;
4672 { 4666
4673 LLVolumeImplFlexible::sUpdateFactor = (F32) event->getValue().asReal(); 4667 switch(gVectorizeProcessor)
4674 return true;
4675 }
4676};
4677static LLFlexLODListener flex_lod_listener;
4678
4679class LLGammaListener: public LLSimpleListener
4680{
4681 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4682 {
4683 F32 gamma = (F32) event->getValue().asReal();
4684 if (gamma == 0.0f)
4685 {
4686 gamma = 1.0f; // restore normal gamma
4687 }
4688 if (gamma != gViewerWindow->getWindow()->getGamma())
4689 {
4690 // Only save it if it's changed
4691 if (!gViewerWindow->getWindow()->setGamma(gamma))
4692 {
4693 llwarns << "setGamma failed!" << llendl;
4694 }
4695 }
4696
4697 return true;
4698 }
4699};
4700static LLGammaListener gamma_listener;
4701
4702class LLNightBrightnessListener: public LLSimpleListener
4703{
4704 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4705 {
4706 LLVOSky::sNighttimeBrightness = (F32) event->getValue().asReal();
4707 return true;
4708 }
4709};
4710static LLNightBrightnessListener night_brightness_listener;
4711
4712class LLFogRatioListener: public LLSimpleListener
4713{
4714 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4715 {
4716 F32 fog_ratio = llmax(MIN_USER_FOG_RATIO,
4717 llmin((F32) event->getValue().asReal(),
4718 MAX_USER_FOG_RATIO));
4719 gSky.setFogRatio(fog_ratio);
4720 return true;
4721 }
4722};
4723static LLFogRatioListener fog_ratio_listener;
4724
4725class LLMaxPartCountListener: public LLSimpleListener
4726{
4727 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4728 {
4729 LLViewerPartSim::setMaxPartCount(event->getValue().asInteger());
4730 return true;
4731 }
4732};
4733static LLMaxPartCountListener max_partCount_listener;
4734
4735class LLCompositeLimitListener: public LLSimpleListener
4736{
4737 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4738 {
4739 S32 composite_limit = llmax(MIN_USER_COMPOSITE_LIMIT,
4740 llmin((S32)event->getValue().asInteger(),
4741 MAX_USER_COMPOSITE_LIMIT));
4742 LLVOAvatar::sMaxOtherAvatarsToComposite = composite_limit;
4743 return true;
4744 }
4745};
4746static LLCompositeLimitListener composite_limit_listener;
4747
4748class LLVideoMemoryListener: public LLSimpleListener
4749{
4750 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4751 {
4752 gImageList.updateMaxResidentTexMem(event->getValue().asInteger());
4753 return true;
4754 }
4755};
4756static LLVideoMemoryListener video_memory_listener;
4757
4758class LLBandwidthListener: public LLSimpleListener
4759{
4760 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4761 {
4762 gViewerThrottle.setMaxBandwidth((F32) event->getValue().asReal());
4763 return true;
4764 }
4765};
4766static LLBandwidthListener bandwidth_listener;
4767
4768class LLChatFontSizeListener: public LLSimpleListener
4769{
4770 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4771 {
4772 gConsole->setFontSize(event->getValue().asInteger());
4773 return true;
4774 }
4775};
4776static LLChatFontSizeListener chat_font_size_listener;
4777
4778class LLChatPersistTimeListener: public LLSimpleListener
4779{
4780 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4781 {
4782 gConsole->setLinePersistTime((F32) event->getValue().asReal());
4783 return true;
4784 }
4785};
4786static LLChatPersistTimeListener chat_persist_time_listener;
4787
4788class LLConsoleMaxLinesListener: public LLSimpleListener
4789{
4790 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4791 {
4792 gConsole->setMaxLines(event->getValue().asInteger());
4793 return true;
4794 }
4795};
4796static LLConsoleMaxLinesListener console_max_lines_listener;
4797
4798
4799class LLMasterAudioListener: public LLSimpleListener
4800{
4801 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4802 {
4803 if(gAudiop)
4804 {
4805 gAudiop->setMasterGain ((F32) event->getValue().asReal() );
4806 }
4807
4808 if (LLMediaEngine::getInstance ()->isAvailable())
4809 {
4810 LLMediaEngine::getInstance ()->setVolume ((F32) event->getValue().asReal() );
4811 }
4812
4813 return true;
4814 }
4815};
4816
4817class LLJoystickListener : public LLSimpleListener
4818{
4819 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4820 {
4821 LLViewerJoystick::updateCamera(TRUE);
4822 return true;
4823 }
4824};
4825static LLJoystickListener joystick_listener;
4826
4827void stop_video();
4828void prepare_video(const LLParcel *parcel);
4829
4830static LLMasterAudioListener master_audio_listener;
4831
4832
4833class LLAudioStreamMusicListener: public LLSimpleListener
4834{
4835 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4836 { 4668 {
4837 if (gAudiop) 4669 case 2: vp = "SSE2"; break; // *TODO: replace the magic #s
4838 { 4670 case 1: vp = "SSE"; break;
4839 if ( event->getValue().asBoolean() ) 4671 default: vp = "COMPILER DEFAULT"; break;
4840 {
4841 if (gParcelMgr
4842 && gParcelMgr->getAgentParcel()
4843 && gParcelMgr->getAgentParcel()->getMusicURL())
4844 {
4845 // if stream is already playing, don't call this
4846 // otherwise music will briefly stop
4847 if ( ! gAudiop->isInternetStreamPlaying () )
4848 {
4849 gAudiop->startInternetStream(
4850 gParcelMgr->getAgentParcel()->getMusicURL());
4851 }
4852 }
4853 }
4854 else
4855 {
4856 gAudiop->stopInternetStream();
4857 }
4858 }
4859 return true;
4860 } 4672 }
4861}; 4673 llinfos << "Vectorization : " << ( gVectorizeEnable ? "ENABLED" : "DISABLED" ) << llendl ;
4862 4674 llinfos << "Vector Processor : " << vp << llendl ;
4863static LLAudioStreamMusicListener audio_stream_music_listener; 4675 llinfos << "Vectorized Skinning : " << ( gVectorizeSkin ? "ENABLED" : "DISABLED" ) << llendl ;
4864 4676
4865 4677 if(gVectorizeEnable && gVectorizeSkin)
4866
4867class LLAudioStreamMediaListener: public LLSimpleListener
4868{
4869 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4870 { 4678 {
4871 if (LLMediaEngine::getInstance() && LLMediaEngine::getInstance()->isAvailable()) 4679 switch(gVectorizeProcessor)
4872 { 4680 {
4873 if (event->getValue().asBoolean()) 4681 case 2:
4874 { 4682 LLViewerJointMesh::sUpdateGeometryFunc = &LLViewerJointMesh::updateGeometrySSE2;
4875 gMessageSystem->setHandlerFunc ( "ParcelMediaCommandMessage", LLMediaEngine::process_parcel_media ); 4683 break;
4876 gMessageSystem->setHandlerFunc ( "ParcelMediaUpdate", LLMediaEngine::process_parcel_media_update ); 4684 case 1:
4877 if ( ( gParcelMgr ) && 4685 LLViewerJointMesh::sUpdateGeometryFunc = &LLViewerJointMesh::updateGeometrySSE;
4878 ( gParcelMgr->getAgentParcel () ) && 4686 break;
4879 ( gParcelMgr->getAgentParcel()->getMediaURL () ) ) 4687 default:
4880 { 4688 LLViewerJointMesh::sUpdateGeometryFunc = &LLViewerJointMesh::updateGeometryVectorized;
4881 prepare_video ( gParcelMgr->getAgentParcel () ); 4689 break;
4882 }
4883 }
4884 else
4885 {
4886 gMessageSystem->setHandlerFunc("ParcelMediaCommandMessage", null_message_callback);
4887 gMessageSystem->setHandlerFunc ( "ParcelMediaUpdate", null_message_callback );
4888 stop_video();
4889 }
4890 }
4891 else
4892 {
4893 if (gSavedSettings.getWarning("QuickTimeInstalled"))
4894 {
4895 gSavedSettings.setWarning("QuickTimeInstalled", FALSE);
4896
4897 LLNotifyBox::showXml("NoQuickTime" );
4898 }
4899 } 4690 }
4900
4901 return true;
4902 } 4691 }
4903}; 4692 else
4904
4905static LLAudioStreamMediaListener audio_stream_media_listener;
4906
4907
4908class LLAudioMuteListener: public LLSimpleListener
4909{
4910 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4911 { 4693 {
4912 if (gAudiop) 4694 LLViewerJointMesh::sUpdateGeometryFunc = &LLViewerJointMesh::updateGeometryOriginal;
4913 {
4914 gAudiop->setMuted(event->getValue().asBoolean());
4915 }
4916 return true;
4917 } 4695 }
4918}; 4696}
4919
4920static LLAudioMuteListener audio_mute_listener;
4921 4697
4922class LLUseOcclusionListener: public LLSimpleListener
4923{
4924 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4925 {
4926 LLPipeline::sUseOcclusion = (event->getValue().asBoolean() && gGLManager.mHasOcclusionQuery &&
4927 !gUseWireframe);
4928 return true;
4929 }
4930};
4931static LLUseOcclusionListener use_occlusion_listener;
4932 4698
4933class LLNumpadControlListener: public LLSimpleListener 4699class LLVectorizationEnableListener: public LLSimpleListener
4934{ 4700{
4935 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 4701 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4936 { 4702 {
4937 if (gKeyboard) 4703 gVectorizeEnable = event->getValue().asBoolean();
4938 { 4704 update_vector_performances();
4939 gKeyboard->setNumpadDistinct(static_cast<LLKeyboard::e_numpad_distinct>(event->getValue().asInteger()));
4940 }
4941 return true; 4705 return true;
4942 } 4706 }
4943}; 4707};
4708static LLVectorizationEnableListener vectorization_enable_listener;
4944 4709
4945static LLNumpadControlListener numpad_control_listener; 4710class LLVectorizeSkinListener: public LLSimpleListener
4946
4947class LLRenderUseVBOListener: public LLSimpleListener
4948{ 4711{
4949 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 4712 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4950 { 4713 {
4951 gPipeline.setUseVBO(event->getValue().asBoolean()); 4714 gVectorizeSkin = event->getValue().asBoolean();
4715 update_vector_performances();
4952 return true; 4716 return true;
4953 } 4717 }
4954}; 4718};
4955static LLRenderUseVBOListener render_use_vbo_listener; 4719static LLVectorizeSkinListener vectorize_skin_listener;
4956 4720
4957class LLRenderLightingDetailListener: public LLSimpleListener 4721class LLVectorProcessorListener: public LLSimpleListener
4958{ 4722{
4959 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 4723 bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
4960 { 4724 {
4961 gPipeline.setLightingDetail(event->getValue().asInteger()); 4725 gVectorizeProcessor = event->getValue().asInteger();
4726 update_vector_performances();
4962 return true; 4727 return true;
4963 } 4728 }
4964}; 4729};
4965static LLRenderLightingDetailListener render_lighting_detail_listener; 4730static LLVectorProcessorListener vector_processor_listener;
4966 4731
4967// Use these strictly for things that are constructed at startup, 4732// Use these strictly for things that are constructed at startup,
4968// or for things that are performance critical. JC 4733// or for things that are performance critical. JC
@@ -5015,53 +4780,59 @@ void saved_settings_to_globals()
5015 gHandleKeysAsync = gSavedSettings.getBOOL("AsyncKeyboard"); 4780 gHandleKeysAsync = gSavedSettings.getBOOL("AsyncKeyboard");
5016 LLHoverView::sShowHoverTips = gSavedSettings.getBOOL("ShowHoverTips"); 4781 LLHoverView::sShowHoverTips = gSavedSettings.getBOOL("ShowHoverTips");
5017 4782
4783#if LL_VECTORIZE
4784 if (gSysCPU.hasAltivec())
4785 {
4786 gSavedSettings.setBOOL("VectorizeEnable", TRUE );
4787 gSavedSettings.setU32("VectorizeProcessor", 0 );
4788 }
4789 else
4790 if (gSysCPU.hasSSE2())
4791 {
4792 gSavedSettings.setBOOL("VectorizeEnable", TRUE );
4793 gSavedSettings.setU32("VectorizeProcessor", 2 );
4794 }
4795 else
4796 if (gSysCPU.hasSSE())
4797 {
4798 gSavedSettings.setBOOL("VectorizeEnable", TRUE );
4799 gSavedSettings.setU32("VectorizeProcessor", 1 );
4800 }
4801 else
4802 {
4803 // Don't bother testing or running if CPU doesn't support it. JC
4804 gSavedSettings.setBOOL("VectorizePerfTest", FALSE );
4805 gSavedSettings.setBOOL("VectorizeEnable", FALSE );
4806 gSavedSettings.setU32("VectorizeProcessor", 0 );
4807 gSavedSettings.setBOOL("VectorizeSkin", FALSE);
4808 }
4809#else
4810 // This build target doesn't support SSE, don't test/run.
4811 gSavedSettings.setBOOL("VectorizePerfTest", FALSE );
4812 gSavedSettings.setBOOL("VectorizeEnable", FALSE );
4813 gSavedSettings.setU32("VectorizeProcessor", 0 );
4814 gSavedSettings.setBOOL("VectorizeSkin", FALSE);
4815#endif
4816
4817 gVectorizePerfTest = gSavedSettings.getBOOL("VectorizePerfTest");
4818 gVectorizeEnable = gSavedSettings.getBOOL("VectorizeEnable");
4819 gVectorizeProcessor = gSavedSettings.getU32("VectorizeProcessor");
4820 gVectorizeSkin = gSavedSettings.getBOOL("VectorizeSkin");
4821 update_vector_performances();
4822
5018 // Into a global in case we corrupt the list on crash. 4823 // Into a global in case we corrupt the list on crash.
5019 gCrashBehavior = gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING); 4824 gCrashBehavior = gCrashSettings.getS32(CRASH_BEHAVIOR_SETTING);
5020 4825
5021 //various listeners 4826 // propagate push to talk preference to current status
5022 gSavedSettings.getControl("FirstPersonAvatarVisible")->addListener(&render_avatar_mouselook_listener); 4827 gSavedSettings.setBOOL("PTTCurrentlyEnabled", gSavedSettings.getBOOL("EnablePushToTalk"));
5023 gSavedSettings.getControl("MouseSensitivity")->addListener(&mouse_sensitivity_listener); 4828
5024 gSavedSettings.getControl("InvertMouse")->addListener(&invert_mouse_listener); 4829 settings_setup_listeners();
5025 gSavedSettings.getControl("AFKTimeout")->addListener(&afk_timeout_listener);
5026 gSavedSettings.getControl("RenderFarClip")->addListener(&render_far_clip_listener);
5027 gSavedSettings.getControl("RenderTerrainDetail")->addListener(&terrain_detail_listener);
5028 gSavedSettings.getControl("RenderRippleWater")->addListener(&set_shader_listener);
5029 gSavedSettings.getControl("RenderAvatarVP")->addListener(&set_shader_listener);
5030 gSavedSettings.getControl("VertexShaderEnable")->addListener(&set_shader_listener);
5031 gSavedSettings.getControl("RenderDynamicReflections")->addListener(&set_shader_listener);
5032 gSavedSettings.getControl("RenderGlow")->addListener(&release_gl_buffer_listener);
5033 gSavedSettings.getControl("RenderGlowResolution")->addListener(&release_gl_buffer_listener);
5034 gSavedSettings.getControl("RenderAvatarMode")->addListener(&set_shader_listener);
5035 gSavedSettings.getControl("RenderVolumeLODFactor")->addListener(&volume_lod_listener);
5036 gSavedSettings.getControl("RenderAvatarLODFactor")->addListener(&avatar_lod_listener);
5037 gSavedSettings.getControl("RenderTreeLODFactor")->addListener(&tree_lod_listener);
5038 gSavedSettings.getControl("RenderFlexTimeFactor")->addListener(&flex_lod_listener);
5039 gSavedSettings.getControl("ThrottleBandwidthKBPS")->addListener(&bandwidth_listener);
5040 gSavedSettings.getControl("RenderGamma")->addListener(&gamma_listener);
5041 gSavedSettings.getControl("RenderNightBrightness")->addListener(&night_brightness_listener);
5042 gSavedSettings.getControl("RenderFogRatio")->addListener(&fog_ratio_listener);
5043 gSavedSettings.getControl("RenderMaxPartCount")->addListener(&max_partCount_listener);
5044 gSavedSettings.getControl("AvatarCompositeLimit")->addListener(&composite_limit_listener);
5045 gSavedSettings.getControl("GraphicsCardMemorySetting")->addListener(&video_memory_listener);
5046 gSavedSettings.getControl("ChatFontSize")->addListener(&chat_font_size_listener);
5047 gSavedSettings.getControl("ChatPersistTime")->addListener(&chat_persist_time_listener);
5048 gSavedSettings.getControl("ConsoleMaxLines")->addListener(&console_max_lines_listener);
5049 gSavedSettings.getControl("UseOcclusion")->addListener(&use_occlusion_listener);
5050 gSavedSettings.getControl("AudioLevelMaster")->addListener(&master_audio_listener);
5051 gSavedSettings.getControl("AudioStreamingMusic")->addListener(&audio_stream_music_listener);
5052 gSavedSettings.getControl("AudioStreamingVideo")->addListener(&audio_stream_media_listener);
5053 gSavedSettings.getControl("MuteAudio")->addListener(&audio_mute_listener);
5054 gSavedSettings.getControl("RenderVBOEnable")->addListener(&render_use_vbo_listener);
5055 gSavedSettings.getControl("RenderLightingDetail")->addListener(&render_lighting_detail_listener);
5056 gSavedSettings.getControl("NumpadControl")->addListener(&numpad_control_listener);
5057 gSavedSettings.getControl("FlycamAxis0")->addListener(&joystick_listener);
5058 gSavedSettings.getControl("FlycamAxis1")->addListener(&joystick_listener);
5059 gSavedSettings.getControl("FlycamAxis2")->addListener(&joystick_listener);
5060 gSavedSettings.getControl("FlycamAxis3")->addListener(&joystick_listener);
5061 gSavedSettings.getControl("FlycamAxis4")->addListener(&joystick_listener);
5062 gSavedSettings.getControl("FlycamAxis5")->addListener(&joystick_listener);
5063 gSavedSettings.getControl("FlycamAxis6")->addListener(&joystick_listener);
5064 4830
4831 // these are currently static in this file, so they can't move to settings_setup_listeners
4832 gSavedSettings.getControl("VectorizeEnable")->addListener(&vectorization_enable_listener);
4833 gSavedSettings.getControl("VectorizeProcessor")->addListener(&vector_processor_listener);
4834 gSavedSettings.getControl("VectorizeSkin")->addListener(&vectorize_skin_listener);
4835
5065 // gAgent.init() also loads from saved settings. 4836 // gAgent.init() also loads from saved settings.
5066} 4837}
5067 4838
@@ -5491,7 +5262,7 @@ void signal_handlers(S32 s)
5491 return; 5262 return;
5492 } 5263 }
5493 5264
5494# if LL_LINUX 5265# if LL_LINUX || LL_SOLARIS
5495 // Really useful to know what KIND of crash we got. 5266 // Really useful to know what KIND of crash we got.
5496 // Might want this on OSX too! 5267 // Might want this on OSX too!
5497 llwarns << "*** Caught signal " << s << llendl; 5268 llwarns << "*** Caught signal " << s << llendl;
@@ -5532,7 +5303,7 @@ void catch_signals()
5532 signal(SIGSYS, signal_handlers); 5303 signal(SIGSYS, signal_handlers);
5533 5304
5534 // SIGEMT is an 'emulator trap' which is not defined on linux. 5305 // SIGEMT is an 'emulator trap' which is not defined on linux.
5535#if !LL_LINUX 5306#if !LL_LINUX && !LL_SOLARIS
5536 signal(SIGEMT, signal_handlers); 5307 signal(SIGEMT, signal_handlers);
5537#endif 5308#endif
5538 5309
@@ -5847,6 +5618,10 @@ int parse_args(int argc, char **argv)
5847 { 5618 {
5848 gMultipleViewersOK = FALSE; 5619 gMultipleViewersOK = FALSE;
5849 } 5620 }
5621 else if (!strcmp(argv[j], "-novoice"))
5622 {
5623 gDisableVoice = TRUE;
5624 }
5850 else if (!strcmp(argv[j], "-nothread")) 5625 else if (!strcmp(argv[j], "-nothread"))
5851 { 5626 {
5852 LLVFile::ALLOW_ASYNC = FALSE; 5627 LLVFile::ALLOW_ASYNC = FALSE;
@@ -6232,6 +6007,8 @@ void send_logout_request()
6232 gLogoutTimer.reset(); 6007 gLogoutTimer.reset();
6233 gLogoutMaxTime = LOGOUT_REQUEST_TIME; 6008 gLogoutMaxTime = LOGOUT_REQUEST_TIME;
6234 gLogoutRequestSent = TRUE; 6009 gLogoutRequestSent = TRUE;
6010
6011 gVoiceClient->leaveChannel();
6235 } 6012 }
6236} 6013}
6237 6014
@@ -6319,6 +6096,8 @@ void cleanup_app()
6319 // to ensure shutdown order 6096 // to ensure shutdown order
6320 LLMortician::setZealous(TRUE); 6097 LLMortician::setZealous(TRUE);
6321 6098
6099 LLVoiceClient::terminate();
6100
6322 disconnect_viewer(NULL); 6101 disconnect_viewer(NULL);
6323 6102
6324 llinfos << "Viewer disconnected" << llendflush; 6103 llinfos << "Viewer disconnected" << llendflush;
@@ -6362,6 +6141,9 @@ void cleanup_app()
6362 delete gGlobalEconomy; 6141 delete gGlobalEconomy;
6363 gGlobalEconomy = NULL; 6142 gGlobalEconomy = NULL;
6364 6143
6144 delete gLocalSpeakerMgr;
6145 gLocalSpeakerMgr = NULL;
6146
6365 LLNotifyBox::cleanup(); 6147 LLNotifyBox::cleanup();
6366 6148
6367 llinfos << "Global stuff deleted" << llendflush; 6149 llinfos << "Global stuff deleted" << llendflush;
@@ -6383,7 +6165,7 @@ void cleanup_app()
6383 6165
6384 LLMediaEngine::cleanupClass(); 6166 LLMediaEngine::cleanupClass();
6385 6167
6386 #if LL_QUICKTIME_ENABLED 6168#if LL_QUICKTIME_ENABLED
6387 if (gQuickTimeInitialized) 6169 if (gQuickTimeInitialized)
6388 { 6170 {
6389 // clean up media stuff 6171 // clean up media stuff
@@ -6394,9 +6176,14 @@ void cleanup_app()
6394 TerminateQTML (); 6176 TerminateQTML ();
6395 #endif 6177 #endif
6396 } 6178 }
6397 #endif
6398
6399 llinfos << "Quicktime cleaned up" << llendflush; 6179 llinfos << "Quicktime cleaned up" << llendflush;
6180#endif
6181
6182#if LL_GSTREAMER_ENABLED
6183 llinfos << "Cleaning up GStreamer" << llendl;
6184 UnloadGStreamer();
6185 llinfos << "GStreamer cleaned up" << llendflush;
6186#endif
6400 6187
6401 llinfos << "Cleaning up feature manager" << llendflush; 6188 llinfos << "Cleaning up feature manager" << llendflush;
6402 delete gFeatureManagerp; 6189 delete gFeatureManagerp;
@@ -6495,7 +6282,7 @@ void cleanup_app()
6495 llinfos << "VFS cleaned up" << llendflush; 6282 llinfos << "VFS cleaned up" << llendflush;
6496 6283
6497 // Store the time of our current logoff 6284 // Store the time of our current logoff
6498 gSavedPerAccountSettings.setU32("LastLogoff", time_corrected()); 6285 gSavedPerAccountSettings.setU32("LastLogoff", time_corrected());
6499 6286
6500 // Must do this after all panels have been deleted because panels that have persistent rects 6287 // Must do this after all panels have been deleted because panels that have persistent rects
6501 // save their rects on delete. 6288 // save their rects on delete.
@@ -6598,6 +6385,13 @@ void cleanup_app()
6598 end_messaging_system(); 6385 end_messaging_system();
6599} 6386}
6600 6387
6388// Clear URIs when picking a new server
6389void resetURIs()
6390{
6391 gLoginURIs.clear();
6392 gHelperURI.clear();
6393}
6394
6601const std::vector<std::string>& getLoginURIs() 6395const std::vector<std::string>& getLoginURIs()
6602{ 6396{
6603 if (gLoginURIs.empty()) 6397 if (gLoginURIs.empty())