From 70218d0ac267e46b8b60aecfe24dd4c4232ce7cc Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sat, 5 Apr 2014 15:23:15 +0200 Subject: [PATCH] FIRE-13385: Added option to separate cached sounds from default cache; Originally implemented by Skills Hak with permission to use under LGPL, rewritten for Firestorm --- indra/llaudio/llaudiodecodemgr.cpp | 5 +- indra/llaudio/llaudioengine.cpp | 10 +- indra/llvfs/lldir.cpp | 49 ++++++++- indra/llvfs/lldir.h | 16 ++- indra/newview/app_settings/settings.xml | 11 ++ indra/newview/fswsassetblacklist.cpp | 2 +- indra/newview/llappviewer.cpp | 17 ++- indra/newview/llfloaterpreference.cpp | 54 +++++++++ indra/newview/llfloaterpreference.h | 6 + .../skins/default/xui/de/notifications.xml | 3 + .../xui/de/panel_preferences_setup.xml | 10 +- .../skins/default/xui/en/notifications.xml | 7 ++ .../xui/en/panel_preferences_setup.xml | 103 +++++++++++++++--- 13 files changed, 265 insertions(+), 28 deletions(-) diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp index eb7bb6ec49..c4e21b38b5 100755 --- a/indra/llaudio/llaudiodecodemgr.cpp +++ b/indra/llaudio/llaudiodecodemgr.cpp @@ -640,7 +640,10 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs) timer.reset(); uuid.toString(uuid_str); - d_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + ".dsf"; + // Sound cache + //d_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + ".dsf"; + d_path = gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE,uuid_str) + ".dsf"; + // mCurrentDecodep = new LLVorbisDecodeState(uuid, d_path); if (!mCurrentDecodep->initDecode()) diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp index 39fccf87e1..329c476152 100755 --- a/indra/llaudio/llaudioengine.cpp +++ b/indra/llaudio/llaudioengine.cpp @@ -1015,7 +1015,10 @@ bool LLAudioEngine::hasDecodedFile(const LLUUID &uuid) uuid.toString(uuid_str); std::string wav_path; - wav_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str); + // Sound cache + //wav_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str); + wav_path = gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE,uuid_str); + // wav_path += ".dsf"; if (gDirUtilp->fileExists(wav_path)) @@ -1904,7 +1907,10 @@ bool LLAudioData::load() std::string uuid_str; std::string wav_path; mID.toString(uuid_str); - wav_path= gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + ".dsf"; + // Sound cache + //wav_path= gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + ".dsf"; + wav_path= gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE,uuid_str) + ".dsf"; + // if (!mBufferp->loadWAV(wav_path)) { diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index f1b6c4cdc2..add34b6b3d 100755 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -91,7 +91,9 @@ LLDir::LLDir() mTempDir(""), mDirDelimiter("/"), // fallback to forward slash if not overridden mLanguage("en"), - mUserName("undefined") + mUserName("undefined"), + // Sound cache + mSoundCacheDir("") { } @@ -375,6 +377,13 @@ const std::string &LLDir::getUserName() const return mUserName; } +// Sound cache +const std::string &LLDir::getSoundCacheDir() const +{ + return mSoundCacheDir; +} +// + static std::string ELLPathToString(ELLPath location) { typedef std::map ELLPathMap; @@ -523,6 +532,12 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd prefix = add(getAppRODataDir(), "fonts"); break; + // Sound cache + case LL_PATH_FS_SOUND_CACHE: + prefix = getSoundCacheDir(); + break; + // + default: llassert(0); } @@ -1042,6 +1057,38 @@ bool LLDir::setCacheDir(const std::string &path) } } +// Sound cache +bool LLDir::setSoundCacheDir(const std::string& path) +{ + bool result = false; + + // Default to normal cache directory + mSoundCacheDir = getCacheDir(); + + if (path.empty() ) + { + // reset to default + result = true; + } + else + { + LLFile::mkdir(path); + std::string tempname = add(path, "temp"); + LLFILE* file = LLFile::fopen(tempname,"wt"); + if (file) + { + fclose(file); + LLFile::remove(tempname); + mSoundCacheDir = path; + result = true; + } + } + LL_INFOS2("AppInit", "Directories") << "Setting sound cache directory: " << mSoundCacheDir << LL_ENDL; + + return result; +} +// + void LLDir::dumpCurrentDirectories() { LL_DEBUGS2("AppInit","Directories") << "Current Directories:" << LL_ENDL; diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h index 54967388b0..13535e9953 100755 --- a/indra/llvfs/lldir.h +++ b/indra/llvfs/lldir.h @@ -56,7 +56,12 @@ typedef enum ELLPath // [SL:KB] - Patch: Viewer-Skins | mS: 2010-10-19 (Catznip-2.4) LL_PATH_TOP_SKINTHEME = 19, // [/SL:KB] - LL_PATH_FS_RESOURCES = 20, // TT - Firestorm data + // Firestorm data + LL_PATH_FS_RESOURCES = 20, + // + // Sound cache + LL_PATH_FS_SOUND_CACHE = 21, + // LL_PATH_LAST } ELLPath; @@ -141,6 +146,9 @@ class LLDir const std::string getSkinBaseDir() const; // folder that contains all installed skins (not user modifications). e.g. c:\program files\second life\skins const std::string &getLLPluginDir() const; // Directory containing plugins and plugin shell const std::string &getUserName() const; + // Sound cache + const std::string &getSoundCacheDir() const; + // // Expanded filename std::string getExpandedFilename(ELLPath location, const std::string &filename) const; @@ -237,6 +245,9 @@ class LLDir virtual std::string getLanguage() const; virtual bool setCacheDir(const std::string &path); virtual void updatePerAccountChatLogsDir(); + // Sound cache + virtual bool setSoundCacheDir(const std::string& path); + // virtual void dumpCurrentDirectories(); @@ -301,6 +312,9 @@ protected: std::string mLanguage; // Current viewer language std::string mLLPluginDir; // Location for plugins and plugin shell std::string mUserName; // Current user name + // Sound cache + std::string mSoundCacheDir; // Sound cache + // // To avoid doing IO calls (expensive) in walkdSearchedSkinDirs cache results. struct SkinDirFile diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index cc36f42c13..768f5eadec 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -21972,6 +21972,17 @@ Change of this parameter will affect the layout of buttons in notification toast Value + FSSoundCacheLocation + + Comment + Location for caching sound files (.DSF); Uses default cache directory if empty + Persist + 1 + Type + String + Value + + diff --git a/indra/newview/fswsassetblacklist.cpp b/indra/newview/fswsassetblacklist.cpp index 2ffac38abc..2194cbe92a 100644 --- a/indra/newview/fswsassetblacklist.cpp +++ b/indra/newview/fswsassetblacklist.cpp @@ -134,7 +134,7 @@ void FSWSAssetBlacklist::addNewItemToBlacklistData(const LLUUID& id, const LLSD& if (type == LLAssetType::AT_SOUND) { gVFS->removeFile(id, LLAssetType::AT_SOUND); - std::string wav_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, id.asString()) + ".dsf"; + std::string wav_path = gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE, id.asString()) + ".dsf"; if (gDirUtilp->fileExists(wav_path)) { LLFile::remove(wav_path); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 53ef32dfd6..5a8ba2a1c9 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2098,10 +2098,13 @@ bool LLAppViewer::cleanup() removeCacheFiles("*.tmp"); removeCacheFiles("*.lso"); removeCacheFiles("*.out"); - if(!gSavedSettings.getBOOL("FSKeepUnpackedCacheFiles")) + // Sound cache + //removeCacheFiles("*.dsf"); + if (!gSavedSettings.getBOOL("FSKeepUnpackedCacheFiles")) { - removeCacheFiles("*.dsf"); + gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE, ""), "*.dsf"); } + // removeCacheFiles("*.bodypart"); removeCacheFiles("*.clothing"); @@ -2284,6 +2287,8 @@ bool LLAppViewer::cleanup() { llinfos << "Purging all cache files on exit" << llendflush; gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), "*.*"); + // Sound cache + gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE, ""), "*.*"); } removeMarkerFile(); // Any crashes from here on we'll just have to ignore @@ -4952,6 +4957,14 @@ bool LLAppViewer::initCache() gSavedSettings.setString("CacheLocation", ""); gSavedSettings.setString("CacheLocationTopFolder", ""); } + + // Sound cache + if (!gDirUtilp->setSoundCacheDir(gSavedSettings.getString("FSSoundCacheLocation"))) + { + LL_WARNS("AppCache") << "Unable to set sound cache location" << LL_ENDL; + gSavedSettings.setString("FSSoundCacheLocation", ""); + } + // if (mPurgeCache && !read_only) { diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 57b08362ac..0137d50032 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -515,6 +515,12 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) gSavedSettings.getControl("FSClientTagsVisibility")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); gSavedSettings.getControl("FSColorClienttags")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); // + + // Sound cache + mCommitCallbackRegistrar.add("Pref.BrowseSoundCache", boost::bind(&LLFloaterPreference::onClickBrowseSoundCache, this)); + mCommitCallbackRegistrar.add("Pref.SetSoundCache", boost::bind(&LLFloaterPreference::onClickSetSoundCache, this)); + mCommitCallbackRegistrar.add("Pref.ResetSoundCache", boost::bind(&LLFloaterPreference::onClickResetSoundCache, this)); + // // } @@ -607,6 +613,10 @@ BOOL LLFloaterPreference::postBuild() getChildView("log_path_string-panelsetup")->setEnabled(FALSE);// and the redundant instance -WoLf std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""); setCacheLocation(cache_location); + // Sound cache + setSoundCacheLocation(gSavedSettings.getString("FSSoundCacheLocation")); + getChild("FSSoundCacheLocation")->setEnabled(FALSE); + // getChild("language_combobox")->setCommitCallback(boost::bind(&LLFloaterPreference::onLanguageChange, this)); @@ -793,6 +803,8 @@ void LLFloaterPreference::apply() std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""); setCacheLocation(cache_location); + // Sound cache + setSoundCacheLocation(gSavedSettings.getString("FSSoundCacheLocation")); LLViewerMedia::setCookiesEnabled(getChild("cookies_enabled")->getValue()); @@ -1311,6 +1323,39 @@ void LLFloaterPreference::onClickResetCache() gSavedSettings.setString("CacheLocationTopFolder", top_folder); } +// Sound cache +void LLFloaterPreference::onClickSetSoundCache() +{ + std::string cur_name(gSavedSettings.getString("FSSoundCacheLocation")); + std::string proposed_name(cur_name); + + LLDirPicker& picker = LLDirPicker::instance(); + if (! picker.getDir(&proposed_name ) ) + { + return; //Canceled! + } + + std::string dir_name = picker.getDirName(); + if (!dir_name.empty() && dir_name != cur_name) + { + gSavedSettings.setString("FSSoundCacheLocation", dir_name); + setSoundCacheLocation(dir_name); + LLNotificationsUtil::add("SoundCacheWillBeMoved"); + } +} + +void LLFloaterPreference::onClickBrowseSoundCache() +{ + gViewerWindow->getWindow()->openFile(gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE, "")); +} + +void LLFloaterPreference::onClickResetSoundCache() +{ + gSavedSettings.setString("FSSoundCacheLocation", std::string()); + setSoundCacheLocation(std::string()); + LLNotificationsUtil::add("SoundCacheWillBeMoved"); +} +// // Performs a wipe of the local settings dir on next restart @@ -2389,6 +2434,15 @@ void LLFloaterPreference::setCacheLocation(const LLStringExplicit& location) cache_location_editor->setToolTip(location); } +// Sound cache +void LLFloaterPreference::setSoundCacheLocation(const LLStringExplicit& location) +{ + LLUICtrl* cache_location_editor = getChild("FSSoundCacheLocation"); + cache_location_editor->setValue(location); + cache_location_editor->setToolTip(location); +} +// + void LLFloaterPreference::selectPanel(const LLSD& name) { LLTabContainer * tab_containerp = getChild("pref core"); diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 2565dc29e2..a9ab82d635 100755 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -155,6 +155,12 @@ protected: public: void setCacheLocation(const LLStringExplicit& location); + // Sound cache + void setSoundCacheLocation(const LLStringExplicit& location); + void onClickSetSoundCache(); + void onClickBrowseSoundCache(); + void onClickResetSoundCache(); + // void onClickSetCache(); void onClickBrowseCache(); diff --git a/indra/newview/skins/default/xui/de/notifications.xml b/indra/newview/skins/default/xui/de/notifications.xml index b28e19ed73..7b3591046e 100755 --- a/indra/newview/skins/default/xui/de/notifications.xml +++ b/indra/newview/skins/default/xui/de/notifications.xml @@ -440,6 +440,9 @@ Sind Sie sicher, dass Sie fortfahren wollen? Der Cache wird nach einem Neustart von [APP_NAME] verschoben. Hinweis: Der Cache wird dabei gelöscht/geleert. + + Der Sound-Cache wird nach einem Neustart von [APP_NAME] verschoben. + Die Port-Einstellungen werden nach einem Neustart von [APP_NAME] wirksam. diff --git a/indra/newview/skins/default/xui/de/panel_preferences_setup.xml b/indra/newview/skins/default/xui/de/panel_preferences_setup.xml index 918b187296..64d1c3eaf1 100755 --- a/indra/newview/skins/default/xui/de/panel_preferences_setup.xml +++ b/indra/newview/skins/default/xui/de/panel_preferences_setup.xml @@ -37,6 +37,13 @@ + + + Sound Cache location: + + + + + + + + Conversation logs and transcripts location: @@ -361,19 +441,6 @@ function="Pref.BrowseSettingsDir" /> - - Maximum number of web browser windows: @@ -527,7 +594,7 @@ name="Proxy Settings:" mouse_opaque="false" top_pad="5" - width="300"> + width="80"> Proxy Settings: