fix up stopping
This commit is contained in:
@@ -78,22 +78,19 @@ bool RageSound_DSound_Software::GetPCM()
|
|||||||
for(unsigned i = 0; i < sounds.size(); ++i)
|
for(unsigned i = 0; i < sounds.size(); ++i)
|
||||||
{
|
{
|
||||||
if(sounds[i]->stopping)
|
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)
|
/* This sound is finishing. */
|
||||||
sounds[i]->flush_bufs--;
|
sounds[i]->stopping = true;
|
||||||
} else {
|
sounds[i]->flush_pos = str_ds->GetMaxPosition();
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,11 +119,13 @@ void RageSound_DSound_Software::Update(float delta)
|
|||||||
vector<sound *> snds = sounds;
|
vector<sound *> snds = sounds;
|
||||||
for(unsigned i = 0; i < snds.size(); ++i)
|
for(unsigned i = 0; i < snds.size(); ++i)
|
||||||
{
|
{
|
||||||
if(sounds[i]->stopping && !sounds[i]->flush_bufs)
|
if(!snds[i]->stopping) continue;
|
||||||
{
|
|
||||||
/* This sound is done. */
|
if(GetPosition(snds[i]->snd) < snds[i]->flush_pos)
|
||||||
snds[i]->snd->SoundStopped();
|
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;
|
bool stopping;
|
||||||
|
|
||||||
int flush_bufs; /* state == STOPPING only */
|
int flush_pos; /* state == STOPPING only */
|
||||||
|
|
||||||
sound() { snd = NULL; stopping=false; }
|
sound() { snd = NULL; stopping=false; }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -85,22 +85,19 @@ bool RageSound_WaveOut::GetPCM()
|
|||||||
for(unsigned i = 0; i < sounds.size(); ++i)
|
for(unsigned i = 0; i < sounds.size(); ++i)
|
||||||
{
|
{
|
||||||
if(sounds[i]->stopping)
|
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)
|
/* This sound is finishing. */
|
||||||
sounds[i]->flush_bufs--;
|
sounds[i]->stopping = true;
|
||||||
} else {
|
sounds[i]->flush_pos = last_cursor_pos + (got / samplesize);
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,11 +130,13 @@ void RageSound_WaveOut::Update(float delta)
|
|||||||
vector<sound *> snds = sounds;
|
vector<sound *> snds = sounds;
|
||||||
for(unsigned i = 0; i < snds.size(); ++i)
|
for(unsigned i = 0; i < snds.size(); ++i)
|
||||||
{
|
{
|
||||||
if(sounds[i]->stopping && !sounds[i]->flush_bufs)
|
if(!sounds[i]->stopping) continue;
|
||||||
{
|
|
||||||
/* This sound is done. */
|
if(GetPosition(snds[i]->snd) < sounds[i]->flush_pos)
|
||||||
snds[i]->snd->SoundStopped();
|
continue; /* stopping but still flushing */
|
||||||
}
|
|
||||||
|
/* This sound is done. */
|
||||||
|
snds[i]->snd->SoundStopped();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class RageSound_WaveOut: public RageSoundDriver
|
|||||||
|
|
||||||
bool stopping;
|
bool stopping;
|
||||||
|
|
||||||
int flush_bufs; /* state == STOPPING only */
|
int flush_pos; /* state == STOPPING only */
|
||||||
|
|
||||||
sound() { snd = NULL; stopping=false; }
|
sound() { snd = NULL; stopping=false; }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user