revert RageSounds::TakeOverSound stuff; ended up not using it

and it broke changing BPM during gameplay
SDL_Delay -> usleep
This commit is contained in:
Glenn Maynard
2004-05-21 00:58:48 +00:00
parent 811bf3fd49
commit 98a0b812f0
6 changed files with 30 additions and 44 deletions
+2 -24
View File
@@ -263,7 +263,7 @@ int MusicThread_start( void *p )
{ {
while( !g_Shutdown ) while( !g_Shutdown )
{ {
SDL_Delay( 10 ); usleep( 10000 );
StartQueuedSounds(); StartQueuedSounds();
} }
@@ -325,7 +325,7 @@ RageSounds::~RageSounds()
delete pMusic; delete pMusic;
} }
static float GetFrameTimingAdjustment( float fDeltaTime ) float RageSounds::GetFrameTimingAdjustment( float fDeltaTime )
{ {
/* /*
* We get one update per frame, and we're updated early, almost immediately after vsync, * We get one update per frame, and we're updated early, almost immediately after vsync,
@@ -501,28 +501,6 @@ float RageSounds::GetPlayLatency() const
return SOUNDMAN->GetPlayLatency(); return SOUNDMAN->GetPlayLatency();
} }
void RageSounds::TakeOverSound( RageSound *snd, const TimingData *Timing )
{
MusicPlaying *NewMusic = new MusicPlaying( snd );
NewMusic->m_TimingDelayed = false;
NewMusic->m_HasTiming = false;
if( Timing )
{
NewMusic->m_HasTiming = true;
NewMusic->m_Timing = *Timing;
}
LockMut( *g_Mutex );
delete g_Playing;
g_Playing = NewMusic;
Update( 0 );
const float fSeconds = g_Playing->m_Music->GetPositionSeconds();
LOG->Trace("Updated: %f sec, %f beat", fSeconds, GAMESTATE->m_fSongBeat );
}
/* /*
* Copyright (c) 2003-2004 Glenn Maynard * Copyright (c) 2003-2004 Glenn Maynard
* All rights reserved. * All rights reserved.
+1 -3
View File
@@ -19,15 +19,13 @@ public:
void StopMusic() { PlayMusic(""); } void StopMusic() { PlayMusic(""); }
CString GetMusicPath() const; CString GetMusicPath() const;
/* Take ownership of snd; handle timing, free it, etc. */
void TakeOverSound( RageSound *snd, const TimingData *Timing );
void PlayOnce( CString sPath ); void PlayOnce( CString sPath );
void PlayOnceFromDir( CString sDir ); void PlayOnceFromDir( CString sDir );
void PlayOnceFromAnnouncer( CString sFolderName ); void PlayOnceFromAnnouncer( CString sFolderName );
float GetPlayLatency() const; float GetPlayLatency() const;
void HandleSongTimer( bool on=true ); void HandleSongTimer( bool on=true );
float GetFrameTimingAdjustment( float fDeltaTime );
}; };
extern RageSounds *SOUND; extern RageSounds *SOUND;
+1 -1
View File
@@ -99,7 +99,7 @@ void ScreenDemonstration::HandleScreenMessage( const ScreenMessage SM )
break; break;
case SM_GoToNextScreen: case SM_GoToNextScreen:
SOUND->StopMusic(); m_soundMusic.Stop();
GAMESTATE->Reset(); GAMESTATE->Reset();
SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on
SCREENMAN->SetNewScreen( NEXT_SCREEN ); SCREENMAN->SetNewScreen( NEXT_SCREEN );
+23 -14
View File
@@ -103,7 +103,8 @@ void ScreenGameplay::Init()
else else
LIGHTSMAN->SetLightsMode( LIGHTSMODE_GAMEPLAY ); LIGHTSMAN->SetLightsMode( LIGHTSMODE_GAMEPLAY );
m_soundMusic = NULL; /* We do this ourself. */
SOUND->HandleSongTimer( false );
SECONDS_BETWEEN_COMMENTS.Refresh(); SECONDS_BETWEEN_COMMENTS.Refresh();
TICK_EARLY_SECONDS.Refresh(); TICK_EARLY_SECONDS.Refresh();
@@ -768,6 +769,7 @@ ScreenGameplay::~ScreenGameplay()
SAFE_DELETE( m_pInventory[p] ); SAFE_DELETE( m_pInventory[p] );
} }
SAFE_DELETE( m_pCombinedLifeMeter ); SAFE_DELETE( m_pCombinedLifeMeter );
m_soundMusic.StopPlaying();
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */ m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
@@ -985,8 +987,7 @@ void ScreenGameplay::LoadNextSong()
LL.LoadFromLRCFile(GAMESTATE->m_pCurSong->GetLyricsPath(), *GAMESTATE->m_pCurSong); LL.LoadFromLRCFile(GAMESTATE->m_pCurSong->GetLyricsPath(), *GAMESTATE->m_pCurSong);
m_soundMusic = new RageSound; m_soundMusic.Load( GAMESTATE->m_pCurSong->GetMusicPath() );
m_soundMusic->Load( GAMESTATE->m_pCurSong->GetMusicPath() );
/* Set up song-specific graphics. */ /* Set up song-specific graphics. */
@@ -1065,8 +1066,6 @@ float ScreenGameplay::StartPlayingSong(float MinTimeToNotes, float MinTimeToMusi
fStartSecond = min(fStartSecond, -MinTimeToMusic); fStartSecond = min(fStartSecond, -MinTimeToMusic);
ASSERT( m_soundMusic );
RageSoundParams p; RageSoundParams p;
p.AccurateSync = true; p.AccurateSync = true;
p.SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate ); p.SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate );
@@ -1077,14 +1076,12 @@ float ScreenGameplay::StartPlayingSong(float MinTimeToNotes, float MinTimeToMusi
//used for syncing up songs. //used for syncing up songs.
NSMAN->StartRequest(); NSMAN->StartRequest();
m_soundMusic->Play( &p ); m_soundMusic.Play( &p );
SOUND->TakeOverSound( m_soundMusic, &GAMESTATE->m_pCurSong->m_Timing );
m_soundMusic = NULL; // SOUND owns it now
/* Make sure GAMESTATE->m_fMusicSeconds is set up. */ /* Make sure GAMESTATE->m_fMusicSeconds is set up. */
GAMESTATE->m_fMusicSeconds = -5000; GAMESTATE->m_fMusicSeconds = -5000;
SOUND->Update(0); UpdateSongPosition(0);
ASSERT( GAMESTATE->m_fMusicSeconds > -4000 ); /* make sure the "fake timer" code doesn't trigger */ ASSERT( GAMESTATE->m_fMusicSeconds > -4000 ); /* make sure the "fake timer" code doesn't trigger */
/* Return the amount of time until the first beat. */ /* Return the amount of time until the first beat. */
@@ -1158,6 +1155,17 @@ void ScreenGameplay::PlayAnnouncer( CString type, float fSeconds )
m_pCombinedLifeMeter->OnTaunt(); m_pCombinedLifeMeter->OnTaunt();
} }
void ScreenGameplay::UpdateSongPosition( float fDeltaTime )
{
if( !m_soundMusic.IsPlaying() )
return;
RageTimer tm;
const float fSeconds = m_soundMusic.GetPositionSeconds( NULL, &tm );
const float fAdjust = SOUND->GetFrameTimingAdjustment( fDeltaTime );
GAMESTATE->UpdateSongPosition( fSeconds+fAdjust, GAMESTATE->m_pCurSong->m_Timing, tm+fAdjust );
}
void ScreenGameplay::Update( float fDeltaTime ) void ScreenGameplay::Update( float fDeltaTime )
{ {
if( GAMESTATE->m_pCurSong == NULL ) if( GAMESTATE->m_pCurSong == NULL )
@@ -1202,6 +1210,8 @@ void ScreenGameplay::Update( float fDeltaTime )
} }
UpdateSongPosition( fDeltaTime );
if( m_bZeroDeltaOnNextUpdate ) if( m_bZeroDeltaOnNextUpdate )
{ {
Screen::Update( 0 ); Screen::Update( 0 );
@@ -1607,8 +1617,8 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
* *
* We're doing #3. I'm not sure which is best. * We're doing #3. I'm not sure which is best.
*/ */
SOUND->StopMusic();
SOUND->HandleSongTimer( false ); m_soundMusic.StopPlaying();
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */ m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
this->ClearMessageQueue(); this->ClearMessageQueue();
@@ -2196,8 +2206,7 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
case SM_BeginFailed: case SM_BeginFailed:
m_DancingState = STATE_OUTRO; m_DancingState = STATE_OUTRO;
SOUND->StopMusic(); m_soundMusic.StopPlaying();
SOUND->HandleSongTimer( false );
m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */ m_soundAssistTick.StopPlaying(); /* Stop any queued assist ticks. */
TweenOffScreen(); TweenOffScreen();
m_Failed.StartTransitioning( SM_GoToScreenAfterFail ); m_Failed.StartTransitioning( SM_GoToScreenAfterFail );
+2 -1
View File
@@ -83,6 +83,7 @@ protected:
void PlayAnnouncer( CString type, float fSeconds ); void PlayAnnouncer( CString type, float fSeconds );
void PlayTicks(); void PlayTicks();
void UpdateSongPosition( float fDeltaTime );
void UpdateLyrics( float fDeltaTime ); void UpdateLyrics( float fDeltaTime );
void UpdateCheckFail(); void UpdateCheckFail();
void SongFinished(); void SongFinished();
@@ -176,7 +177,7 @@ protected:
bool m_bDemonstration; bool m_bDemonstration;
RageSound m_soundAssistTick; RageSound m_soundAssistTick;
RageSound *m_soundMusic; RageSound m_soundMusic;
BeginnerHelper m_BeginnerHelper; BeginnerHelper m_BeginnerHelper;
+1 -1
View File
@@ -216,7 +216,7 @@ void ScreenJukebox::HandleScreenMessage( const ScreenMessage SM )
m_Out.StartTransitioning( SM_GoToNextScreen ); m_Out.StartTransitioning( SM_GoToNextScreen );
return; return;
case SM_GoToNextScreen: case SM_GoToNextScreen:
SOUND->StopMusic(); m_soundMusic.Stop();
SCREENMAN->SetNewScreen( "ScreenJukebox" ); SCREENMAN->SetNewScreen( "ScreenJukebox" );
return; return;
} }