Add audio cache for faster initialization

This commit is contained in:
Sergeanur 2020-07-17 13:48:25 +03:00
parent 693a5e0c2a
commit 949d0c8853
5 changed files with 35 additions and 2 deletions

View File

@ -959,6 +959,15 @@ cSampleManager::Initialise(void)
} }
#ifdef AUDIO_CACHE
TRACE("cache");
FILE *cacheFile = fopen("audio\\sound.cache", "rb");
if (cacheFile) {
fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile);
m_bInitialised = true;
}else {
#endif
TRACE("cdrom"); TRACE("cdrom");
S32 tatalms; S32 tatalms;
@ -1115,7 +1124,13 @@ cSampleManager::Initialise(void)
_bUseHDDAudio = false; _bUseHDDAudio = false;
} }
#endif #endif
#ifdef AUDIO_CACHE
cacheFile = fopen("audio\\sound.cache", "wb");
fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile);
}
#endif
TRACE("stream"); TRACE("stream");
{ {
for ( int32 i = 0; i < MAX_STREAMS; i++ ) for ( int32 i = 0; i < MAX_STREAMS; i++ )

View File

@ -604,7 +604,13 @@ cSampleManager::Initialise(void)
return false; return false;
} }
} }
#ifdef AUDIO_CACHE
FILE *cacheFile = fopen("audio\\sound.cache", "rb");
if (cacheFile) {
fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile);
} else
#endif
{ {
for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ )
@ -622,6 +628,11 @@ cSampleManager::Initialise(void)
else else
USERERROR("Can't open '%s'\n", StreamedNameTable[i]); USERERROR("Can't open '%s'\n", StreamedNameTable[i]);
} }
#ifdef AUDIO_CACHE
cacheFile = fopen("audio\\sound.cache", "wb");
fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile);
#endif
} }
LoadSampleBank(SAMPLEBANK_MAIN); LoadSampleBank(SAMPLEBANK_MAIN);

View File

@ -439,8 +439,10 @@ void CRecordDataForChase::StartChaseScene(float startTime)
Status = STATE_PLAYBACK; Status = STATE_PLAYBACK;
AnimTime = startTime; AnimTime = startTime;
AnimStartTime = CTimer::GetTimeInMilliseconds(); AnimStartTime = CTimer::GetTimeInMilliseconds();
#ifndef NO_ISLAND_LOADING
RemoveUnusedCollision(); RemoveUnusedCollision();
CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN); CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN);
#endif
CGame::TidyUpMemory(true, true); CGame::TidyUpMemory(true, true);
CStreaming::ImGonnaUseStreamingMemory(); CStreaming::ImGonnaUseStreamingMemory();
CFileMgr::SetDir("data\\paths"); CFileMgr::SetDir("data\\paths");

View File

@ -104,7 +104,9 @@ CFileLoader::LoadLevel(const char *filename)
LoadingScreenLoadingFile(line + 8); LoadingScreenLoadingFile(line + 8);
LoadMapZones(line + 8); LoadMapZones(line + 8);
}else if(strncmp(line, "SPLASH", 6) == 0){ }else if(strncmp(line, "SPLASH", 6) == 0){
#ifndef DISABLE_LOADING_SCREEN
LoadSplash(GetRandomSplashScreen()); LoadSplash(GetRandomSplashScreen());
#endif
}else if(strncmp(line, "CDIMAGE", 7) == 0){ }else if(strncmp(line, "CDIMAGE", 7) == 0){
CdStreamAddImage(line + 8); CdStreamAddImage(line + 8);
} }

View File

@ -275,3 +275,6 @@ enum Config {
//#define PS2_CAM_TRANSITION // old way of transitioning between cam modes //#define PS2_CAM_TRANSITION // old way of transitioning between cam modes
#define IMPROVED_CAMERA // Better Debug cam, and maybe more in the future #define IMPROVED_CAMERA // Better Debug cam, and maybe more in the future
#define FREE_CAM // Rotating cam #define FREE_CAM // Rotating cam
// Audio
#define AUDIO_CACHE // cache sound lengths to speed up the cold boot