Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Andros Baphomet
2013-10-12 12:59:26 -04:00
21 changed files with 540 additions and 723 deletions

View File

@@ -1534,33 +1534,6 @@ bool LLAppViewer::cleanup()
llinfos << "Global stuff deleted" << llendflush;
if (gAudiop)
{
// shut down the streaming audio sub-subsystem first, in case it relies on not outliving the general audio subsystem.
LLStreamingAudioInterface *sai = gAudiop->getStreamingAudioImpl();
delete sai;
gAudiop->setStreamingAudioImpl(NULL);
// shut down the audio subsystem
bool want_longname = false;
if (gAudiop->getDriverName(want_longname) == "FMOD")
{
// This hack exists because fmod likes to occasionally
// crash or hang forever when shutting down, for no
// apparent reason.
llwarns << "Hack, skipping FMOD audio engine cleanup" << llendflush;
}
else
{
gAudiop->shutdown();
}
delete gAudiop;
gAudiop = NULL;
}
// Note: this is where LLFeatureManager::getInstance()-> used to be deleted.
// Patch up settings for next time
@@ -3942,6 +3915,9 @@ void LLAppViewer::idle()
gViewerWindow->updateUI();
//updateUI may have created sounds (clicks, etc). Call idleAudio to dispatch asap.
idleAudio();
///////////////////////////////////////
// Agent and camera movement
//
@@ -4120,22 +4096,6 @@ void LLAppViewer::idle()
gObjectList.updateApparentAngles(gAgent);
}
{
gFrameStats.start(LLFrameStats::AUDIO);
LLFastTimer t(FTM_AUDIO_UPDATE);
if (gAudiop)
{
audio_update_volume(false);
audio_update_listener();
audio_update_wind(false);
// this line actually commits the changes we've made to source positions, etc.
const F32 max_audio_decode_time = 0.002f; // 2 ms decode time
gAudiop->idle(max_audio_decode_time);
}
}
// Execute deferred tasks.
LLDeferredTaskList::instance().run();
@@ -4440,6 +4400,51 @@ void LLAppViewer::idleNetwork()
}
}
void LLAppViewer::idleAudio()
{
gFrameStats.start(LLFrameStats::AUDIO);
LLFastTimer t(FTM_AUDIO_UPDATE);
if (gAudiop)
{
audio_update_volume();
audio_update_listener();
// this line actually commits the changes we've made to source positions, etc.
const F32 max_audio_decode_time = 0.002f; // 2 ms decode time
gAudiop->idle(max_audio_decode_time);
}
}
void LLAppViewer::shutdownAudio()
{
if (gAudiop)
{
// shut down the streaming audio sub-subsystem first, in case it relies on not outliving the general audio subsystem.
LLStreamingAudioInterface *sai = gAudiop->getStreamingAudioImpl();
delete sai;
gAudiop->setStreamingAudioImpl(NULL);
// shut down the audio subsystem
bool want_longname = false;
if (gAudiop->getDriverName(want_longname) == "FMOD")
{
// This hack exists because fmod likes to occasionally
// crash or hang forever when shutting down, for no
// apparent reason.
llwarns << "Hack, skipping FMOD audio engine cleanup" << llendflush;
}
else
{
gAudiop->shutdown();
}
delete gAudiop;
gAudiop = NULL;
}
}
void LLAppViewer::disconnectViewer()
{
if (gDisconnected)
@@ -4540,6 +4545,9 @@ void LLAppViewer::disconnectViewer()
LLDestroyClassList::instance().fireCallbacks();
cleanup_xfer_manager();
shutdownAudio();
gDisconnected = TRUE;
}

View File

@@ -210,6 +210,8 @@ private:
// update avatar SLID and display name caches
void idleNameCache();
void idleNetwork();
void idleAudio();
void shutdownAudio();
void sendLogoutRequest();
void disconnectViewer();

View File

@@ -174,7 +174,8 @@ void LLFloaterBlacklist::addEntry(LLUUID key, LLSD data)
std::string wav_path= gDirUtilp->getExpandedFilename(LL_PATH_CACHE,sound_id.asString()) + ".dsf";
if(LLAPRFile::isExist(wav_path, LL_APR_RPB))
LLAPRFile::remove(wav_path);
gAudiop->removeAudioData(sound_id);
if(gAudiop)
gAudiop->removeAudioData(sound_id);
}
blacklist_entries.insert(std::pair<LLUUID,LLSD>(key,data));
updateBlacklists();

