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

Ansariel 2014-04-05 15:23:15 +02:00
parent 567d06a43b
commit 70218d0ac2
13 changed files with 265 additions and 28 deletions

View File

@ -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";
// <FS:Ansariel> Sound cache
//d_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + ".dsf";
d_path = gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE,uuid_str) + ".dsf";
// </FS:Ansariel>
mCurrentDecodep = new LLVorbisDecodeState(uuid, d_path);
if (!mCurrentDecodep->initDecode())

View File

@ -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);
// <FS:Ansariel> Sound cache
//wav_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str);
wav_path = gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE,uuid_str);
// </FS:Ansariel>
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";
// <FS:Ansariel> Sound cache
//wav_path= gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str) + ".dsf";
wav_path= gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE,uuid_str) + ".dsf";
// </FS:Ansariel>
if (!mBufferp->loadWAV(wav_path))
{

View File

@ -91,7 +91,9 @@ LLDir::LLDir()
mTempDir(""),
mDirDelimiter("/"), // fallback to forward slash if not overridden
mLanguage("en"),
mUserName("undefined")
mUserName("undefined"),
// <FS:Ansariel> Sound cache
mSoundCacheDir("")
{
}
@ -375,6 +377,13 @@ const std::string &LLDir::getUserName() const
return mUserName;
}
// <FS:Ansariel> Sound cache
const std::string &LLDir::getSoundCacheDir() const
{
return mSoundCacheDir;
}
// </FS:Ansariel>
static std::string ELLPathToString(ELLPath location)
{
typedef std::map<ELLPath, const char*> ELLPathMap;
@ -523,6 +532,12 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd
prefix = add(getAppRODataDir(), "fonts");
break;
// <FS:Ansariel> Sound cache
case LL_PATH_FS_SOUND_CACHE:
prefix = getSoundCacheDir();
break;
// </FS:Ansariel>
default:
llassert(0);
}
@ -1042,6 +1057,38 @@ bool LLDir::setCacheDir(const std::string &path)
}
}
// <FS:Ansariel> 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;
}
// </FS:Ansariel>
void LLDir::dumpCurrentDirectories()
{
LL_DEBUGS2("AppInit","Directories") << "Current Directories:" << LL_ENDL;

View File

@ -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
// <FS:TT> Firestorm data
LL_PATH_FS_RESOURCES = 20,
// </FS:TT>
// <FS:Ansariel> Sound cache
LL_PATH_FS_SOUND_CACHE = 21,
// </FS:Ansariel>
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;
// <FS:Ansariel> Sound cache
const std::string &getSoundCacheDir() const;
// </FS:Ansariel>
// 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();
// <FS:Ansariel> Sound cache
virtual bool setSoundCacheDir(const std::string& path);
// </FS:Ansariel>
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
// <FS:Ansariel> Sound cache
std::string mSoundCacheDir; // Sound cache
// </FS:Ansariel>
// <FS:ND> To avoid doing IO calls (expensive) in walkdSearchedSkinDirs cache results.
struct SkinDirFile

View File

@ -21972,6 +21972,17 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<string/>
</map>
<key>FSSoundCacheLocation</key>
<map>
<key>Comment</key>
<string>Location for caching sound files (.DSF); Uses default cache directory if empty</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string/>
</map>
</map>
</llsd>

View File

@ -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);

View File

