fix up stopping

This commit is contained in:
Glenn Maynard
2002-12-21 23:14:46 +00:00
parent 07e38b8a6c
commit 5d0ce128e4
4 changed files with 40 additions and 42 deletions
@@ -78,22 +78,19 @@ bool RageSound_DSound_Software::GetPCM()
for(unsigned i = 0; i < sounds.size(); ++i)
{
if(sounds[i]->stopping)
continue;
/* Call the callback. */
unsigned got = sounds[i]->snd->GetPCM((char *) buf, len, play_pos);
SOUNDMAN->MixAudio(
(Uint8 *) locked_buf, (Uint8 *) buf, got, SDL_MIX_MAXVOLUME/2);
if(got < len)
{
if(sounds[i]->flush_bufs)
sounds[i]->flush_bufs--;
} else {
/* Call the callback. */
unsigned got = sounds[i]->snd->GetPCM((char *) buf, len, play_pos);
SOUNDMAN->MixAudio(
(Uint8 *) locked_buf, (Uint8 *) buf, got, SDL_MIX_MAXVOLUME/2);
if(got < len)
{
/* This sound is finishing. */
sounds[i]->stopping = true;
sounds[i]->flush_bufs = 2;
}
/* This sound is finishing. */
sounds[i]->stopping = true;
sounds[i]->flush_pos = str_ds->GetMaxPosition();
}
}
@@ -122,11 +119,13 @@ void RageSound_DSound_Software::Update(float delta)
vector<sound *> snds = sounds;
for(unsigned i = 0; i < snds.size(); ++i)
{
if(sounds[i]->stopping && !sounds[i]->flush_bufs)
{
/* This sound is done. */
snds[i]->snd->SoundStopped();
}
if(!snds[i]->stopping) continue;
if(GetPosition(snds[i]->snd) < snds[i]->flush_pos)
continue; /* stopping but still flushing */
/* This sound is done. */
snds[i]->snd->SoundStopped();
}
}
@@ -15,7 +15,7 @@ class RageSound_DSound_Software: public RageSoundDriver
bool stopping;
int flush_bufs; /* state == STOPPING only */
int flush_pos; /* state == STOPPING only */
sound() { snd = NULL; stopping=false; }
};
@@ -85,22 +85,19 @@ bool RageSound_WaveOut::GetPCM()
for(unsigned i = 0; i < sounds.size(); ++i)
{
if(sounds[i]->stopping)
continue;
/* Call the callback. */
unsigned got = sounds[i]->snd->GetPCM((char *) buf, chunksize, last_cursor_pos);
SOUNDMAN->MixAudio(
(Uint8 *) buffers[b].lpData, (Uint8 *) buf, got, SDL_MIX_MAXVOLUME/2);
if(got < chunksize)
{
if(sounds[i]->flush_bufs)
sounds[i]->flush_bufs--;
} else {
/* Call the callback. */
unsigned got = sounds[i]->snd->GetPCM((char *) buf, chunksize, last_cursor_pos);
SOUNDMAN->MixAudio(
(Uint8 *) buffers[b].lpData, (Uint8 *) buf, got, SDL_MIX_MAXVOLUME/2);
if(got < chunksize)
{
/* This sound is finishing. */
sounds[i]->stopping = true;
sounds[i]->flush_bufs = num_chunks;
}
/* This sound is finishing. */
sounds[i]->stopping = true;
sounds[i]->flush_pos = last_cursor_pos + (got / samplesize);
}
}
@@ -133,11 +130,13 @@ void RageSound_WaveOut::Update(float delta)
vector<sound *> snds = sounds;
for(unsigned i = 0; i < snds.size(); ++i)
{
if(sounds[i]->stopping && !sounds[i]->flush_bufs)
{
/* This sound is done. */
snds[i]->snd->SoundStopped();
}
if(!sounds[i]->stopping) continue;
if(GetPosition(snds[i]->snd) < sounds[i]->flush_pos)
continue; /* stopping but still flushing */
/* This sound is done. */
snds[i]->snd->SoundStopped();
}
}
@@ -12,7 +12,7 @@ class RageSound_WaveOut: public RageSoundDriver
bool stopping;
int flush_bufs; /* state == STOPPING only */
int flush_pos; /* state == STOPPING only */
sound() { snd = NULL; stopping=false; }
};