View File

@@ -498,6 +498,7 @@ void LLFloaterChat::triggerAlerts(const std::string& text)
{
if ((std::string)highlight["sound_lluuid"] != LLUUID::null.asString())
{
if(gAudiop)
gAudiop->triggerSound(highlight["sound_lluuid"].asUUID(),
gAgent.getID(),
1.f,

View File

@@ -304,6 +304,7 @@ void LLFloaterExploreSounds::handle_play_locally(void* user_data)
if(std::find(asset_list.begin(), asset_list.end(), item.mAssetID) == asset_list.end())
{
asset_list.push_back(item.mAssetID);
if(gAudiop)
gAudiop->triggerSound(item.mAssetID, LLUUID::null, 1.0f, LLAudioEngine::AUDIO_TYPE_UI);
}
}

View File

@@ -136,6 +136,8 @@ LLFloaterPay::LLFloaterPay(const std::string& name,
// Destroys the object
LLFloaterPay::~LLFloaterPay()
{
// In case this floater is currently waiting for a reply.
gMessageSystem->setHandlerFuncFast(_PREHASH_PayPriceReply, 0, 0);
}
// static

View File

@@ -93,13 +93,13 @@ LLPreviewSound::LLPreviewSound(const std::string& name, const LLRect& rect, cons
// preload the sound
if(item && gAudiop)
{
gAudiop->preloadSound(item->getAssetUUID());
// <edit>
// that thing above doesn't actually start a sound transfer, so I will do it
//LLAudioSource *asp = new LLAudioSource(gAgent.getID(), gAgent.getID(), F32(1.0f), LLAudioEngine::AUDIO_TYPE_UI);
LLAudioSource *asp = gAgentAvatarp->getAudioSource(gAgent.getID());
LLAudioData *datap = gAudiop->getAudioData(item->getAssetUUID());
asp->addAudioData(datap, FALSE);
if(asp)
{
asp->preload(item->getAssetUUID());
}
// </edit>
}

View File

@@ -375,6 +375,88 @@ void hooked_process_sound_trigger(LLMessageSystem *msg, void **)
LLFloaterAvatarList::sound_trigger_hook(msg,NULL);
}
void init_audio()
{
if (FALSE == gSavedSettings.getBOOL("NoAudio"))
{
gAudiop = NULL;
#ifdef LL_FMODEX
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_FMODEX_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_FMODEX(gSavedSettings.getBOOL("SHEnableFMODExProfiler"),gSavedSettings.getBOOL("SHEnableFMODEXVerboseDebugging"));
}
#endif
#ifdef LL_OPENAL
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_OPENAL_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_OpenAL();
}
#endif
#ifdef LL_FMOD
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_FMOD_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_FMOD();
}
#endif
if (gAudiop)
{
#if LL_WINDOWS
// FMOD on Windows needs the window handle to stop playing audio
// when window is minimized. JC
void* window_handle = (HWND)gViewerWindow->getPlatformWindow();
#else
void* window_handle = NULL;
#endif
bool init = gAudiop->init(kAUDIO_NUM_SOURCES, window_handle);
if(init)
{
gAudiop->setMuted(TRUE);
if(gSavedSettings.getBOOL("AllowLargeSounds"))
gAudiop->setAllowLargeSounds(true);
}
else
{
LL_WARNS("AppInit") << "Unable to initialize audio engine" << LL_ENDL;
delete gAudiop;
gAudiop = NULL;
}
if (gAudiop)
{
// if the audio engine hasn't set up its own preferred handler for streaming audio then set up the generic streaming audio implementation which uses media plugins
if (NULL == gAudiop->getStreamingAudioImpl())
{
LL_INFOS("AppInit") << "Using media plugins to render streaming audio" << LL_ENDL;
gAudiop->setStreamingAudioImpl(new LLStreamingAudio_MediaPlugins());
}
// Unmute audio if desired and setup volumes.
// This is a not-uncommon crash site, so surround it with
// llinfos output to aid diagnosis.
LL_INFOS("AppInit") << "Doing first audio_update_volume..." << LL_ENDL;
audio_update_volume(false);
LL_INFOS("AppInit") << "Done first audio_update_volume." << LL_ENDL;
}
}
}
LL_INFOS("AppInit") << "Audio Engine Initialized." << LL_ENDL;
}
// Returns false to skip other idle processing. Should only return
// true when all initialization done.
bool idle_startup()
@@ -674,85 +756,6 @@ bool idle_startup()
//-------------------------------------------------
AIFilePicker::loadFile("filepicker_contexts.xml");
//-------------------------------------------------
// Init audio, which may be needed for prefs dialog
// or audio cues in connection UI.
//-------------------------------------------------
if (FALSE == gSavedSettings.getBOOL("NoAudio"))
{
gAudiop = NULL;
#ifdef LL_FMODEX
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_FMODEX_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_FMODEX(gSavedSettings.getBOOL("SHEnableFMODExProfiler"),gSavedSettings.getBOOL("SHEnableFMODEXVerboseDebugging"));
}
#endif
#ifdef LL_OPENAL
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_OPENAL_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_OpenAL();
}
#endif
#ifdef LL_FMOD
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_FMOD_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_FMOD();
}
#endif
if (gAudiop)
{
#if LL_WINDOWS
// FMOD on Windows needs the window handle to stop playing audio
// when window is minimized. JC
void* window_handle = (HWND)gViewerWindow->getPlatformWindow();
#else
void* window_handle = NULL;
#endif
bool init = gAudiop->init(kAUDIO_NUM_SOURCES, window_handle);
if(init)
{
gAudiop->setMuted(TRUE);
if(gSavedSettings.getBOOL("AllowLargeSounds"))
gAudiop->setAllowLargeSounds(true);
}
else
{
LL_WARNS("AppInit") << "Unable to initialize audio engine" << LL_ENDL;
delete gAudiop;
gAudiop = NULL;
}
if (gAudiop)
{
// if the audio engine hasn't set up its own preferred handler for streaming audio then set up the generic streaming audio implementation which uses media plugins
if (NULL == gAudiop->getStreamingAudioImpl())
{
LL_INFOS("AppInit") << "Using media plugins to render streaming audio" << LL_ENDL;
gAudiop->setStreamingAudioImpl(new LLStreamingAudio_MediaPlugins());
}
}
}
}
LL_INFOS("AppInit") << "Audio Engine Initialized." << LL_ENDL;
if (LLTimer::knownBadTimer())
{
@@ -889,15 +892,13 @@ bool idle_startup()
if (login_history.size() > 0)
{
LLPanelLogin::setFields(*login_history.getEntries().rbegin());
display_startup();
}
else
{
LLPanelLogin::setFields(firstname, lastname, password);
display_startup();
LLPanelLogin::giveFocus();
}
display_startup();
LLPanelLogin::giveFocus();
gSavedSettings.setBOOL("FirstRunThisInstall", FALSE);
@@ -2356,7 +2357,7 @@ bool idle_startup()
if (!gNoRender)
{
// JC: Initializing audio requests many sounds for download.
//Now that we're loading the world, initialize the audio engine.
init_audio();
display_startup();
@@ -2535,6 +2536,8 @@ bool idle_startup()
LLViewerShaderMgr::instance()->setShaders();
display_startup();
}
//Precache UI sounds.
precache_audio();
}
return TRUE;
@@ -2677,13 +2680,8 @@ bool idle_startup()
gSavedSettings.setF32("RenderFarClip", 32.0f);
}
// Unmute audio if desired and setup volumes.
// Unmute audio if desired and setup volumes.
// This is a not-uncommon crash site, so surround it with
// llinfos output to aid diagnosis.
LL_INFOS("AppInit") << "Doing first audio_update_volume..." << LL_ENDL;
audio_update_volume();
LL_INFOS("AppInit") << "Done first audio_update_volume." << LL_ENDL;
//Agent avatar is ready. Create the listener.
audio_update_listener();
// reset keyboard focus to sane state of pointing at world
gFocusMgr.setKeyboardFocus(NULL);

