From 4cdf3961253b49093bf3e2fceda0099cedef4295 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Fri, 28 Oct 2011 17:48:24 -0400 Subject: STORM-591 As a music fan, I want audio to fade in gently so my immersion is increased Co-written with Robin Cornelius --- indra/newview/app_settings/settings.xml | 22 ++ indra/newview/lloverlaybar.cpp | 378 -------------------------------- indra/newview/lloverlaybar.h | 95 -------- indra/newview/llpanelnearbymedia.cpp | 24 +- indra/newview/llpanelnearbymedia.h | 1 - indra/newview/llvieweraudio.cpp | 211 +++++++++++++++++- indra/newview/llvieweraudio.h | 41 ++++ indra/newview/llviewermedia.cpp | 22 +- indra/newview/llviewerparcelmgr.cpp | 55 +++-- 9 files changed, 320 insertions(+), 529 deletions(-) delete mode 100644 indra/newview/lloverlaybar.cpp delete mode 100644 indra/newview/lloverlaybar.h (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 3c53a9d44c..c7300cc1bb 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -192,6 +192,28 @@ Value 1 + AudioMusicFadeIn + + Comment + Fade in time in seconds for music streams + Persist + 1 + Type + F32 + Value + 5.0 + + AudioMusicFadeOut + + Comment + Fade out time in seconds for music streams + Persist + 1 + Type + F32 + Value + 5.0 + AudioLevelAmbient Comment diff --git a/indra/newview/lloverlaybar.cpp b/indra/newview/lloverlaybar.cpp deleted file mode 100644 index c2bbec0470..0000000000 --- a/indra/newview/lloverlaybar.cpp +++ /dev/null @@ -1,378 +0,0 @@ -/** - * @file lloverlaybar.cpp - * @brief LLOverlayBar class implementation - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * 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. - * - * 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. - * - * 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 - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -// Temporary buttons that appear at the bottom of the screen when you -// are in a mode. - -#include "llviewerprecompiledheaders.h" - -#include "lloverlaybar.h" - -#include "llaudioengine.h" -#include "llrender.h" -#include "llagent.h" -#include "llbutton.h" -#include "llfocusmgr.h" -#include "llimview.h" -#include "llmediaremotectrl.h" -#include "llparcel.h" -#include "lltextbox.h" -#include "llui.h" -#include "llviewercontrol.h" -#include "llviewertexturelist.h" -#include "llviewerjoystick.h" -#include "llviewermedia.h" -#include "llviewermenu.h" // handle_reset_view() -#include "llviewermedia.h" -#include "llviewerparcelmedia.h" -#include "llviewerparcelmgr.h" -#include "lluictrlfactory.h" -#include "llviewerwindow.h" -#include "llvoiceclient.h" -#include "llvoavatarself.h" -#include "llvoiceremotectrl.h" -#include "llmediactrl.h" -#include "llselectmgr.h" - -// -// Globals -// - -LLOverlayBar *gOverlayBar = NULL; - -extern S32 MENU_BAR_HEIGHT; - -// -// Functions -// - - - -void* LLOverlayBar::createMediaRemote(void* userdata) -{ - LLOverlayBar *self = (LLOverlayBar*)userdata; - self->mMediaRemote = new LLMediaRemoteCtrl (); - return self->mMediaRemote; -} - -void* LLOverlayBar::createVoiceRemote(void* userdata) -{ - LLOverlayBar *self = (LLOverlayBar*)userdata; - self->mVoiceRemote = new LLVoiceRemoteCtrl(); - return self->mVoiceRemote; -} - -LLOverlayBar::LLOverlayBar() - : LLPanel(), - mMediaRemote(NULL), - mVoiceRemote(NULL), - mMusicState(STOPPED) -{ - setMouseOpaque(FALSE); - setIsChrome(TRUE); - - mBuilt = false; - - mFactoryMap["media_remote"] = LLCallbackMap(LLOverlayBar::createMediaRemote, this); - mFactoryMap["voice_remote"] = LLCallbackMap(LLOverlayBar::createVoiceRemote, this); - - LLUICtrlFactory::getInstance()->buildPanel(this, "panel_overlaybar.xml"); -} - -BOOL LLOverlayBar::postBuild() -{ - childSetAction("Set Not Busy",onClickSetNotBusy,this); - childSetAction("Mouselook",onClickMouselook,this); - childSetAction("Stand Up",onClickStandUp,this); - childSetAction("Flycam",onClickFlycam,this); - childSetVisible("chat_bar", gSavedSettings.getBOOL("ChatVisible")); - - mVoiceRemote->expandOrCollapse(); - mMediaRemote->expandOrCollapse(); - - setFocusRoot(TRUE); - mBuilt = true; - - layoutButtons(); - return TRUE; -} - -LLOverlayBar::~LLOverlayBar() -{ - // LLView destructor cleans up children -} - -// virtual -void LLOverlayBar::reshape(S32 width, S32 height, BOOL called_from_parent) -{ - LLView::reshape(width, height, called_from_parent); - - if (mBuilt) - { - layoutButtons(); - } -} - -void LLOverlayBar::layoutButtons() -{ - LLView* state_buttons_panel = getChildView("state_buttons"); - - if (state_buttons_panel->getVisible()) - { - LLViewQuery query; - LLWidgetTypeFilter widget_filter; - query.addPreFilter(LLEnabledFilter::getInstance()); - query.addPreFilter(&widget_filter); - - child_list_t button_list = query(state_buttons_panel); - - const S32 MAX_BAR_WIDTH = 600; - S32 bar_width = llclamp(state_buttons_panel->getRect().getWidth(), 0, MAX_BAR_WIDTH); - - // calculate button widths - const S32 MAX_BUTTON_WIDTH = 150; - const S32 STATUS_BAR_PAD = 10; - S32 segment_width = llclamp(lltrunc((F32)(bar_width) / (F32)button_list.size()), 0, MAX_BUTTON_WIDTH); - S32 btn_width = segment_width - STATUS_BAR_PAD; - - // Evenly space all buttons, starting from left - S32 left = 0; - S32 bottom = 1; - - for (child_list_reverse_iter_t child_iter = button_list.rbegin(); - child_iter != button_list.rend(); ++child_iter) - { - LLView *view = *child_iter; - LLRect r = view->getRect(); - r.setOriginAndSize(left, bottom, btn_width, r.getHeight()); - view->setRect(r); - left += segment_width; - } - } -} - -// Per-frame updates of visibility -void LLOverlayBar::refresh() -{ - BOOL buttons_changed = FALSE; - - BOOL im_received = gIMMgr->getIMReceived(); - LLButton* button = getChild("IM Received"); - if (button && button->getVisible() != im_received) - { - button->setVisible(im_received); - sendChildToFront(button); - moveChildToBackOfTabGroup(button); - buttons_changed = TRUE; - } - - BOOL busy = gAgent.getBusy(); - button = getChild("Set Not Busy"); - if (button && button->getVisible() != busy) - { - button->setVisible(busy); - sendChildToFront(button); - moveChildToBackOfTabGroup(button); - buttons_changed = TRUE; - } - - BOOL flycam = LLViewerJoystick::getInstance()->getOverrideCamera(); - button = getChild("Flycam"); - if (button && button->getVisible() != flycam) - { - button->setVisible(flycam); - sendChildToFront(button); - moveChildToBackOfTabGroup(button); - buttons_changed = TRUE; - } - - BOOL mouselook_grabbed; - mouselook_grabbed = gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_DOWN_INDEX) - || gAgent.isControlGrabbed(CONTROL_ML_LBUTTON_UP_INDEX); - button = getChild("Mouselook"); - - if (button && button->getVisible() != mouselook_grabbed) - { - button->setVisible(mouselook_grabbed); - sendChildToFront(button); - moveChildToBackOfTabGroup(button); - buttons_changed = TRUE; - } - - BOOL sitting = FALSE; - if (gAgent.getAvatarObject()) - { - sitting = gAgent.getAvatarObject()->isSitting(); - } - button = getChild("Stand Up"); - - if (button && button->getVisible() != sitting) - { - button->setVisible(sitting); - sendChildToFront(button); - moveChildToBackOfTabGroup(button); - buttons_changed = TRUE; - } - - - moveChildToBackOfTabGroup(mMediaRemote); - moveChildToBackOfTabGroup(mVoiceRemote); - - // turn off the whole bar in mouselook - if (gAgent.cameraMouselook()) - { - childSetVisible("media_remote_container", FALSE); - childSetVisible("voice_remote_container", FALSE); - childSetVisible("state_buttons", FALSE); - } - else - { - // update "remotes" - childSetVisible("media_remote_container", TRUE); - childSetVisible("voice_remote_container", LLVoiceClient::getInstance()->voiceEnabled()); - childSetVisible("state_buttons", TRUE); - } - - // always let user toggle into and out of chatbar - childSetVisible("chat_bar", gSavedSettings.getBOOL("ChatVisible")); - - if (buttons_changed) - { - layoutButtons(); - } -} - -//----------------------------------------------------------------------- -// Static functions -//----------------------------------------------------------------------- - -// static -void LLOverlayBar::onClickSetNotBusy(void*) -{ - gAgent.clearBusy(); -} - - -// static -void LLOverlayBar::onClickFlycam(void*) -{ - LLViewerJoystick::getInstance()->toggleFlycam(); -} - -// static -void LLOverlayBar::onClickResetView(void* data) -{ - handle_reset_view(); -} - -//static -void LLOverlayBar::onClickMouselook(void*) -{ - gAgent.changeCameraToMouselook(); -} - -//static -void LLOverlayBar::onClickStandUp(void*) -{ - LLSelectMgr::getInstance()->deselectAllForStandingUp(); - gAgent.setControlFlags(AGENT_CONTROL_STAND_UP); -} - -//////////////////////////////////////////////////////////////////////////////// -// static media helpers -// *TODO: Move this into an audio manager abstraction -//static -void LLOverlayBar::mediaStop(void*) -{ - if (!gOverlayBar) - { - // return; - } - LLViewerParcelMedia::stop(); -} -//static -void LLOverlayBar::toggleMediaPlay(void*) -{ - if (!gOverlayBar) - { - // return; - } - - - if (LLViewerParcelMedia::getStatus() == LLViewerMediaImpl::MEDIA_PAUSED) - { - LLViewerParcelMedia::start(); - } - else if(LLViewerParcelMedia::getStatus() == LLViewerMediaImpl::MEDIA_PLAYING) - { - LLViewerParcelMedia::pause(); - } - else - { - LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if (parcel) - { - LLViewerParcelMedia::play(parcel); - } - } -} - -//static -void LLOverlayBar::toggleMusicPlay(void*) -{ - if (gAudiop->isInternetStreamPlaying() != 1) - { - if (gAudiop) - { - LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if ( parcel ) - { - // this doesn't work properly when crossing parcel boundaries - even when the - // stream is stopped, it doesn't return the right thing - commenting out for now. - // if ( gAudiop->isInternetStreamPlaying() == 0 ) - { - gAudiop->startInternetStream(parcel->getMusicURL()); - } - } - } - } - //else - //{ - // gOverlayBar->mMusicState = PAUSED; // desired state - // if (gAudiop) - // { - // gAudiop->pauseInternetStream(1); - // } - //} - else - { - if (gAudiop) - { - gAudiop->stopInternetStream(); - } - } -} - diff --git a/indra/newview/lloverlaybar.h b/indra/newview/lloverlaybar.h deleted file mode 100644 index b36f5ebb73..0000000000 --- a/indra/newview/lloverlaybar.h +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @file lloverlaybar.h - * @brief LLOverlayBar class definition - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * 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. - * - * 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. - * - * 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 - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLOVERLAYBAR_H -#define LL_LLOVERLAYBAR_H - -#include "llpanel.h" - -// "Constants" loaded from settings.xml at start time -extern S32 STATUS_BAR_HEIGHT; - -class LLButton; -class LLLineEditor; -class LLMediaRemoteCtrl; -class LLMessageSystem; -class LLTextBox; -class LLTextEditor; -class LLUICtrl; -class LLUUID; -class LLFrameTimer; -class LLStatGraph; -class LLSlider; -class LLVoiceRemoteCtrl; - -class LLOverlayBar -: public LLPanel -{ -public: - LLOverlayBar(); - ~LLOverlayBar(); - - /*virtual*/ void refresh(); - /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); - /*virtual*/ BOOL postBuild(); - - void layoutButtons(); - - // helpers for returning desired state - BOOL musicPlaying() { return mMusicState == PLAYING; } - - static void onClickSetNotBusy(void* data); - static void onClickMouselook(void* data); - static void onClickStandUp(void* data); - static void onClickResetView(void* data); - static void onClickFlycam(void* data); - - //static media helper functions - static void toggleMediaPlay(void*); - static void toggleMusicPlay(void*); - static void musicPause(void*); - static void musicStop(void*); - static void mediaStop(void*); - - static void toggleAudioVolumeFloater(void*); - -protected: - static void* createMediaRemote(void* userdata); - static void* createVoiceRemote(void* userdata); - - void enableMediaButtons(); - -protected: - LLMediaRemoteCtrl* mMediaRemote; - LLVoiceRemoteCtrl* mVoiceRemote; - bool mBuilt; // dialog constructed yet? - enum { STOPPED=0, PLAYING=1, PAUSED=2 }; - S32 mMusicState; -}; - -extern LLOverlayBar* gOverlayBar; - -#endif diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp index 2bbd15ae11..53fc64f089 100644 --- a/indra/newview/llpanelnearbymedia.cpp +++ b/indra/newview/llpanelnearbymedia.cpp @@ -52,6 +52,7 @@ #include "llvovolume.h" #include "llstatusbar.h" #include "llsdutil.h" +#include "llvieweraudio.h" #include "llfloaterreg.h" #include "llfloaterpreference.h" // for the gear icon @@ -808,7 +809,7 @@ bool LLPanelNearByMedia::setDisabled(const LLUUID &row_id, bool disabled) if (row_id == PARCEL_AUDIO_LIST_ITEM_UUID) { if (disabled) onClickParcelAudioStop(); - else onClickParcelAudioStart(); + else onClickParcelAudioPlay(); return true; } else if (row_id == PARCEL_MEDIA_LIST_ITEM_UUID) @@ -857,24 +858,11 @@ void LLPanelNearByMedia::onClickParcelMediaPause() LLViewerParcelMedia::pause(); } -void LLPanelNearByMedia::onClickParcelAudioStart() -{ - // User *explicitly* started the internet stream, so keep the stream - // playing and updated as they cross to other parcels etc. - mParcelAudioAutoStart = true; - - if (!gAudiop) - return; - - gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); -} - void LLPanelNearByMedia::onClickParcelAudioPlay() { // User *explicitly* started the internet stream, so keep the stream // playing and updated as they cross to other parcels etc. mParcelAudioAutoStart = true; - if (!gAudiop) return; @@ -883,8 +871,9 @@ void LLPanelNearByMedia::onClickParcelAudioPlay() // 'false' means unpause gAudiop->pauseInternetStream(false); } - else { - gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); + else + { + LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLViewerMedia::getParcelAudioURL()); } } @@ -894,11 +883,10 @@ void LLPanelNearByMedia::onClickParcelAudioStop() // re-start audio when i.e. they move to another parcel, until // they explicitly start it again. mParcelAudioAutoStart = false; - if (!gAudiop) return; - gAudiop->stopInternetStream(); + LLViewerAudio::getInstance()->stopInternetStreamWithAutoFade(); } void LLPanelNearByMedia::onClickParcelAudioPause() diff --git a/indra/newview/llpanelnearbymedia.h b/indra/newview/llpanelnearbymedia.h index be4d313743..c3634de9b4 100644 --- a/indra/newview/llpanelnearbymedia.h +++ b/indra/newview/llpanelnearbymedia.h @@ -115,7 +115,6 @@ private: void onClickParcelMediaPause(); void onClickParcelAudioPlay(); void onClickParcelAudioStop(); - void onClickParcelAudioStart(); void onClickParcelAudioPause(); void onCheckAutoPlay(); void onAdvancedButtonClick(); diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp index f7fa5690d6..8fd1ca3807 100644 --- a/indra/newview/llvieweraudio.cpp +++ b/indra/newview/llvieweraudio.cpp @@ -37,9 +37,212 @@ #include "llvoiceclient.h" #include "llviewermedia.h" #include "llprogressview.h" +#include "llcallbacklist.h" ///////////////////////////////////////////////////////// +LLViewerAudio::LLViewerAudio() : + mDone(true), + mFadeState(FADE_IDLE), + mFadeTime(), + mIdleListnerActive(false) +{ +} + +LLViewerAudio::~LLViewerAudio() +{ +} + +void LLViewerAudio::registerIdleListener() +{ + if(mIdleListnerActive==false) + { + mIdleListnerActive = true; + doOnIdleRepeating(boost::bind(boost::bind(&LLViewerAudio::onIdleUpdate, this))); + } + +} + +void LLViewerAudio::startInternetStreamWithAutoFade(std::string streamURI) +{ + llinfos << "DBG streamURI: " << streamURI << llendl; + llinfos << "DBG mNextStreamURI: " << mNextStreamURI << llendl; + if (mFadeState == FADE_OUT) {llinfos << "DBG mFadeState: FADE_OUT " << llendl;} + if (mFadeState == FADE_IN) {llinfos << "DBG mFadeState: FADE_IN " << llendl;} + if (mFadeState == FADE_IDLE) {llinfos << "DBG mFadeState: FADE_IDLE " << llendl;} + + // Old and new stream are identical + if (mNextStreamURI == streamURI) + { + return; + } + + // Record the URI we are going to be switching to + mNextStreamURI = streamURI; + + if (mFadeState == FADE_IDLE) + { + // If a stream is playing fade it out first + if (!gAudiop->getInternetStreamURL().empty()) + { + mFadeState = FADE_OUT; +llinfos << "DBG new mFadeState: OUT" << llendl; + } + // Otherwise the new stream can be faded in + else + { + mFadeState = FADE_IN; +llinfos << "DBG new mFadeState: IN" << llendl; + + gAudiop->startInternetStream(mNextStreamURI); + startFading(); + registerIdleListener(); + return; + } + } + + if (mFadeState == FADE_OUT) + { + startFading(); + registerIdleListener(); + return; + } + + if (mFadeState == FADE_IN) + { + registerIdleListener(); + return; + } +} + +// 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() +{ + if (mDone) + { + if (mFadeState == FADE_OUT) {llinfos << "DBG mFadeState: FADE_OUT " << llendl;} + if (mFadeState == FADE_IN) {llinfos << "DBG mFadeState: FADE_IN " << llendl;} + if (mFadeState == FADE_IDLE) {llinfos << "DBG mFadeState: FADE_IDLE " << llendl;} + + // This should be a rare or never occurring state. + if (mFadeState == FADE_IDLE) + { + deregisterIdleListener(); + return true; // Stop calling onIdleUpdate + } + + // we have finished the current fade operation + if (mFadeState == FADE_OUT) + { + // Clear URI + gAudiop->startInternetStream(LLStringUtil::null); + gAudiop->stopInternetStream(); + + if (!mNextStreamURI.empty()) + { + mFadeState = FADE_IN; +llinfos << "DBG new mFadeState: IN" << llendl; + gAudiop->startInternetStream(mNextStreamURI); + startFading(); + return false; + } + else + { + mFadeState = FADE_IDLE; +llinfos << "DBG new mFadeState: IDLE" << llendl; + deregisterIdleListener(); + return true; // Stop calling onIdleUpdate + } + } + else if (mFadeState == FADE_IN) + { + if (mNextStreamURI != gAudiop->getInternetStreamURL()) + { + mFadeState = FADE_OUT; + startFading(); + return false; +llinfos << "DBG new mFadeState: OUT" << llendl; + } + else + { + mFadeState = FADE_IDLE; +llinfos << "DBG new mFadeState: IDLE" << llendl; + deregisterIdleListener(); + return true; // Stop calling onIdleUpdate + } + } + } + + return false; +} + +void LLViewerAudio::stopInternetStreamWithAutoFade() +{ +llinfos << "DBG stopping stream" << llendl; + mFadeState = FADE_IDLE; +llinfos << "DBG new mFadeState: IDLE" << llendl; + mNextStreamURI = LLStringUtil::null; + mDone = true; +llinfos << "DBG mDone: true" << llendl; + + gAudiop->startInternetStream(LLStringUtil::null); + gAudiop->stopInternetStream(); +} + +void LLViewerAudio::startFading() +{ +llinfos << "DBG startFading" << llendl; + + if(mDone) + { + // The fade state here should only be one of FADE_IN or FADE_OUT, but, in case it is not, + // rather than check for both states assume a fade in and check for the fade out case. + mFadeTime = llmax(0.0f, gSavedSettings.getF32("AudioMusicFadeIn")); + if (LLViewerAudio::getInstance()->getFadeState() == LLViewerAudio::FADE_OUT) + { + mFadeTime = llmax(0.0f, gSavedSettings.getF32("AudioMusicFadeOut")); + } + stream_fade_timer.reset(); + stream_fade_timer.setTimerExpirySec(mFadeTime); + mDone = false; +llinfos << "DBG mDone: false" << llendl; + } +} + +F32 LLViewerAudio::getFadeVolume() +{ + F32 fade_volume = 1.0f; + + if (stream_fade_timer.hasExpired()) + { + mDone = true; + // If we have been fading out set volume to 0 until the next fade state occurs to prevent + // an audio transient. + if (LLViewerAudio::getInstance()->getFadeState() == LLViewerAudio::FADE_OUT) + { + fade_volume = 0.0f; + } + } + + if (!mDone) + { + // Calculate how far we are into the fade time + fade_volume = stream_fade_timer.getElapsedTimeF32() / mFadeTime; + + if (LLViewerAudio::getInstance()->getFadeState() == LLViewerAudio::FADE_OUT) + { + // If we are not fading in then we are fading out, so invert the fade + // direction; start loud and move towards zero volume. + fade_volume = 1.0f - fade_volume; + } + } + + return fade_volume; +} + void init_audio() { if (!gAudiop) @@ -145,9 +348,11 @@ void audio_update_volume(bool force_update) { F32 music_volume = gSavedSettings.getF32("AudioLevelMusic"); BOOL music_muted = gSavedSettings.getBOOL("MuteMusic"); - music_volume = mute_volume * master_volume * music_volume; - gAudiop->setInternetStreamGain ( music_muted || progress_view_visible ? 0.f : music_volume ); - + F32 fade_volume = LLViewerAudio::getInstance()->getFadeVolume(); +llinfos << "DBG fade_volume:" << fade_volume << llendl; + + music_volume = mute_volume * master_volume * music_volume * fade_volume; + gAudiop->setInternetStreamGain (music_muted ? 0.f : music_volume); } // Streaming Media diff --git a/indra/newview/llvieweraudio.h b/indra/newview/llvieweraudio.h index e5916285fb..316d7b32d2 100644 --- a/indra/newview/llvieweraudio.h +++ b/indra/newview/llvieweraudio.h @@ -27,6 +27,10 @@ #ifndef LL_VIEWERAUDIO_H #define LL_VIEWERAUDIO_H +#include "llframetimer.h" +#include "llthread.h" +#include "llsingleton.h" + // comment out to turn off wind #define kAUDIO_ENABLE_WIND //#define kAUDIO_ENABLE_WATER 1 // comment out to turn off water @@ -38,4 +42,41 @@ void audio_update_volume(bool force_update = true); void audio_update_listener(); void audio_update_wind(bool force_update = true); +class LLViewerAudio : public LLSingleton +{ +public: + + enum EFadeState + { + FADE_IDLE, + FADE_IN, + FADE_OUT, + }; + + LLViewerAudio(); + virtual ~LLViewerAudio(); + + void startInternetStreamWithAutoFade(std::string streamURI); + void stopInternetStreamWithAutoFade(); + + bool LLViewerAudio::onIdleUpdate(); + + EFadeState getFadeState() { return mFadeState; } + bool isDone() { return mDone; }; + F32 getFadeVolume(); + +private: + + bool mDone; + F32 mFadeTime; + std::string mNextStreamURI; + EFadeState mFadeState; + LLFrameTimer stream_fade_timer; + bool mIdleListnerActive; + + void registerIdleListener(); + void deregisterIdleListener() { mIdleListnerActive = false; }; + void startFading(); +}; + #endif //LL_VIEWER_H diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 41b4dc01e8..148bfbf080 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -66,7 +66,7 @@ //#include "llfirstuse.h" #include "llviewernetwork.h" #include "llwindow.h" - +#include "llvieweraudio.h" #include "llfloatermediabrowser.h" // for handling window close requests and geometry change requests in media browser windows. #include "llfloaterwebcontent.h" // for handling window close requests and geometry change requests in media browser windows. @@ -967,7 +967,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg) { if(LLViewerMedia::isParcelAudioPlaying() && gAudiop && LLViewerMedia::hasParcelAudio()) { - gAudiop->stopInternetStream(); + LLViewerAudio::getInstance()->stopInternetStreamWithAutoFade(); } } pimpl->setPriority(new_priority); @@ -1069,13 +1069,24 @@ void LLViewerMedia::setAllMediaEnabled(bool val) gAudiop && LLViewerMedia::hasParcelAudio()) { - gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); + if (LLAudioEngine::AUDIO_PAUSED == gAudiop->isInternetStreamPlaying()) + { + // 'false' means unpause + gAudiop->pauseInternetStream(false); + } + else + { + LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLViewerMedia::getParcelAudioURL()); + } } } else { // This actually unloads the impl, as opposed to "stop"ping the media LLViewerParcelMedia::stop(); - if (gAudiop) gAudiop->stopInternetStream(); + if (gAudiop) + { + LLViewerAudio::getInstance()->stopInternetStreamWithAutoFade(); + } } } @@ -1488,8 +1499,7 @@ void LLViewerMedia::setOpenIDCookie() new LLViewerMediaWebProfileResponder(raw_profile_url.getAuthority()), headers); - // FUI: No longer perform the user_status query - //doOnetimeEarlyHTTPRequests(); + doOnetimeEarlyHTTPRequests(); } } diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index 8db72da1ee..928a84e7eb 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -67,6 +67,7 @@ #include "llworld.h" #include "roles_constants.h" #include "llweb.h" +#include "llvieweraudio.h" const F32 PARCEL_COLLISION_DRAW_SECS = 1.f; @@ -1725,7 +1726,11 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use } else { - // look for music. + // 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. if (gAudiop) { if (parcel) @@ -1736,46 +1741,36 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use std::string music_url = music_url_raw; LLStringUtil::trim(music_url); - // On entering a new parcel, stop the last stream if the - // new parcel has a different music url. (Empty URL counts - // as different.) const std::string& stream_url = gAudiop->getInternetStreamURL(); - if (music_url.empty() || music_url != stream_url) + // If there is a new music URL and it's valid, play it. + if (music_url.size() > 12) { - // URL is different from one currently playing. - gAudiop->stopInternetStream(); - - // If there is a new music URL and it's valid, play it. - if (music_url.size() > 12) + if (music_url.substr(0,7) == "http://") { - if (music_url.substr(0,7) == "http://") - { - optionally_start_music(music_url); - } - else - { - llinfos << "Stopping parcel music (invalid audio stream URL)" << llendl; - // clears the URL - gAudiop->startInternetStream(LLStringUtil::null); - } + optionally_start_music(music_url); } - else if (!gAudiop->getInternetStreamURL().empty()) + else { - llinfos << "Stopping parcel music (parcel stream URL is empty)" << llendl; - gAudiop->startInternetStream(LLStringUtil::null); + llinfos << "Stopping parcel music (invalid audio stream URL)" << llendl; + // clears the URL + // null value causes fade out + LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLStringUtil::null); } } + else if (!gAudiop->getInternetStreamURL().empty()) + { + llinfos << "Stopping parcel music (parcel stream URL is empty)" << llendl; + // null value causes fade out + LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLStringUtil::null); + } } else { // Public land has no music - gAudiop->stopInternetStream(); + LLViewerAudio::getInstance()->stopInternetStreamWithAutoFade(); } }//if gAudiop - - // now check for video - LLViewerParcelMedia::update( parcel ); }; } @@ -1794,7 +1789,11 @@ void optionally_start_music(const std::string& music_url) gSavedSettings.getBOOL("MediaTentativeAutoPlay"))) { llinfos << "Starting parcel music " << music_url << llendl; - gAudiop->startInternetStream(music_url); + LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(music_url); + } + else + { + LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLStringUtil::null); } } } -- cgit v1.2.3 From 5663f41a7a3dafb4650b49ebc0c86140136239cd Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Fri, 28 Oct 2011 17:54:42 -0400 Subject: STORM-591 Fix minor merge error regression --- indra/newview/llviewermedia.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 148bfbf080..a85f70b599 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1499,7 +1499,8 @@ void LLViewerMedia::setOpenIDCookie() new LLViewerMediaWebProfileResponder(raw_profile_url.getAuthority()), headers); - doOnetimeEarlyHTTPRequests(); + // FUI: No longer perform the user_status query + //doOnetimeEarlyHTTPRequests(); } } -- cgit v1.2.3 From 526f71053a9fb18e95993343a0fd826023bda683 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Sat, 29 Oct 2011 05:01:23 -0400 Subject: STORM-591 Comment out debugging llinfos lines --- indra/newview/llvieweraudio.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp index 8fd1ca3807..10ba54356c 100644 --- a/indra/newview/llvieweraudio.cpp +++ b/indra/newview/llvieweraudio.cpp @@ -65,12 +65,12 @@ void LLViewerAudio::registerIdleListener() void LLViewerAudio::startInternetStreamWithAutoFade(std::string streamURI) { - llinfos << "DBG streamURI: " << streamURI << llendl; +/* llinfos << "DBG streamURI: " << streamURI << llendl; llinfos << "DBG mNextStreamURI: " << mNextStreamURI << llendl; if (mFadeState == FADE_OUT) {llinfos << "DBG mFadeState: FADE_OUT " << llendl;} if (mFadeState == FADE_IN) {llinfos << "DBG mFadeState: FADE_IN " << llendl;} if (mFadeState == FADE_IDLE) {llinfos << "DBG mFadeState: FADE_IDLE " << llendl;} - +*/ // Old and new stream are identical if (mNextStreamURI == streamURI) { @@ -86,13 +86,13 @@ void LLViewerAudio::startInternetStreamWithAutoFade(std::string streamURI) if (!gAudiop->getInternetStreamURL().empty()) { mFadeState = FADE_OUT; -llinfos << "DBG new mFadeState: OUT" << llendl; +//llinfos << "DBG new mFadeState: OUT" << llendl; } // Otherwise the new stream can be faded in else { mFadeState = FADE_IN; -llinfos << "DBG new mFadeState: IN" << llendl; +//llinfos << "DBG new mFadeState: IN" << llendl; gAudiop->startInternetStream(mNextStreamURI); startFading(); @@ -123,10 +123,10 @@ bool LLViewerAudio::onIdleUpdate() { if (mDone) { - if (mFadeState == FADE_OUT) {llinfos << "DBG mFadeState: FADE_OUT " << llendl;} +/* if (mFadeState == FADE_OUT) {llinfos << "DBG mFadeState: FADE_OUT " << llendl;} if (mFadeState == FADE_IN) {llinfos << "DBG mFadeState: FADE_IN " << llendl;} if (mFadeState == FADE_IDLE) {llinfos << "DBG mFadeState: FADE_IDLE " << llendl;} - +*/ // This should be a rare or never occurring state. if (mFadeState == FADE_IDLE) { @@ -144,7 +144,7 @@ bool LLViewerAudio::onIdleUpdate() if (!mNextStreamURI.empty()) { mFadeState = FADE_IN; -llinfos << "DBG new mFadeState: IN" << llendl; +//llinfos << "DBG new mFadeState: IN" << llendl; gAudiop->startInternetStream(mNextStreamURI); startFading(); return false; @@ -152,7 +152,7 @@ llinfos << "DBG new mFadeState: IN" << llendl; else { mFadeState = FADE_IDLE; -llinfos << "DBG new mFadeState: IDLE" << llendl; +//llinfos << "DBG new mFadeState: IDLE" << llendl; deregisterIdleListener(); return true; // Stop calling onIdleUpdate } @@ -164,12 +164,12 @@ llinfos << "DBG new mFadeState: IDLE" << llendl; mFadeState = FADE_OUT; startFading(); return false; -llinfos << "DBG new mFadeState: OUT" << llendl; +//llinfos << "DBG new mFadeState: OUT" << llendl; } else { mFadeState = FADE_IDLE; -llinfos << "DBG new mFadeState: IDLE" << llendl; +//llinfos << "DBG new mFadeState: IDLE" << llendl; deregisterIdleListener(); return true; // Stop calling onIdleUpdate } @@ -181,12 +181,12 @@ llinfos << "DBG new mFadeState: IDLE" << llendl; void LLViewerAudio::stopInternetStreamWithAutoFade() { -llinfos << "DBG stopping stream" << llendl; +//llinfos << "DBG stopping stream" << llendl; mFadeState = FADE_IDLE; -llinfos << "DBG new mFadeState: IDLE" << llendl; +//llinfos << "DBG new mFadeState: IDLE" << llendl; mNextStreamURI = LLStringUtil::null; mDone = true; -llinfos << "DBG mDone: true" << llendl; +//llinfos << "DBG mDone: true" << llendl; gAudiop->startInternetStream(LLStringUtil::null); gAudiop->stopInternetStream(); @@ -194,7 +194,7 @@ llinfos << "DBG mDone: true" << llendl; void LLViewerAudio::startFading() { -llinfos << "DBG startFading" << llendl; +//llinfos << "DBG startFading" << llendl; if(mDone) { @@ -208,7 +208,7 @@ llinfos << "DBG startFading" << llendl; stream_fade_timer.reset(); stream_fade_timer.setTimerExpirySec(mFadeTime); mDone = false; -llinfos << "DBG mDone: false" << llendl; +//llinfos << "DBG mDone: false" << llendl; } } @@ -349,7 +349,7 @@ void audio_update_volume(bool force_update) F32 music_volume = gSavedSettings.getF32("AudioLevelMusic"); BOOL music_muted = gSavedSettings.getBOOL("MuteMusic"); F32 fade_volume = LLViewerAudio::getInstance()->getFadeVolume(); -llinfos << "DBG fade_volume:" << fade_volume << llendl; +//llinfos << "DBG fade_volume:" << fade_volume << llendl; music_volume = mute_volume * master_volume * music_volume * fade_volume; gAudiop->setInternetStreamGain (music_muted ? 0.f : music_volume); -- cgit v1.2.3 From 3aaaae15034b1c0e3099662023bc90d5e447d1ac Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Tue, 8 Nov 2011 15:23:56 -0500 Subject: STORM-591 Audio fading Hopefully fix error in llvieweraudio.h that caused mac and linux compile failure --- indra/newview/llvieweraudio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llvieweraudio.h b/indra/newview/llvieweraudio.h index 316d7b32d2..1663f77f4a 100644 --- a/indra/newview/llvieweraudio.h +++ b/indra/newview/llvieweraudio.h @@ -59,7 +59,7 @@ public: void startInternetStreamWithAutoFade(std::string streamURI); void stopInternetStreamWithAutoFade(); - bool LLViewerAudio::onIdleUpdate(); + bool onIdleUpdate(); EFadeState getFadeState() { return mFadeState; } bool isDone() { return mDone; }; -- cgit v1.2.3 From 57b8da6b4926435f92f0a8568c6ac725774bbbd2 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Fri, 11 Nov 2011 12:22:48 -0500 Subject: STORM-591 Remove dead line of code to fix mac/linux compile error. --- indra/newview/llviewerparcelmgr.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index 928a84e7eb..ada89cc7aa 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -1741,8 +1741,6 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use std::string music_url = music_url_raw; LLStringUtil::trim(music_url); - const std::string& stream_url = gAudiop->getInternetStreamURL(); - // If there is a new music URL and it's valid, play it. if (music_url.size() > 12) { -- cgit v1.2.3 From cc1fb7bcac2924674763d917f66d84fbadb11623 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 17 Nov 2011 08:06:31 -0500 Subject: LLSD-14: Bring over llsd.{h,cpp} enhancements from server-trunk. Because new enum values have been added to the LLSD type field, a few external switch statements must be adjusted to suppress fatal warnings, even though we never expect to encounter an LLSD instance containing any of the new values. --- indra/llcommon/llsd.cpp | 194 ++++++++++++++++++++++++++++------ indra/llcommon/llsd.h | 82 +++++++++++++- indra/llmessage/llsdmessagereader.cpp | 1 + indra/test/lltut.cpp | 5 + 4 files changed, 248 insertions(+), 34 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index 6ca0737445..862b6b5ebc 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -31,6 +31,7 @@ #include "../llmath/llmath.h" #include "llformat.h" #include "llsdserialize.h" +#include "stringize.h" #ifndef LL_RELEASE_FOR_DOWNLOAD #define NAME_UNNAMED_NAMESPACE @@ -50,6 +51,24 @@ namespace using namespace LLSDUnnamedNamespace; #endif + +// Normally undefined +#ifdef LLSD_DEBUG_INFO + +// statics +S32 LLSD::sLLSDAllocationCount = 0; +S32 LLSD::sLLSDNetObjects = 0; + +#define ALLOC_LLSD_OBJECT { sLLSDNetObjects++; sLLSDAllocationCount++; } +#define FREE_LLSD_OBJECT { sLLSDNetObjects--; } + +#else + +#define ALLOC_LLSD_OBJECT +#define FREE_LLSD_OBJECT + +#endif + class LLSD::Impl /**< This class is the abstract base class of the implementation of LLSD It provides the reference counting implementation, and the default @@ -58,13 +77,10 @@ class LLSD::Impl */ { -private: - U32 mUseCount; - protected: Impl(); - enum StaticAllocationMarker { STATIC }; + enum StaticAllocationMarker { STATIC_USAGE_COUNT = 0xFFFFFFFF }; Impl(StaticAllocationMarker); ///< This constructor is used for static objects and causes the // suppresses adjusting the debugging counters when they are @@ -72,7 +88,9 @@ protected: virtual ~Impl(); - bool shared() const { return mUseCount > 1; } + bool shared() const { return (mUseCount > 1) && (mUseCount != STATIC_USAGE_COUNT); } + + U32 mUseCount; public: static void reset(Impl*& var, Impl* impl); @@ -128,6 +146,9 @@ public: virtual LLSD::array_const_iterator beginArray() const { return endArray(); } virtual LLSD::array_const_iterator endArray() const { static const std::vector empty; return empty.end(); } + virtual void dumpStats() const; + virtual void calcStats(S32 type_counts[], S32 share_counts[]) const; + static const LLSD& undef(); static U32 sAllocationCount; @@ -360,6 +381,9 @@ namespace LLSD::map_iterator endMap() { return mData.end(); } virtual LLSD::map_const_iterator beginMap() const { return mData.begin(); } virtual LLSD::map_const_iterator endMap() const { return mData.end(); } + + virtual void dumpStats() const; + virtual void calcStats(S32 type_counts[], S32 share_counts[]) const; }; ImplMap& ImplMap::makeMap(LLSD::Impl*& var) @@ -414,6 +438,36 @@ namespace return i->second; } + void ImplMap::dumpStats() const + { + std::cout << "Map size: " << mData.size() << std::endl; + + #ifdef LLSD_DEBUG_INFO + std::cout << "LLSD Net Objects: " << LLSD::sLLSDNetObjects << std::endl; + std::cout << "LLSD allocations: " << LLSD::sLLSDAllocationCount << std::endl; + #endif + + std::cout << "LLSD::Impl Net Objects: " << sOutstandingCount << std::endl; + std::cout << "LLSD::Impl allocations: " << sAllocationCount << std::endl; + + Impl::dumpStats(); + } + + void ImplMap::calcStats(S32 type_counts[], S32 share_counts[]) const + { + LLSD::map_const_iterator iter = beginMap(); + while (iter != endMap()) + { + //std::cout << " " << (*iter).first << ": " << (*iter).second << std::endl; + (*iter).second.calcStats(type_counts, share_counts); + iter++; + } + + // Add in the values for this map + Impl::calcStats(type_counts, share_counts); + } + + class ImplArray : public LLSD::Impl { private: @@ -449,6 +503,8 @@ namespace LLSD::array_iterator endArray() { return mData.end(); } virtual LLSD::array_const_iterator beginArray() const { return mData.begin(); } virtual LLSD::array_const_iterator endArray() const { return mData.end(); } + + virtual void calcStats(S32 type_counts[], S32 share_counts[]) const; }; ImplArray& ImplArray::makeArray(Impl*& var) @@ -490,12 +546,13 @@ namespace void ImplArray::insert(LLSD::Integer i, const LLSD& v) { - if (i < 0) { + if (i < 0) + { return; } DataVector::size_type index = i; - if (index >= mData.size()) + if (index >= mData.size()) // tbd - sanity check limit for index ? { mData.resize(index + 1); } @@ -543,6 +600,19 @@ namespace return mData[index]; } + + void ImplArray::calcStats(S32 type_counts[], S32 share_counts[]) const + { + LLSD::array_const_iterator iter = beginArray(); + while (iter != endArray()) + { // Add values for all items held in the array + (*iter).calcStats(type_counts, share_counts); + iter++; + } + + // Add in the values for this array + Impl::calcStats(type_counts, share_counts); + } } LLSD::Impl::Impl() @@ -564,8 +634,11 @@ LLSD::Impl::~Impl() void LLSD::Impl::reset(Impl*& var, Impl* impl) { - if (impl) ++impl->mUseCount; - if (var && --var->mUseCount == 0) + if (impl && impl->mUseCount != STATIC_USAGE_COUNT) + { + ++impl->mUseCount; + } + if (var && var->mUseCount != STATIC_USAGE_COUNT && --var->mUseCount == 0) { delete var; } @@ -574,13 +647,13 @@ void LLSD::Impl::reset(Impl*& var, Impl* impl) LLSD::Impl& LLSD::Impl::safe(Impl* impl) { - static Impl theUndefined(STATIC); + static Impl theUndefined(STATIC_USAGE_COUNT); return impl ? *impl : theUndefined; } const LLSD::Impl& LLSD::Impl::safe(const Impl* impl) { - static Impl theUndefined(STATIC); + static Impl theUndefined(STATIC_USAGE_COUNT); return impl ? *impl : theUndefined; } @@ -656,6 +729,39 @@ const LLSD& LLSD::Impl::undef() return immutableUndefined; } +void LLSD::Impl::dumpStats() const +{ + S32 type_counts[LLSD::TypeLLSDNumTypes + 1]; + memset(&type_counts, 0, LLSD::TypeLLSDNumTypes * sizeof(S32)); + + S32 share_counts[LLSD::TypeLLSDNumTypes + 1]; + memset(&share_counts, 0, LLSD::TypeLLSDNumTypes * sizeof(S32)); + + // Add info from all the values this object has + calcStats(type_counts, share_counts); + + S32 type_index = LLSD::TypeLLSDTypeBegin; + while (type_index != LLSD::TypeLLSDTypeEnd) + { + std::cout << LLSD::typeString((LLSD::Type)type_index) << " type " + << type_counts[type_index] << " objects, " + << share_counts[type_index] << " shared" + << std::endl; + type_index++; + } +} + + +void LLSD::Impl::calcStats(S32 type_counts[], S32 share_counts[]) const +{ + type_counts[(S32) type()]++; + if (shared()) + { + share_counts[(S32) type()]++; + } +} + + U32 LLSD::Impl::sAllocationCount = 0; U32 LLSD::Impl::sOutstandingCount = 0; @@ -681,10 +787,10 @@ namespace } -LLSD::LLSD() : impl(0) { } -LLSD::~LLSD() { Impl::reset(impl, 0); } +LLSD::LLSD() : impl(0) { ALLOC_LLSD_OBJECT; } +LLSD::~LLSD() { FREE_LLSD_OBJECT; Impl::reset(impl, 0); } -LLSD::LLSD(const LLSD& other) : impl(0) { assign(other); } +LLSD::LLSD(const LLSD& other) : impl(0) { ALLOC_LLSD_OBJECT; assign(other); } void LLSD::assign(const LLSD& other) { Impl::assign(impl, other.impl); } @@ -693,17 +799,17 @@ void LLSD::clear() { Impl::assignUndefined(impl); } LLSD::Type LLSD::type() const { return safe(impl).type(); } // Scaler Constructors -LLSD::LLSD(Boolean v) : impl(0) { assign(v); } -LLSD::LLSD(Integer v) : impl(0) { assign(v); } -LLSD::LLSD(Real v) : impl(0) { assign(v); } -LLSD::LLSD(const UUID& v) : impl(0) { assign(v); } -LLSD::LLSD(const String& v) : impl(0) { assign(v); } -LLSD::LLSD(const Date& v) : impl(0) { assign(v); } -LLSD::LLSD(const URI& v) : impl(0) { assign(v); } -LLSD::LLSD(const Binary& v) : impl(0) { assign(v); } +LLSD::LLSD(Boolean v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } +LLSD::LLSD(Integer v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } +LLSD::LLSD(Real v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } +LLSD::LLSD(const UUID& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } +LLSD::LLSD(const String& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } +LLSD::LLSD(const Date& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } +LLSD::LLSD(const URI& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } +LLSD::LLSD(const Binary& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } // Convenience Constructors -LLSD::LLSD(F32 v) : impl(0) { assign((Real)v); } +LLSD::LLSD(F32 v) : impl(0) { ALLOC_LLSD_OBJECT; assign((Real)v); } // Scalar Assignment void LLSD::assign(Boolean v) { safe(impl).assign(impl, v); } @@ -726,7 +832,7 @@ LLSD::URI LLSD::asURI() const { return safe(impl).asURI(); } LLSD::Binary LLSD::asBinary() const { return safe(impl).asBinary(); } // const char * helpers -LLSD::LLSD(const char* v) : impl(0) { assign(v); } +LLSD::LLSD(const char* v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } void LLSD::assign(const char* v) { if(v) assign(std::string(v)); @@ -801,15 +907,9 @@ static const char *llsd_dump(const LLSD &llsd, bool useXMLFormat) { std::ostringstream out; if (useXMLFormat) - { - LLSDXMLStreamer xml_streamer(llsd); - out << xml_streamer; - } + out << LLSDXMLStreamer(llsd); else - { - LLSDNotationStreamer notation_streamer(llsd); - out << notation_streamer; - } + out << LLSDNotationStreamer(llsd); out_string = out.str(); } int len = out_string.length(); @@ -840,3 +940,33 @@ LLSD::array_iterator LLSD::beginArray() { return makeArray(impl).beginArray(); LLSD::array_iterator LLSD::endArray() { return makeArray(impl).endArray(); } LLSD::array_const_iterator LLSD::beginArray() const{ return safe(impl).beginArray(); } LLSD::array_const_iterator LLSD::endArray() const { return safe(impl).endArray(); } + + +// Diagnostic dump of contents in an LLSD object +void LLSD::dumpStats() const { safe(impl).dumpStats(); } +void LLSD::calcStats(S32 type_counts[], S32 share_counts[]) const + { safe(impl).calcStats(type_counts, share_counts); } + +// static +std::string LLSD::typeString(Type type) +{ + static const char * sTypeNameArray[] = { + "Undefined", + "Boolean", + "Integer", + "Real", + "String", + "UUID", + "Date", + "URI", + "Binary", + "Map", + "Array" + }; + + if (0 <= type < (sizeof(sTypeNameArray)/sizeof(sTypeNameArray[0]))) + { + return sTypeNameArray[type]; + } + return STRINGIZE("** invalid type value " << type); +} diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 90d0f97873..1ffa1d279b 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -80,9 +80,73 @@ An array is a sequence of zero or more LLSD values. + Thread Safety + + In general, these LLSD classes offer *less* safety than STL container + classes. Implementations prior to this one were unsafe even when + completely unrelated LLSD trees were in two threads due to reference + sharing of special 'undefined' values that participated in the reference + counting mechanism. + + The dereference-before-refcount and aggressive tree sharing also make + it impractical to share an LLSD across threads. A strategy of passing + ownership or a copy to another thread is still difficult due to a lack + of a cloning interface but it can be done with some care. + + One way of transferring ownership is as follows: + + void method(const LLSD input) { + ... + LLSD * xfer_tree = new LLSD(); + { + // Top-level values + (* xfer_tree)['label'] = "Some text"; + (* xfer_tree)['mode'] = APP_MODE_CONSTANT; + + // There will be a second-level + LLSD subtree(LLSD::emptyMap()); + (* xfer_tree)['subtree'] = subtree; + + // Do *not* copy from LLSD objects via LLSD + // intermediaries. Only use plain-old-data + // types as intermediaries to prevent reference + // sharing. + subtree['value1'] = input['value1'].asInteger(); + subtree['value2'] = input['value2'].asString(); + + // Close scope and drop 'subtree's reference. + // Only xfer_tree has a reference to the second + // level data. + } + ... + // Transfer the LLSD pointer to another thread. Ownership + // transfers, this thread no longer has a reference to any + // part of the xfer_tree and there's nothing to free or + // release here. Receiving thread does need to delete the + // pointer when it is done with the LLSD. Transfer + // mechanism must perform correct data ordering operations + // as dictated by architecture. + other_thread.sendMessageAndPointer("Take This", xfer_tree); + xfer_tree = NULL; + + + Avoid this pattern which provides half of a race condition: + + void method(const LLSD input) { + ... + LLSD xfer_tree(LLSD::emptyMap()); + xfer_tree['label'] = "Some text"; + xfer_tree['mode'] = APP_MODE_CONSTANT; + ... + other_thread.sendMessageAndPointer("Take This", xfer_tree); + + @nosubgrouping */ +// Normally undefined, used for diagnostics +//#define LLSD_DEBUG_INFO 1 + class LL_COMMON_API LLSD { public: @@ -266,7 +330,7 @@ public: /** @name Type Testing */ //@{ enum Type { - TypeUndefined, + TypeUndefined = 0, TypeBoolean, TypeInteger, TypeReal, @@ -276,7 +340,10 @@ public: TypeURI, TypeBinary, TypeMap, - TypeArray + TypeArray, + TypeLLSDTypeEnd, + TypeLLSDTypeBegin = TypeUndefined, + TypeLLSDNumTypes = (TypeLLSDTypeEnd - TypeLLSDTypeBegin) }; Type type() const; @@ -338,6 +405,17 @@ private: /// Returns Notation version of llsd -- only to be called from debugger static const char *dump(const LLSD &llsd); //@} + +public: + void dumpStats() const; // Output information on object and usage + void calcStats(S32 type_counts[], S32 share_counts[]) const; // Calculate the number of LLSD objects used by this value + + static std::string typeString(Type type); // Return human-readable type as a string + +#ifdef LLSD_DEBUG_INFO + static S32 sLLSDAllocationCount; // Number of LLSD objects ever created + static S32 sLLSDNetObjects; // Number of LLSD objects that exist +#endif }; struct llsd_select_bool : public std::unary_function diff --git a/indra/llmessage/llsdmessagereader.cpp b/indra/llmessage/llsdmessagereader.cpp index 304a692cdf..3ab62a8c57 100644 --- a/indra/llmessage/llsdmessagereader.cpp +++ b/indra/llmessage/llsdmessagereader.cpp @@ -291,6 +291,7 @@ S32 getElementSize(const LLSD& llsd) case LLSD::TypeMap: case LLSD::TypeArray: case LLSD::TypeUndefined: + default: // TypeLLSDTypeEnd, TypeLLSDNumTypes, etc. return 0; } return 0; diff --git a/indra/test/lltut.cpp b/indra/test/lltut.cpp index da7031b52a..c43a8f0c7d 100644 --- a/indra/test/lltut.cpp +++ b/indra/test/lltut.cpp @@ -34,6 +34,7 @@ #include "llformat.h" #include "llsd.h" #include "lluri.h" +#include "stringize.h" namespace tut { @@ -144,6 +145,10 @@ namespace tut } return; } + default: + // should never get here, but compiler produces warning if we + // don't cover this case, and at Linden warnings are fatal. + throw failure(STRINGIZE("invalid type field " << actual.type())); } } -- cgit v1.2.3 From e62c691aab36b50d3eecb99310d5652d0b8e6f23 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 17 Nov 2011 10:02:05 -0500 Subject: LLSD-14: Fix silly syntax error in subscript bounds check. --- indra/llcommon/llsd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index 862b6b5ebc..b0801745d7 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -964,7 +964,7 @@ std::string LLSD::typeString(Type type) "Array" }; - if (0 <= type < (sizeof(sTypeNameArray)/sizeof(sTypeNameArray[0]))) + if (0 <= type && type < (sizeof(sTypeNameArray)/sizeof(sTypeNameArray[0]))) { return sTypeNameArray[type]; } -- cgit v1.2.3 From b0d869554b902c30f8a874b1e772a0241acf9f1f Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 17 Nov 2011 11:10:39 -0500 Subject: LLSD-14: Add tests from Simon's server-trunk changeset 3852648182db. That changeset provides most of the changes previously checked in on this Jira (viewer changeset 22b293aae639). Bring over the code he added to llsd_new_tut.cpp as well. --- indra/test/llsd_new_tut.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'indra') diff --git a/indra/test/llsd_new_tut.cpp b/indra/test/llsd_new_tut.cpp index dd93b36f04..f332ad0ee2 100644 --- a/indra/test/llsd_new_tut.cpp +++ b/indra/test/llsd_new_tut.cpp @@ -742,6 +742,42 @@ namespace tut LLSD w = v; w = "nice day"; } + + { + SDAllocationCheck check("shared values test for threaded work", 9); + + //U32 start_llsd_count = LLSD::outstandingCount(); + + LLSD m = LLSD::emptyMap(); + + m["one"] = 1; + m["two"] = 2; + m["one_copy"] = m["one"]; // 3 (m, "one" and "two") + + m["undef_one"] = LLSD(); + m["undef_two"] = LLSD(); + m["undef_one_copy"] = m["undef_one"]; + + { // Ensure first_array gets freed to avoid counting it + LLSD first_array = LLSD::emptyArray(); + first_array.append(1.0f); + first_array.append(2.0f); + first_array.append(3.0f); // 7 + + m["array"] = first_array; + m["array_clone"] = first_array; + m["array_copy"] = m["array"]; // 7 + } + + m["string_one"] = "string one value"; + m["string_two"] = "string two value"; + m["string_one_copy"] = m["string_one"]; // 9 + + //U32 llsd_object_count = LLSD::outstandingCount(); + //std::cout << "Using " << (llsd_object_count - start_llsd_count) << " LLSD objects" << std::endl; + + //m.dumpStats(); + } } template<> template<> -- cgit v1.2.3 From 570ac04e167c97553a03f283ee0683cc4648601c Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 17 Nov 2011 11:54:13 -0500 Subject: LLSD-14: while we're in llsd.h anyway, fix longstanding misspellings. My tollerance is at an end. :-P --- indra/llcommon/llsd.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 1ffa1d279b..80c3e9e7b5 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -40,10 +40,10 @@ /** LLSD provides a flexible data system similar to the data facilities of dynamic languages like Perl and Python. It is created to support exchange - of structured data between loosly coupled systems. (Here, "loosly coupled" + of structured data between loosely coupled systems. (Here, "loosely coupled" means not compiled together into the same module.) - Data in such exchanges must be highly tollerant of changes on either side + Data in such exchanges must be highly tolerant of changes on either side such as: - recompilation - implementation in a different langauge @@ -51,19 +51,19 @@ - execution of older versions (with fewer parameters) To this aim, the C++ API of LLSD strives to be very easy to use, and to - default to "the right thing" whereever possible. It is extremely tollerant + default to "the right thing" wherever possible. It is extremely tolerant of errors and unexpected situations. - The fundimental class is LLSD. LLSD is a value holding object. It holds + The fundamental class is LLSD. LLSD is a value holding object. It holds one value that is either undefined, one of the scalar types, or a map or an array. LLSD objects have value semantics (copying them copies the value, - though it can be considered efficient, due to shareing.), and mutable. + though it can be considered efficient, due to sharing), and mutable. Undefined is the singular value given to LLSD objects that are not initialized with any data. It is also used as the return value for - operations that return an LLSD, + operations that return an LLSD. - The sclar data types are: + The scalar data types are: - Boolean - true or false - Integer - a 32 bit signed integer - Real - a 64 IEEE 754 floating point value @@ -266,7 +266,7 @@ public: //@} /** @name Character Pointer Helpers - These are helper routines to make working with char* the same as easy as + These are helper routines to make working with char* as easy as working with strings. */ //@{ @@ -369,7 +369,7 @@ public: If you get a linker error about these being missing, you have made mistake in your code. DO NOT IMPLEMENT THESE FUNCTIONS as a fix. - All of thse problems stem from trying to support char* in LLSD or in + All of these problems stem from trying to support char* in LLSD or in std::string. There are too many automatic casts that will lead to using an arbitrary pointer or scalar type to std::string. */ @@ -378,7 +378,7 @@ public: void assign(const void*); ///< assign from arbitrary pointers LLSD& operator=(const void*); ///< assign from arbitrary pointers - bool has(Integer) const; ///< has only works for Maps + bool has(Integer) const; ///< has() only works for Maps //@} /** @name Implementation */ @@ -464,8 +464,8 @@ struct llsd_select_string : public std::unary_function LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLSD& llsd); /** QUESTIONS & TO DOS - - Would Binary be more convenient as usigned char* buffer semantics? - - Should Binary be convertable to/from String, and if so how? + - Would Binary be more convenient as unsigned char* buffer semantics? + - Should Binary be convertible to/from String, and if so how? - as UTF8 encoded strings (making not like UUID<->String) - as Base64 or Base96 encoded (making like UUID<->String) - Conversions to std::string and LLUUID do not result in easy assignment -- cgit v1.2.3 From bd5b1ed713506d365793c7f9cb49d506ce392e7a Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 17 Nov 2011 13:55:11 -0500 Subject: LLSD-14: Make dumpStats()/calcStats() implementation more robust per Monty code review --- indra/llcommon/llsd.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index b0801745d7..39d1f3e35f 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -732,10 +732,10 @@ const LLSD& LLSD::Impl::undef() void LLSD::Impl::dumpStats() const { S32 type_counts[LLSD::TypeLLSDNumTypes + 1]; - memset(&type_counts, 0, LLSD::TypeLLSDNumTypes * sizeof(S32)); + memset(&type_counts, 0, sizeof(type_counts)); S32 share_counts[LLSD::TypeLLSDNumTypes + 1]; - memset(&share_counts, 0, LLSD::TypeLLSDNumTypes * sizeof(S32)); + memset(&share_counts, 0, sizeof(share_counts)); // Add info from all the values this object has calcStats(type_counts, share_counts); @@ -753,11 +753,15 @@ void LLSD::Impl::dumpStats() const void LLSD::Impl::calcStats(S32 type_counts[], S32 share_counts[]) const -{ - type_counts[(S32) type()]++; - if (shared()) +{ + S32 type = S32(type()); + if (0 <= type && type < LLSD::TypeLLSDNumTypes) { - share_counts[(S32) type()]++; + type_counts[type]++; + if (shared()) + { + share_counts[type]++; + } } } -- cgit v1.2.3 From b49c934bd913c0973630abf32ea566eefa1aa973 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 17 Nov 2011 15:03:25 -0500 Subject: LLSD-14: fixed way-too-overloaded local variable. --- indra/llcommon/llsd.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index 39d1f3e35f..3fa08aee8d 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -754,13 +754,13 @@ void LLSD::Impl::dumpStats() const void LLSD::Impl::calcStats(S32 type_counts[], S32 share_counts[]) const { - S32 type = S32(type()); - if (0 <= type && type < LLSD::TypeLLSDNumTypes) + S32 tp = S32(type()); + if (0 <= tp && tp < LLSD::TypeLLSDNumTypes) { - type_counts[type]++; + type_counts[tp]++; if (shared()) { - share_counts[type]++; + share_counts[tp]++; } } } -- cgit v1.2.3 From ed596077c4eb5b1ba6be4a71824ef220c086d436 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Fri, 18 Nov 2011 09:47:55 -0500 Subject: STORM-591 Removed commented out debugging lines --- indra/newview/llvieweraudio.cpp | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp index 10ba54356c..0262da4dee 100644 --- a/indra/newview/llvieweraudio.cpp +++ b/indra/newview/llvieweraudio.cpp @@ -65,12 +65,6 @@ void LLViewerAudio::registerIdleListener() void LLViewerAudio::startInternetStreamWithAutoFade(std::string streamURI) { -/* llinfos << "DBG streamURI: " << streamURI << llendl; - llinfos << "DBG mNextStreamURI: " << mNextStreamURI << llendl; - if (mFadeState == FADE_OUT) {llinfos << "DBG mFadeState: FADE_OUT " << llendl;} - if (mFadeState == FADE_IN) {llinfos << "DBG mFadeState: FADE_IN " << llendl;} - if (mFadeState == FADE_IDLE) {llinfos << "DBG mFadeState: FADE_IDLE " << llendl;} -*/ // Old and new stream are identical if (mNextStreamURI == streamURI) { @@ -86,14 +80,11 @@ void LLViewerAudio::startInternetStreamWithAutoFade(std::string streamURI) if (!gAudiop->getInternetStreamURL().empty()) { mFadeState = FADE_OUT; -//llinfos << "DBG new mFadeState: OUT" << llendl; } // Otherwise the new stream can be faded in else { mFadeState = FADE_IN; -//llinfos << "DBG new mFadeState: IN" << llendl; - gAudiop->startInternetStream(mNextStreamURI); startFading(); registerIdleListener(); @@ -123,10 +114,6 @@ bool LLViewerAudio::onIdleUpdate() { if (mDone) { -/* if (mFadeState == FADE_OUT) {llinfos << "DBG mFadeState: FADE_OUT " << llendl;} - if (mFadeState == FADE_IN) {llinfos << "DBG mFadeState: FADE_IN " << llendl;} - if (mFadeState == FADE_IDLE) {llinfos << "DBG mFadeState: FADE_IDLE " << llendl;} -*/ // This should be a rare or never occurring state. if (mFadeState == FADE_IDLE) { @@ -144,7 +131,6 @@ bool LLViewerAudio::onIdleUpdate() if (!mNextStreamURI.empty()) { mFadeState = FADE_IN; -//llinfos << "DBG new mFadeState: IN" << llendl; gAudiop->startInternetStream(mNextStreamURI); startFading(); return false; @@ -152,7 +138,6 @@ bool LLViewerAudio::onIdleUpdate() else { mFadeState = FADE_IDLE; -//llinfos << "DBG new mFadeState: IDLE" << llendl; deregisterIdleListener(); return true; // Stop calling onIdleUpdate } @@ -164,12 +149,10 @@ bool LLViewerAudio::onIdleUpdate() mFadeState = FADE_OUT; startFading(); return false; -//llinfos << "DBG new mFadeState: OUT" << llendl; } else { mFadeState = FADE_IDLE; -//llinfos << "DBG new mFadeState: IDLE" << llendl; deregisterIdleListener(); return true; // Stop calling onIdleUpdate } @@ -181,12 +164,9 @@ bool LLViewerAudio::onIdleUpdate() void LLViewerAudio::stopInternetStreamWithAutoFade() { -//llinfos << "DBG stopping stream" << llendl; mFadeState = FADE_IDLE; -//llinfos << "DBG new mFadeState: IDLE" << llendl; mNextStreamURI = LLStringUtil::null; mDone = true; -//llinfos << "DBG mDone: true" << llendl; gAudiop->startInternetStream(LLStringUtil::null); gAudiop->stopInternetStream(); @@ -194,8 +174,6 @@ void LLViewerAudio::stopInternetStreamWithAutoFade() void LLViewerAudio::startFading() { -//llinfos << "DBG startFading" << llendl; - if(mDone) { // The fade state here should only be one of FADE_IN or FADE_OUT, but, in case it is not, @@ -208,7 +186,6 @@ void LLViewerAudio::startFading() stream_fade_timer.reset(); stream_fade_timer.setTimerExpirySec(mFadeTime); mDone = false; -//llinfos << "DBG mDone: false" << llendl; } } @@ -349,7 +326,6 @@ void audio_update_volume(bool force_update) F32 music_volume = gSavedSettings.getF32("AudioLevelMusic"); BOOL music_muted = gSavedSettings.getBOOL("MuteMusic"); F32 fade_volume = LLViewerAudio::getInstance()->getFadeVolume(); -//llinfos << "DBG fade_volume:" << fade_volume << llendl; music_volume = mute_volume * master_volume * music_volume * fade_volume; gAudiop->setInternetStreamGain (music_muted ? 0.f : music_volume); -- cgit v1.2.3 From e97fb23218734d1fbda87eedd7659235777a69ae Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sat, 19 Nov 2011 10:02:20 -0500 Subject: Make LLSD diagnostic methods conditional on LLSD_DEBUG_INFO. This establishes that there are no viewer-side unit tests relying on these methods. The point is to try to clean up the LLSD public API. In the same vein, remove from LLSD public API a diagnostic method which is nothing more than an implementation detail for the corresponding LLSD::Impl method. The same effect can be achieved by making LLSD::Impl a friend of LLSD, moving the method with the messy signature (classic-C arrays!) into LLSD::Impl itself. --- indra/llcommon/llsd.cpp | 19 ++++++++++++++----- indra/llcommon/llsd.h | 14 +++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index 3fa08aee8d..1bd5d06d29 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -148,6 +148,13 @@ public: virtual void dumpStats() const; virtual void calcStats(S32 type_counts[], S32 share_counts[]) const; + // Container subclasses contain LLSD objects, rather than directly + // containing Impl objects. This helper forwards through LLSD. + void calcStats(const LLSD& llsd, S32 type_counts[], S32 share_counts[]) const + { + safe(llsd.impl).calcStats(type_counts, share_counts); + } + static const LLSD& undef(); @@ -459,7 +466,7 @@ namespace while (iter != endMap()) { //std::cout << " " << (*iter).first << ": " << (*iter).second << std::endl; - (*iter).second.calcStats(type_counts, share_counts); + Impl::calcStats((*iter).second, type_counts, share_counts); iter++; } @@ -606,7 +613,7 @@ namespace LLSD::array_const_iterator iter = beginArray(); while (iter != endArray()) { // Add values for all items held in the array - (*iter).calcStats(type_counts, share_counts); + Impl::calcStats((*iter), type_counts, share_counts); iter++; } @@ -802,7 +809,7 @@ void LLSD::clear() { Impl::assignUndefined(impl); } LLSD::Type LLSD::type() const { return safe(impl).type(); } -// Scaler Constructors +// Scalar Constructors LLSD::LLSD(Boolean v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } LLSD::LLSD(Integer v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } LLSD::LLSD(Real v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } @@ -894,8 +901,10 @@ LLSD& LLSD::operator[](Integer i) const LLSD& LLSD::operator[](Integer i) const { return safe(impl).ref(i); } +#ifdef LLSD_DEBUG_INFO U32 LLSD::allocationCount() { return Impl::sAllocationCount; } U32 LLSD::outstandingCount() { return Impl::sOutstandingCount; } +#endif static const char *llsd_dump(const LLSD &llsd, bool useXMLFormat) { @@ -947,9 +956,9 @@ LLSD::array_const_iterator LLSD::endArray() const { return safe(impl).endArray() // Diagnostic dump of contents in an LLSD object +#ifdef LLSD_DEBUG_INFO void LLSD::dumpStats() const { safe(impl).dumpStats(); } -void LLSD::calcStats(S32 type_counts[], S32 share_counts[]) const - { safe(impl).calcStats(type_counts, share_counts); } +#endif // static std::string LLSD::typeString(Type type) diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 80c3e9e7b5..3519b134c2 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -387,13 +387,20 @@ public: class Impl; private: Impl* impl; + friend class LLSD::Impl; //@} /** @name Unit Testing Interface */ //@{ public: +#ifdef LLSD_DEBUG_INFO + /// @warn THESE COUNTS WILL NOT BE ACCURATE IN A MULTI-THREADED + /// ENVIRONMENT. + /// + /// These counts track LLSD::Impl (hidden) objects. static U32 allocationCount(); ///< how many Impls have been made static U32 outstandingCount(); ///< how many Impls are still alive +#endif //@} private: @@ -407,12 +414,17 @@ private: //@} public: +#ifdef LLSD_DEBUG_INFO void dumpStats() const; // Output information on object and usage - void calcStats(S32 type_counts[], S32 share_counts[]) const; // Calculate the number of LLSD objects used by this value +#endif static std::string typeString(Type type); // Return human-readable type as a string #ifdef LLSD_DEBUG_INFO + /// @warn THESE COUNTS WILL NOT BE ACCURATE IN A MULTI-THREADED + /// ENVIRONMENT. + /// + /// These counts track LLSD (public) objects. static S32 sLLSDAllocationCount; // Number of LLSD objects ever created static S32 sLLSDNetObjects; // Number of LLSD objects that exist #endif -- cgit v1.2.3 From 2b43a6b8c9b22d02373ac70193fa85f2bfb77b19 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Tue, 22 Nov 2011 13:13:51 -0500 Subject: STORM-591 Remove 2 development debug settings and replace them with constants --- indra/newview/app_settings/settings.xml | 22 ---------------------- indra/newview/llvieweraudio.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 24 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index c7300cc1bb..3c53a9d44c 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -192,28 +192,6 @@ Value 1 - AudioMusicFadeIn - - Comment - Fade in time in seconds for music streams - Persist - 1 - Type - F32 - Value - 5.0 - - AudioMusicFadeOut - - Comment - Fade out time in seconds for music streams - Persist - 1 - Type - F32 - Value - 5.0 - AudioLevelAmbient Comment diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp index 0262da4dee..1e5c742cf9 100644 --- a/indra/newview/llvieweraudio.cpp +++ b/indra/newview/llvieweraudio.cpp @@ -174,14 +174,17 @@ void LLViewerAudio::stopInternetStreamWithAutoFade() void LLViewerAudio::startFading() { + const F32 AUDIO_MUSIC_FADE_IN_TIME = 3.0; + const F32 AUDIO_MUSIC_FADE_OUT_TIME = 2.0; + if(mDone) { // The fade state here should only be one of FADE_IN or FADE_OUT, but, in case it is not, // rather than check for both states assume a fade in and check for the fade out case. - mFadeTime = llmax(0.0f, gSavedSettings.getF32("AudioMusicFadeIn")); + mFadeTime = AUDIO_MUSIC_FADE_IN_TIME; if (LLViewerAudio::getInstance()->getFadeState() == LLViewerAudio::FADE_OUT) { - mFadeTime = llmax(0.0f, gSavedSettings.getF32("AudioMusicFadeOut")); + mFadeTime = AUDIO_MUSIC_FADE_OUT_TIME; } stream_fade_timer.reset(); stream_fade_timer.setTimerExpirySec(mFadeTime); -- cgit v1.2.3 From a4cb08ae5d20416e21bbc70540527097495af887 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Wed, 23 Nov 2011 08:42:42 -0500 Subject: STORM-591 Trivial code cleanup --- indra/newview/llvieweraudio.h | 1 - indra/newview/llviewerparcelmgr.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvieweraudio.h b/indra/newview/llvieweraudio.h index 1663f77f4a..26062a2818 100644 --- a/indra/newview/llvieweraudio.h +++ b/indra/newview/llvieweraudio.h @@ -28,7 +28,6 @@ #define LL_VIEWERAUDIO_H #include "llframetimer.h" -#include "llthread.h" #include "llsingleton.h" // comment out to turn off wind diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index ada89cc7aa..c18665a3c3 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -1727,7 +1727,7 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use else { // Check for video - LLViewerParcelMedia::update( parcel ); + LLViewerParcelMedia::update(parcel); // Then check for music. Do this last, as there may be a delay waiting for // the stream fading thread to finish. -- cgit v1.2.3 From 9ad8f46a6bb96a8352cf66beafa1c742a4bed5a9 Mon Sep 17 00:00:00 2001 From: eli Date: Tue, 29 Nov 2011 15:52:56 -0800 Subject: sync with viewer-development --- .../newview/skins/default/xui/en/floater_about.xml | 52 +++--- .../default/xui/en/floater_hardware_settings.xml | 2 +- .../skins/default/xui/en/floater_world_map.xml | 2 +- indra/newview/skins/default/xui/en/menu_viewer.xml | 21 +-- .../default/xui/en/panel_postcard_settings.xml | 163 +++++++++------- .../skins/default/xui/en/panel_snapshot_local.xml | 205 ++++++++++++--------- .../default/xui/en/panel_snapshot_profile.xml | 171 ++++++++++------- indra/newview/skins/minimal/colors.xml | 6 - .../newview/skins/minimal/textures/arrow_keys.png | Bin 6558 -> 0 bytes .../minimal/textures/bottomtray/Speak_Btn_Off.png | Bin 993 -> 0 bytes .../bottomtray/Speak_Btn_Selected_Press.png | Bin 1217 -> 0 bytes .../textures/bottomtray/button_separator.png | Bin 153 -> 0 bytes .../minimal/textures/bottomtray/close_off.png | Bin 3184 -> 0 bytes .../minimal/textures/bottomtray/close_over.png | Bin 3173 -> 0 bytes .../minimal/textures/bottomtray/close_press.png | Bin 3259 -> 0 bytes .../skins/minimal/textures/click_to_move.png | Bin 8188 -> 0 bytes indra/newview/skins/minimal/textures/textures.xml | 11 -- .../skins/minimal/xui/ru/menu_script_chiclet.xml | 4 - .../skins/minimal/xui/tr/menu_script_chiclet.xml | 4 - .../skins/minimal/xui/zh/menu_script_chiclet.xml | 4 - .../minimal/xui/zh_CN/menu_script_chiclet.xml | 4 - 21 files changed, 359 insertions(+), 290 deletions(-) delete mode 100644 indra/newview/skins/minimal/colors.xml delete mode 100644 indra/newview/skins/minimal/textures/arrow_keys.png delete mode 100644 indra/newview/skins/minimal/textures/bottomtray/Speak_Btn_Off.png delete mode 100644 indra/newview/skins/minimal/textures/bottomtray/Speak_Btn_Selected_Press.png delete mode 100644 indra/newview/skins/minimal/textures/bottomtray/button_separator.png delete mode 100644 indra/newview/skins/minimal/textures/bottomtray/close_off.png delete mode 100644 indra/newview/skins/minimal/textures/bottomtray/close_over.png delete mode 100644 indra/newview/skins/minimal/textures/bottomtray/close_press.png delete mode 100644 indra/newview/skins/minimal/textures/click_to_move.png delete mode 100644 indra/newview/skins/minimal/textures/textures.xml delete mode 100644 indra/newview/skins/minimal/xui/ru/menu_script_chiclet.xml delete mode 100644 indra/newview/skins/minimal/xui/tr/menu_script_chiclet.xml delete mode 100644 indra/newview/skins/minimal/xui/zh/menu_script_chiclet.xml delete mode 100644 indra/newview/skins/minimal/xui/zh_CN/menu_script_chiclet.xml (limited to 'indra') diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml index 36af475824..c7e9ec781d 100644 --- a/indra/newview/skins/default/xui/en/floater_about.xml +++ b/indra/newview/skins/default/xui/en/floater_about.xml @@ -196,34 +196,36 @@ Dummy Name replaced at run time top="5" width="435" word_wrap="true"> -3Dconnexion SDK Copyright (C) 1992-2007 3Dconnexion -APR Copyright (C) 2000-2004 The Apache Software Foundation -Collada DOM Copyright 2005 Sony Computer Entertainment Inc. -cURL Copyright (C) 1996-2002, Daniel Stenberg, (daniel@haxx.se) -DBus/dbus-glib Copyright (C) 2002, 2003 CodeFactory AB / Copyright (C) 2003, 2004 Red Hat, Inc. -expat Copyright (C) 1998, 1999, 2000 Thai Open Source Software Center Ltd. -FreeType Copyright (C) 1996-2002, The FreeType Project (www.freetype.org). -GL Copyright (C) 1999-2004 Brian Paul. -GLOD Copyright (C) 2003-04 Jonathan Cohen, Nat Duca, Chris Niski, Johns Hopkins University and David Luebke, Brenden Schubert, University of Virginia. -google-perftools Copyright (c) 2005, Google Inc. -Havok.com(TM) Copyright (C) 1999-2001, Telekinesys Research Limited. -jpeg2000 Copyright (C) 2001, David Taubman, The University of New South Wales (UNSW) -jpeglib Copyright (C) 1991-1998, Thomas G. Lane. -ogg/vorbis Copyright (C) 2001, Xiphophorus -OpenSSL Copyright (C) 1998-2002 The OpenSSL Project. -PCRE Copyright (c) 1997-2008 University of Cambridge -SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga -SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) -xmlrpc-epi Copyright (C) 2000 Epinions, Inc. -zlib Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler. -google-perftools Copyright (c) 2005, Google Inc. + 3Dconnexion SDK Copyright (C) 1992-2007 3Dconnexion + APR Copyright (C) 2000-2004 The Apache Software Foundation + Collada DOM Copyright 2005 Sony Computer Entertainment Inc. + cURL Copyright (C) 1996-2002, Daniel Stenberg, (daniel@haxx.se) + DBus/dbus-glib Copyright (C) 2002, 2003 CodeFactory AB / Copyright (C) 2003, 2004 Red Hat, Inc. + expat Copyright (C) 1998, 1999, 2000 Thai Open Source Software Center Ltd. + FreeType Copyright (C) 1996-2002, The FreeType Project (www.freetype.org). + GL Copyright (C) 1999-2004 Brian Paul. + GLOD Copyright (C) 2003-04 Jonathan Cohen, Nat Duca, Chris Niski, Johns Hopkins University and David Luebke, Brenden Schubert, University of Virginia. + google-perftools Copyright (c) 2005, Google Inc. + Havok.com(TM) Copyright (C) 1999-2001, Telekinesys Research Limited. + jpeg2000 Copyright (C) 2001, David Taubman, The University of New South Wales (UNSW) + jpeglib Copyright (C) 1991-1998, Thomas G. Lane. + ogg/vorbis Copyright (C) 2001, Xiphophorus + OpenSSL Copyright (C) 1998-2002 The OpenSSL Project. + PCRE Copyright (c) 1997-2008 University of Cambridge + SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga + SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + xmlrpc-epi Copyright (C) 2000 Epinions, Inc. + zlib Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler. + google-perftools Copyright (c) 2005, Google Inc. -Second Life Viewer uses Havok (TM) Physics. (c)Copyright 1999-2010 Havok.com Inc. (and its Licensors). All Rights Reserved. See www.havok.com for details. + Second Life Viewer uses Havok (TM) Physics. (c)Copyright 1999-2010 Havok.com Inc. (and its Licensors). All Rights Reserved. See www.havok.com for details. -All rights reserved. See licenses.txt for details. + This software contains source code provided by NVIDIA Corporation. -Voice chat Audio coding: Polycom(R) Siren14(TM) (ITU-T Rec. G.722.1 Annex C) - + All rights reserved. See licenses.txt for details. + + Voice chat Audio coding: Polycom(R) Siren14(TM) (ITU-T Rec. G.722.1 Annex C) + diff --git a/indra/newview/skins/default/xui/en/floater_hardware_settings.xml b/indra/newview/skins/default/xui/en/floater_hardware_settings.xml index 05f4c52b95..66bb9d3cea 100644 --- a/indra/newview/skins/default/xui/en/floater_hardware_settings.xml +++ b/indra/newview/skins/default/xui/en/floater_hardware_settings.xml @@ -35,7 +35,7 @@ height="12" layout="topleft" left="10" - name="Antialiasing:" + name="antialiasing label" top_pad="7" width="188"> Antialiasing: diff --git a/indra/newview/skins/default/xui/en/floater_world_map.xml b/indra/newview/skins/default/xui/en/floater_world_map.xml index 4314c8a9e2..56d79f62c7 100644 --- a/indra/newview/skins/default/xui/en/floater_world_map.xml +++ b/indra/newview/skins/default/xui/en/floater_world_map.xml @@ -468,7 +468,7 @@ left="3" top_pad="7" mouse_opaque="true" - name="region_icon" + name="location_icon" width="16" /> + + + + @@ -2569,19 +2577,6 @@ - - - - - - - - - - - - ([QLVL]) - + right="-10"> + + + + + + + + + ([QLVL]) + + + diff --git a/indra/newview/skins/default/xui/en/panel_snapshot_local.xml b/indra/newview/skins/default/xui/en/panel_snapshot_local.xml index 30403a21dd..ae0215a578 100644 --- a/indra/newview/skins/default/xui/en/panel_snapshot_local.xml +++ b/indra/newview/skins/default/xui/en/panel_snapshot_local.xml @@ -80,93 +80,128 @@ name="Custom" value="[i-1,i-1]" /> - - - - - - - - - - - ([QLVL]) - + right="-10"> + + + + + + + + + + + + + + ([QLVL]) + + +