play copy of so that the Cancel sound continues playing after the transition and sample have been torn down

This commit is contained in:
Chris Danford
2005-03-21 03:41:06 +00:00
parent a23db65a1e
commit 1bff5bb755
3 changed files with 23 additions and 9 deletions
+20 -7
View File
@@ -3,7 +3,7 @@
#include "RageSound.h"
#include "RageUtil.h"
#include "RageLog.h"
#include "RageSoundManager.h"
RandomSample::RandomSample()
@@ -78,14 +78,11 @@ bool RandomSample::LoadSound( CString sSoundFilePath )
return true;
}
void RandomSample::PlayRandom()
int RandomSample::GetNextToPlay()
{
// play one of the samples
if( m_pSamples.empty() )
{
// LOG->Trace( "WARNING: Tried to play a RandomSample that has 0 sounds loaded." );
return;
}
return -1;
int iIndexToPlay = 0;
for( int i=0; i<5; i++ )
@@ -95,8 +92,24 @@ void RandomSample::PlayRandom()
break;
}
m_pSamples[iIndexToPlay]->Play();
m_iIndexLastPlayed = iIndexToPlay;
return iIndexToPlay;
}
void RandomSample::PlayRandom()
{
int iIndexToPlay = GetNextToPlay();
if( iIndexToPlay == -1 )
return;
m_pSamples[iIndexToPlay]->Play();
}
void RandomSample::PlayCopyOfRandom()
{
int iIndexToPlay = GetNextToPlay();
if( iIndexToPlay == -1 )
return;
SOUNDMAN->PlayCopyOfSound( *m_pSamples[iIndexToPlay] );
}
void RandomSample::Stop()
+2 -1
View File
@@ -14,12 +14,13 @@ public:
bool Load( CString sFilePath, int iMaxToLoad = 1000 /*load all*/ );
void UnloadAll();
void PlayRandom();
void PlayCopyOfRandom();
void Stop();
private:
bool LoadSoundDir( CString sDir, int iMaxToLoad );
bool LoadSound( CString sSoundFilePath );
int GetNextToPlay();
vector<RageSound*> m_pSamples;
int m_iIndexLastPlayed;
+1 -1
View File
@@ -53,7 +53,7 @@ void Transition::Update( float fDeltaTime )
/* Start the transition on the first update, not in the ctor, so
* we don't play a sound while our parent is still loading. */
if( m_bFirstUpdate )
m_sound.PlayRandom();
m_sound.PlayCopyOfRandom();
// Check this before running Update, so we draw the last frame of the finished
// transition before sending m_MessageToSendWhenDone.