STORM-591 Made change per code review request: disable audio when teleport progress bar is present

Added code to start counting the fade in time on login when STATE_STARTED is set
meow-7.2.2
Jonathan Yap 2011-12-05 05:01:38 -05:00
parent 7226b23366
commit 3193170850
3 changed files with 50 additions and 6 deletions

View File

@ -38,6 +38,9 @@
#include "llviewermedia.h"
#include "llprogressview.h"
#include "llcallbacklist.h"
#include "llstartup.h"
#include "llviewerparcelmgr.h"
#include "llparcel.h"
/////////////////////////////////////////////////////////
@ -45,12 +48,16 @@ LLViewerAudio::LLViewerAudio() :
mDone(true),
mFadeState(FADE_IDLE),
mFadeTime(),
mIdleListnerActive(false)
mIdleListnerActive(false),
mForcedTeleportFade(false)
{
mTeleportFailedConnection = LLViewerParcelMgr::getInstance()->
setTeleportFailedCallback(boost::bind(&LLViewerAudio::onTeleportFailed, this));
}
LLViewerAudio::~LLViewerAudio()
{
mTeleportFailedConnection.disconnect();
}
void LLViewerAudio::registerIdleListener()
@ -108,14 +115,21 @@ void LLViewerAudio::startInternetStreamWithAutoFade(std::string streamURI)
}
}
// We want onIdleUpdate callback to keep firing whilst we are fading out. Once we have completed the fade
// out, we switch the stream and start a fade in, and we don't care about idle updates anymore.
// A return of false from onIdleUpdate means it will be called again next idle update.
// A return of true means we have finished with it and the callback will be deleted.
bool LLViewerAudio::onIdleUpdate()
{
bool fadeIsFinished = false;
// There is a delay in the login sequence between when the parcel information has
// arrived and the music stream is started and when the audio system is called to set
// initial volume levels. This code extends the fade time so you hear a full fade in.
if ((LLStartUp::getStartupState() < STATE_STARTED))
{
stream_fade_timer.reset();
stream_fade_timer.setTimerExpirySec(mFadeTime);
}
if (mDone)
{
// This should be a rare or never occurring state.
@ -231,6 +245,18 @@ F32 LLViewerAudio::getFadeVolume()
return fade_volume;
}
void LLViewerAudio::onTeleportFailed()
{
if (gAudiop)
{
LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
if (parcel)
{
mNextStreamURI = parcel->getMusicURL();
}
}
}
void init_audio()
{
if (!gAudiop)
@ -333,7 +359,19 @@ void audio_update_volume(bool force_update)
// Streaming Music
if (gAudiop)
{
{
if (progress_view_visible && !LLViewerAudio::getInstance()->getForcedTeleportFade())
{
LLViewerAudio::getInstance()->setForcedTeleportFade(true);
LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLStringUtil::null);
LLViewerAudio::getInstance()->setNextStreamURI(LLStringUtil::null);
}
if (!progress_view_visible && LLViewerAudio::getInstance()->getForcedTeleportFade() == true)
{
LLViewerAudio::getInstance()->setForcedTeleportFade(false);
}
F32 music_volume = gSavedSettings.getF32("AudioLevelMusic");
BOOL music_muted = gSavedSettings.getBOOL("MuteMusic");
F32 fade_volume = LLViewerAudio::getInstance()->getFadeVolume();

View File

@ -63,6 +63,9 @@ public:
EFadeState getFadeState() { return mFadeState; }
bool isDone() { return mDone; };
F32 getFadeVolume();
bool getForcedTeleportFade() { return mForcedTeleportFade; };
void setForcedTeleportFade(bool fade) { mForcedTeleportFade = fade;} ;
void setNextStreamURI(std::string stream) { mNextStreamURI = stream; } ;
private:
@ -72,10 +75,14 @@ private:
EFadeState mFadeState;
LLFrameTimer stream_fade_timer;
bool mIdleListnerActive;
bool mForcedTeleportFade;
boost::signals2::connection mTeleportFailedConnection;
void registerIdleListener();
void deregisterIdleListener() { mIdleListnerActive = false; };
void startFading();
void onTeleportFailed();
};
#endif //LL_VIEWER_H

View File

@ -1729,8 +1729,7 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use
// Check for video
LLViewerParcelMedia::update(parcel);
// Then check for music. Do this last, as there may be a delay waiting for
// the stream fading thread to finish.
// Then check for music
if (gAudiop)
{
if (parcel)