reduce disk access on wheel move by using timing data that's already loaded

This commit is contained in:
Glenn Maynard
2004-08-15 23:16:30 +00:00
parent 7ad61f1f07
commit 83b640f5dd
2 changed files with 15 additions and 18 deletions
+13 -17
View File
@@ -653,11 +653,8 @@ void ScreenSelectMusic::Update( float fDeltaTime )
if( !m_sSampleMusicToPlay.empty() ) if( !m_sSampleMusicToPlay.empty() )
{ {
SOUND->PlayMusic( SOUND->PlayMusic(
m_sSampleMusicToPlay, m_sSampleMusicToPlay, m_pSampleMusicTimingData,
m_sSampleMusicTimingData, true, m_fSampleStartSeconds, m_fSampleLengthSeconds,
true,
m_fSampleStartSeconds,
m_fSampleLengthSeconds,
1.5f, /* fade out for 1.5 seconds */ 1.5f, /* fade out for 1.5 seconds */
ALIGN_MUSIC_BEATS ); ALIGN_MUSIC_BEATS );
} }
@@ -1353,6 +1350,9 @@ void ScreenSelectMusic::AfterMusicChange()
vector<CString> m_Artists, m_AltArtists; vector<CString> m_Artists, m_AltArtists;
m_MachineRank.SetText( "" ); m_MachineRank.SetText( "" );
m_sSampleMusicToPlay = "";
m_pSampleMusicTimingData = NULL;
switch( m_MusicWheel.GetSelectedType() ) switch( m_MusicWheel.GetSelectedType() )
{ {
case TYPE_SECTION: case TYPE_SECTION:
@@ -1377,7 +1377,7 @@ void ScreenSelectMusic::AfterMusicChange()
{ {
case TYPE_SECTION: case TYPE_SECTION:
m_Banner.LoadFromGroup( sGroup ); // if this isn't a group, it'll default to the fallback banner m_Banner.LoadFromGroup( sGroup ); // if this isn't a group, it'll default to the fallback banner
SampleMusicToPlay = THEME->GetPathS(m_sName,"section music"); m_sSampleMusicToPlay = THEME->GetPathS(m_sName,"section music");
break; break;
case TYPE_SORT: case TYPE_SORT:
switch( GAMESTATE->m_SortOrder ) switch( GAMESTATE->m_SortOrder )
@@ -1389,7 +1389,7 @@ void ScreenSelectMusic::AfterMusicChange()
m_Banner.LoadMode(); m_Banner.LoadMode();
break; break;
} }
SampleMusicToPlay = THEME->GetPathS(m_sName,"sort music"); m_sSampleMusicToPlay = THEME->GetPathS(m_sName,"sort music");
break; break;
default: default:
ASSERT(0); ASSERT(0);
@@ -1405,8 +1405,8 @@ void ScreenSelectMusic::AfterMusicChange()
case TYPE_SONG: case TYPE_SONG:
case TYPE_PORTAL: case TYPE_PORTAL:
{ {
SampleMusicToPlay = pSong->GetMusicPath(); m_sSampleMusicToPlay = pSong->GetMusicPath();
SampleMusicTimingData = pSong->GetCacheFilePath(); m_pSampleMusicTimingData = &pSong->m_Timing;
m_fSampleStartSeconds = pSong->m_fMusicSampleStartSeconds; m_fSampleStartSeconds = pSong->m_fMusicSampleStartSeconds;
m_fSampleLengthSeconds = pSong->m_fMusicSampleLengthSeconds; m_fSampleLengthSeconds = pSong->m_fMusicSampleLengthSeconds;
@@ -1499,10 +1499,10 @@ void ScreenSelectMusic::AfterMusicChange()
switch( m_MusicWheel.GetSelectedType() ) switch( m_MusicWheel.GetSelectedType() )
{ {
case TYPE_ROULETTE: case TYPE_ROULETTE:
SampleMusicToPlay = THEME->GetPathS(m_sName,"roulette music"); m_sSampleMusicToPlay = THEME->GetPathS(m_sName,"roulette music");
break; break;
case TYPE_RANDOM: case TYPE_RANDOM:
SampleMusicToPlay = THEME->GetPathS(m_sName,"random music"); m_sSampleMusicToPlay = THEME->GetPathS(m_sName,"random music");
break; break;
default: default:
ASSERT(0); ASSERT(0);
@@ -1524,7 +1524,7 @@ void ScreenSelectMusic::AfterMusicChange()
pCourse->GetTrails( m_vpTrails, GAMESTATE->GetCurrentStyle()->m_StepsType ); pCourse->GetTrails( m_vpTrails, GAMESTATE->GetCurrentStyle()->m_StepsType );
SampleMusicToPlay = THEME->GetPathS(m_sName,"course music"); m_sSampleMusicToPlay = THEME->GetPathS(m_sName,"course music");
m_fSampleStartSeconds = 0; m_fSampleStartSeconds = 0;
m_fSampleLengthSeconds = -1; m_fSampleLengthSeconds = -1;
@@ -1585,13 +1585,9 @@ void ScreenSelectMusic::AfterMusicChange()
m_sprStage.Load( THEME->GetPathG(m_sName,"stage "+GAMESTATE->GetStageText()) ); m_sprStage.Load( THEME->GetPathG(m_sName,"stage "+GAMESTATE->GetStageText()) );
// Don't stop music if it's already playing the right file. // Don't stop music if it's already playing the right file.
if( SampleMusicToPlay == "" ) if( SOUND->GetMusicPath() != m_sSampleMusicToPlay )
SOUND->StopMusic();
else if( SOUND->GetMusicPath() != SampleMusicToPlay )
{ {
SOUND->StopMusic(); SOUND->StopMusic();
m_sSampleMusicToPlay = SampleMusicToPlay;
m_sSampleMusicTimingData = SampleMusicTimingData;
m_fPlaySampleCountdown = SAMPLE_MUSIC_DELAY; m_fPlaySampleCountdown = SAMPLE_MUSIC_DELAY;
} }
+2 -1
View File
@@ -104,7 +104,8 @@ protected:
bool m_bGoToOptions; bool m_bGoToOptions;
Sprite m_sprOptionsMessage; Sprite m_sprOptionsMessage;
float m_fPlaySampleCountdown; float m_fPlaySampleCountdown;
CString m_sSampleMusicToPlay, m_sSampleMusicTimingData; CString m_sSampleMusicToPlay;
TimingData *m_pSampleMusicTimingData;
float m_fSampleStartSeconds, m_fSampleLengthSeconds; float m_fSampleStartSeconds, m_fSampleLengthSeconds;
bool m_bAllowOptionsMenu, m_bAllowOptionsMenuRepeat; bool m_bAllowOptionsMenu, m_bAllowOptionsMenuRepeat;