Soundcache

From Valve Developer Community
Revision as of 08:40, 30 November 2005 by TomEdwards (talk | contribs) (Updated, thanks Yahn)
Jump to navigation Jump to search

Outline

A Soundcache is a file with contains the first second of each sound required in a map. Source loads the soundcache instead of the sounds themselves to save time and memory: during gameplay the soundcache snippet is played while the full sound loads on-demand from the hard drive. There is enough data loaded by the time the sound snippet finishes playing to begin streaming to hardware. Each soundcache has an accompanying .manifest, which contains a list of files needed by the map.

Extraction

  • .cache files can be viewed with Game Extractor [1]
  • .manifest files can be viewed with any text editor

Caches

  • _sharedprecache.cache: contains data for sounds common to over 50% of maps.
  • _other.cache: contains the file header, but no data, for any sound files that were not encountered in any other precache lists. Sounds in this cache do not cause I/O-related hitches as they play back fully asynchronously, that is, only once the sound is completely loaded.
  • <mapname>.cache: Contains the remaining files that are precached but not already a part of _sharedprecache.cache.

Creation

Sound caches are created automatically if they do not already exist before a map is loaded. A manifest is first written listing every file used, then each cache is created using the rules above, with the first second of each file written to the relavant cache.

  • snd_writemanifest
Writes the .manifest file. Buggy.
  • snd_rebuildaudiocache
Writes the .cache file, containing soundfile snippets. Appears to have no effect.

Limitations & Bugs

There is no known way to manually select the contents of each cache.