@ -2098,10 +2098,13 @@ bool LLAppViewer::cleanup()
removeCacheFiles("*.tmp");
removeCacheFiles("*.lso");
removeCacheFiles("*.out");
if(!gSavedSettings.getBOOL("FSKeepUnpackedCacheFiles"))
// <FS:Ansariel> Sound cache
//removeCacheFiles("*.dsf");
if (!gSavedSettings.getBOOL("FSKeepUnpackedCacheFiles"))
{
removeCacheFiles("*.dsf");
gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_FS_SOUND_CACHE, ""), "*.dsf");
}
// </FS:Ansariel>
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,""), "*.*");
// <FS:Ansariel> 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", "");
}
// <FS:Ansariel> Sound cache
if (!gDirUtilp->setSoundCacheDir(gSavedSettings.getString("FSSoundCacheLocation")))
{
LL_WARNS("AppCache") << "Unable to set sound cache location" << LL_ENDL;
gSavedSettings.setString("FSSoundCacheLocation", "");
}
// </FS:Ansariel>
if (mPurgeCache && !read_only)
{

View File

@ -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));
// </FS:CR>
// <FS:Ansariel> 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));
// </FS:Ansariel>
// </Firestorm callbacks>
}
@ -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);
// <FS:Ansariel> Sound cache
setSoundCacheLocation(gSavedSettings.getString("FSSoundCacheLocation"));
getChild<LLUICtrl>("FSSoundCacheLocation")->setEnabled(FALSE);
// </FS:Ansariel>
getChild<LLComboBox>("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);
// <FS:Ansariel> Sound cache
setSoundCacheLocation(gSavedSettings.getString("FSSoundCacheLocation"));
LLViewerMedia::setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue());
@ -1311,6 +1323,39 @@ void LLFloaterPreference::onClickResetCache()
gSavedSettings.setString("CacheLocationTopFolder", top_folder);
}
// <FS:Ansariel> 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");
}
// </FS:Ansariel>
// 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);
}
// <FS:Ansariel> Sound cache
void LLFloaterPreference::setSoundCacheLocation(const LLStringExplicit& location)
{
LLUICtrl* cache_location_editor = getChild<LLUICtrl>("FSSoundCacheLocation");
cache_location_editor->setValue(location);
cache_location_editor->setToolTip(location);
}
// </FS:Ansariel>
void LLFloaterPreference::selectPanel(const LLSD& name)
{
LLTabContainer * tab_containerp = getChild<LLTabContainer>("pref core");

View File

@ -155,6 +155,12 @@ protected:
public:
void setCacheLocation(const LLStringExplicit& location);
// <FS:Ansariel> Sound cache
void setSoundCacheLocation(const LLStringExplicit& location);
void onClickSetSoundCache();
void onClickBrowseSoundCache();
void onClickResetSoundCache();
// </FS:Ansariel>
void onClickSetCache();
void onClickBrowseCache();

View File

@ -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.
</notification>
<notification name="SoundCacheWillBeMoved">
Der Sound-Cache wird nach einem Neustart von [APP_NAME] verschoben.
</notification>
<notification name="ChangeConnectionPort">
Die Port-Einstellungen werden nach einem Neustart von [APP_NAME] wirksam.
</notification>

View File

@ -37,6 +37,13 @@
<button label="Setzen" label_selected="Setzen" name="set_cache" width="45"/>
<button label="Zurücksetzen" label_selected="Zurücksetzen" name="reset_cache" width="85"/>
<button label="Löschen" label_selected="Löschen" name="clear_cache" width="55" left_pad="5"/>
<text name="Sound Cache location">
Sound-Cache-Speicherort:
</text>
<button label="Öffnen" label_selected="Öffnen" name="open_sound_cache"/>
<button label="Setzen" label_selected="Setzen" name="set_sound_cache" width="45"/>
<button label="Zurücksetzen" label_selected="Zurücksetzen" name="reset_sound_cache" width="85"/>
<check_box label="DSF (Sound) Cache-Dateien beim Ausloggen nicht löschen" tool_tip="Falls aktiviert, werden entpackte Sound-Dateien beim Ausloggen nicht aus dem Cache gelöscht, wodurch das Abspielen von Sounds verbessert werden kann. ACHTUNG: Hierdurch kann die Cache-Größe sehr schnell ansteigen und zudem wird Cache-Größenlimit in diesem Fall NICHT beachtet, wodurch mehr als 10GB an Festplattenspeicher belegt werden kann! Diese Option ist in Firestorm standardmäßig deaktiviert." name="keep_unpacked_cache"/>
<text name="log_path_desc">
Speicherort für Chatprotokoll und Verläufe:
</text>
@ -45,7 +52,6 @@
<button label="Zurücksetzen" label_selected="Zurücksetzen" name="reset_logpath" width="85"/>
<button label="Öffne Crash-Protokolle" label_selected="Öffne Crash-Protokolle" name="browse_crashlogs" width="140"/>
<button label="Öffne Ordner mit Einstellungen" label_selected="Öffne Ordner mit Einstellungen" name="browse_settingsdir" width="190"/>
<check_box label="DSF (Sound) Cache-Dateien beim Ausloggen nicht löschen" tool_tip="Falls aktiviert, werden entpackte Sound-Dateien beim Ausloggen nicht aus dem Cache gelöscht, wodurch das Abspielen von Sounds verbessert werden kann. ACHTUNG: Hierdurch kann die Cache-Größe sehr schnell ansteigen und zudem wird Cache-Größenlimit in diesem Fall NICHT beachtet, wodurch mehr als 10GB an Festplattenspeicher belegt werden kann! Diese Option ist in Firestorm standardmäßig deaktiviert." name="keep_unpacked_cache"/>
<text name="Web:">
Web:
@ -67,7 +73,7 @@
<check_box initial_value="true" label="Cookies annehmen" name="cookies_enabled"/>
<check_box initial_value="true" label="Javascript aktivieren" name="browser_javascript_enabled"/>
<check_box initial_value="false" label="Medienbrowser-Popups aktivieren" name="media_popup_enabled"/>
<text name="Proxy Settings:">
<text name="Proxy Settings:" width="110">
Proxy-Einstellungen:
</text>
<button label="Proxy-Einstellungen ändern" label_selected="Durchsuchen" name="set_proxy" width="180"/>

View File

@ -1114,6 +1114,13 @@ If you disable Javascript, the search function will not work properly, and you w
Cache will be moved after restarting [APP_NAME].
Note: This will also clear the cache.
</notification>
<notification
icon="alertmodal.tga"
name="SoundCacheWillBeMoved"
type="alertmodal">
Sound cache will be moved after restarting [APP_NAME].
</notification>
<notification
icon="alertmodal.tga"

View File

@ -265,6 +265,86 @@
<button.commit_callback
function="Pref.ClearCache" />
</button>
<text
type="string"
length="1"
follows="left|top"
height="10"
layout="topleft"
left="15"
name="Sound Cache location"
top_delta="25"
width="300">
Sound Cache location:
</text>
<line_editor
control_name="FSSoundCacheLocation"
border_style="line"
border_thickness="1"
follows="left|top"
font="SansSerif"
height="23"
layout="topleft"
left="20"
max_length_chars="4096"
name="FSSoundCacheLocation"
top_pad="5"
width="270" />
<button
enabled="true"
follows="left|top"
height="23"
label="Open"
label_selected="Open"
layout="topleft"
left_pad="5"
name="open_sound_cache"
top_delta="-1"
width="45">
<button.commit_callback
function="Pref.BrowseSoundCache" />
</button>
<button
follows="left|top"
height="23"
label="Set"
label_selected="Set"
layout="topleft"
left_pad="5"
name="set_sound_cache"
top_delta="-0"
width="40">
<button.commit_callback
function="Pref.SetSoundCache" />
</button>
<button
follows="left|top"
height="23"
label="Reset"
label_selected="Reset"
layout="topleft"
left_pad="3"
name="reset_sound_cache"
top_delta="0"
width="50">
<button.commit_callback
function="Pref.ResetSoundCache" />
</button>
<check_box
follows="left|top"
height="16"
control_name="FSKeepUnpackedCacheFiles"
label="Don't delete unpacked DSF (sound) cache files when logging out"
tool_tip="If checked, the viewer won't delete unpacked sound files from the cache when logging out, which may improve experience with playing inworld sounds. Please note: Enabling this will likely fill your cache directory very quickly, and does not adhere to the max cache setting. This may result in excessive disk space usage. Disabled by default."
left="15"
mouse_opaque="true"
name="keep_unpacked_cache"
radio_style="false"
width="400"
top_pad="5"/>
<text
type="string"
length="1"
@ -273,7 +353,7 @@
layout="topleft"
left="15"
name="log_path_desc"
top_delta="35"
top_pad="10"
width="300">
Conversation logs and transcripts location:
</text>
@ -361,19 +441,6 @@
function="Pref.BrowseSettingsDir" />
</button>
<check_box
follows="left|top"
height="16"
control_name="FSKeepUnpackedCacheFiles"
label="Don't delete unpacked DSF (sound) cache files when logging out"
tool_tip="If checked, the viewer won't delete unpacked sound files from the cache when logging out, which may improve experience with playing inworld sounds. Please note: Enabling this will likely fill your cache directory very quickly, and does not adhere to the max cache setting. This may result in excessive disk space usage. Disabled by default."
left="15"
mouse_opaque="true"
name="keep_unpacked_cache"
radio_style="false"
width="400"
top_pad="10"/>
<text
type="string"
length="1"
@ -425,7 +492,7 @@
left="25"
name="numberwebfloaters_label"
mouse_opaque="false"
top_pad="5"
top_pad="0"
width="300">
Maximum number of web browser windows:
</text>
@ -527,7 +594,7 @@
name="Proxy Settings:"
mouse_opaque="false"
top_pad="5"
width="300">
width="80">
Proxy Settings:
</text>
<button
@ -537,9 +604,9 @@
width="140"
label_selected="Browse"
layout="topleft"
left_delta="50"
left_pad="10"
name="set_proxy"
top_pad="5" >
top_delta="-5" >
<button.commit_callback
function="Pref.Proxy" />
</button>