View File

@@ -46,28 +46,15 @@
/////////////////////////////////////////////////////////
void init_audio()
void precache_audio()
{
if (!gAudiop)
{
llwarns << "Failed to create an appropriate Audio Engine" << llendl;
static bool already_precached = false;
if(already_precached)
return;
}
LLVector3d lpos_global = gAgentCamera.getCameraPositionGlobal();
LLVector3 lpos_global_f;
already_precached = true;
lpos_global_f.setVec(lpos_global);
gAudiop->setListener(lpos_global_f,
LLVector3::zero, // LLViewerCamera::getInstance()->getVelocity(), // !!! BUG need to replace this with smoothed velocity!
LLViewerCamera::getInstance()->getUpAxis(),
LLViewerCamera::getInstance()->getAtAxis());
// load up our initial set of sounds we'll want so they're in memory and ready to be played
BOOL mute_audio = gSavedSettings.getBOOL("MuteAudio");
if (!mute_audio && FALSE == gSavedSettings.getBOOL("NoPreload"))
// load up our initial set of sounds we'll want so they're in memory and ready to be played
if (gAudiop && !gSavedSettings.getBOOL("MuteAudio") && !gSavedSettings.getBOOL("NoPreload"))
{
gAudiop->preloadSound(LLUUID(gSavedSettings.getString("UISndAlert")));
gAudiop->preloadSound(LLUUID(gSavedSettings.getString("UISndBadKeystroke")));
@@ -110,11 +97,9 @@ void init_audio()
gAudiop->preloadSound(LLUUID(gSavedSettings.getString("UISndWindowClose")));
gAudiop->preloadSound(LLUUID(gSavedSettings.getString("UISndWindowOpen")));
}
audio_update_volume(true);
}
void audio_update_volume(bool force_update)
void audio_update_volume( bool wind_fade )
{
static const LLCachedControl<F32> master_volume("AudioLevelMaster",1.0);
static const LLCachedControl<F32> audio_level_sfx("AudioLevelSFX",1.0);
@@ -154,11 +139,6 @@ void audio_update_volume(bool force_update)
gAudiop->setRolloffFactor( audio_level_underwater_rolloff );
gAudiop->setMuted(mute_audio);
if (force_update)
{
audio_update_wind(true);
}
// handle secondary gains
gAudiop->setSecondaryGain(LLAudioEngine::AUDIO_TYPE_SFX,
@@ -167,6 +147,8 @@ void audio_update_volume(bool force_update)
mute_ui ? 0.f : audio_level_ui);
gAudiop->setSecondaryGain(LLAudioEngine::AUDIO_TYPE_AMBIENT,
mute_ambient ? 0.f : audio_level_ambient);
audio_update_wind(wind_fade);
}
// Streaming Music
@@ -217,17 +199,23 @@ void audio_update_listener()
}
}
void audio_update_wind(bool force_update)
void audio_update_wind(bool fade)
{
#ifdef kAUDIO_ENABLE_WIND
if(gAgent.getRegion())
if(gAgent.getRegion() && gAudiop)
{
// Scale down the contribution of weather-simulation wind to the
// ambient wind noise. Wind velocity averages 3.5 m/s, with gusts to 7 m/s
// whereas steady-state avatar walk velocity is only 3.2 m/s.
// Without this the world feels desolate on first login when you are
// standing still.
static LLCachedControl<F32> wind_level("AudioLevelWind", 0.5f);
static LLCachedControl<F32> wind_level("AudioLevelWind", 0.5f);
static LLCachedControl<bool> mute_audio("MuteAudio", false);
static LLCachedControl<bool> mute_ambient("MuteAmbient", false);
static LLCachedControl<F32> audio_level_master("AudioLevelMaster", 1.f);
static LLCachedControl<F32> audio_level_ambient("AudioLevelAmbient", 1.f);
LLVector3 scaled_wind_vec = gWindVec * wind_level;
// Mix in the avatar's motion, subtract because when you walk north,
@@ -240,18 +228,18 @@ void audio_update_wind(bool force_update)
// don't use the setter setMaxWindGain() because we don't
// want to screw up the fade-in on startup by setting actual source gain
// outside the fade-in.
F32 master_volume = gSavedSettings.getBOOL("MuteAudio") ? 0.f : gSavedSettings.getF32("AudioLevelMaster");
F32 ambient_volume = gSavedSettings.getBOOL("MuteAmbient") ? 0.f : gSavedSettings.getF32("AudioLevelAmbient");
F32 master_volume = mute_audio ? 0.f : audio_level_master;
F32 ambient_volume = mute_ambient ? 0.f : audio_level_ambient;
F32 max_wind_volume = master_volume * ambient_volume;
const F32 WIND_SOUND_TRANSITION_TIME = 2.f;
// amount to change volume this frame
F32 volume_delta = (LLFrameTimer::getFrameDeltaTimeF32() / WIND_SOUND_TRANSITION_TIME) * max_wind_volume;
if (force_update)
F32 volume_delta = 1.f;
if(fade)
{
// initialize wind volume (force_update) by using large volume_delta
// which is sufficient to completely turn off or turn on wind noise
volume_delta = 1.f;
// amount to change volume this frame
volume_delta = (LLFrameTimer::getFrameDeltaTimeF32() / WIND_SOUND_TRANSITION_TIME) * max_wind_volume;
}
static LLCachedControl<bool> MuteWind("MuteWind");

View File

@@ -39,9 +39,9 @@
#define kAUDIO_NUM_BUFFERS 30
#define kAUDIO_NUM_SOURCES 30
void init_audio();
void audio_update_volume(bool force_update = true);
void precache_audio();
void audio_update_volume(bool wind_fade = true);
void audio_update_listener();
void audio_update_wind(bool force_update = true);
void audio_update_wind(bool fade);
#endif //LL_VIEWER_H

View File

@@ -355,7 +355,7 @@ static bool handleChatPersistTimeChanged(const LLSD& newvalue)
static void handleAudioVolumeChanged(const LLSD& newvalue)
{
audio_update_volume(true);
audio_update_volume(false);
}
static bool handleJoystickChanged(const LLSD& newvalue)

View File

@@ -5328,8 +5328,6 @@ void process_preload_sound(LLMessageSystem *msg, void **user_data)
LLAudioSource *sourcep = objectp->getAudioSource(owner_id);
if (!sourcep) return;
LLAudioData *datap = gAudiop->getAudioData(sound_id);
// Note that I don't actually do any loading of the
// audio data into a buffer at this point, as it won't actually
// help us out.
@@ -5338,8 +5336,8 @@ void process_preload_sound(LLMessageSystem *msg, void **user_data)
LLVector3d pos_global = objectp->getPositionGlobal();
if (gAgent.canAccessMaturityAtGlobal(pos_global))
{
// Add audioData starts a transfer internally.
sourcep->addAudioData(datap, FALSE);
// Preload starts a transfer internally.
sourcep->preload(sound_id);
}
}

View File

@@ -1432,7 +1432,7 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
}
// Unmute audio
audio_update_volume();
audio_update_volume(false);
}
else
{
@@ -1457,7 +1457,7 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
stopGL();
}
// Mute audio
audio_update_volume();
audio_update_volume(false);
}
return TRUE;
}

View File

@@ -83,6 +83,9 @@ SHFloaterMediaTicker::SHFloaterMediaTicker() : LLFloater()/*, LLSingleton<SHFloa
}
void SHFloaterMediaTicker::updateTickerText() //called via draw.
{
if(!gAudiop)
return;
bool stream_paused = gAudiop->getStreamingAudioImpl()->isPlaying() != 1; //will return 1 if playing.
bool dirty = setPaused(stream_paused);
@@ -119,7 +122,7 @@ void SHFloaterMediaTicker::updateTickerText() //called via draw.
void SHFloaterMediaTicker::drawOscilloscope() //called via draw.
{
if(!mVisualizer || !gAudiop->getStreamingAudioImpl()->supportsWaveData())
if(!gAudiop || !mVisualizer || !gAudiop->getStreamingAudioImpl()->supportsWaveData())
return;
static const S32 NUM_LINE_STRIPS = 64; //How many lines to draw. 64 is more than enough.