diff options
author | Colin Snover | 2017-07-23 15:56:03 -0500 |
---|---|---|
committer | Colin Snover | 2017-07-23 16:01:19 -0500 |
commit | 4d52b018a23114813fd5c0d159abb97a02a96d34 (patch) | |
tree | d210c0b3d22e3144c3e4ff89322aab3dd933a1ed | |
parent | d3f3da4d15eeebd55a7e8731d53857be421b8fce (diff) | |
download | scummvm-rg350-4d52b018a23114813fd5c0d159abb97a02a96d34.tar.gz scummvm-rg350-4d52b018a23114813fd5c0d159abb97a02a96d34.tar.bz2 scummvm-rg350-4d52b018a23114813fd5c0d159abb97a02a96d34.zip |
SCI: Keep audio maps out of the LRU cache
-rw-r--r-- | engines/sci/resource.cpp | 6 | ||||
-rw-r--r-- | engines/sci/resource_audio.cpp | 20 |
2 files changed, 19 insertions, 7 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index bf669c9176..29f3017acb 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -1877,12 +1877,6 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) { // if we use the first entries in the resource file, half of the // game will be English and umlauts will also be missing :P if (resource->_source->getSourceType() == kSourceVolume) { - // Maps are read during the scanning process (below), so - // need to be treated as unallocated in order for the new - // data from this volume to be picked up and used - if (resId.getType() == kResourceTypeMap) { - resource->_status = kResStatusNoMalloc; - } updateResource(resId, source, fileOffset, 0, map->getLocationName()); } } diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp index 92761cae39..741968b293 100644 --- a/engines/sci/resource_audio.cpp +++ b/engines/sci/resource_audio.cpp @@ -297,13 +297,29 @@ int ResourceManager::readAudioMapSCI11(IntMapResourceSource *map) { uint32 offset = 0; const ResourceId mapResId(kResourceTypeMap, map->_mapNumber); - Resource *mapRes = findResource(mapResId, false); + Resource *mapRes = _resMap.getVal(mapResId, nullptr); if (!mapRes) { warning("Failed to open %s", mapResId.toString().c_str()); return SCI_ERROR_RESMAP_NOT_FOUND; } + // Here, we allocate audio maps ourselves instead of using findResource to + // do this for us. This is in order to prevent the map resources from + // getting into the LRU cache. These resources must be read and then + // deallocated in games with multi-disc audio in order to read the audio + // maps from every CD, and LRU eviction freaks out if an unallocated + // resource ends up in the LRU list. It is also not necessary for these + // resources to be cached in the LRU at all, since they are only used upon + // game startup to populate _resMap. + assert(mapRes->_status == kResStatusNoMalloc); + loadResource(mapRes); + + if (!mapRes->data()) { + warning("Failed to read data for %s", mapResId.toString().c_str()); + return SCI_ERROR_RESMAP_NOT_FOUND; + } + ResourceSource *src = findVolume(map, map->_volumeNumber); if (!src) { @@ -484,6 +500,8 @@ int ResourceManager::readAudioMapSCI11(IntMapResourceSource *map) { } } + mapRes->unalloc(); + return 0; } |