fix up stopping
This commit is contained in:
@@ -78,10 +78,8 @@ 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;
|
||||||
if(sounds[i]->flush_bufs)
|
|
||||||
sounds[i]->flush_bufs--;
|
|
||||||
} else {
|
|
||||||
/* Call the callback. */
|
/* Call the callback. */
|
||||||
unsigned got = sounds[i]->snd->GetPCM((char *) buf, len, play_pos);
|
unsigned got = sounds[i]->snd->GetPCM((char *) buf, len, play_pos);
|
||||||
|
|
||||||
@@ -92,8 +90,7 @@ bool RageSound_DSound_Software::GetPCM()
|
|||||||
{
|
{
|
||||||
/* This sound is finishing. */
|
/* This sound is finishing. */
|
||||||
sounds[i]->stopping = true;
|
sounds[i]->stopping = true;
|
||||||
sounds[i]->flush_bufs = 2;
|
sounds[i]->flush_pos = str_ds->GetMaxPosition();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,13 +119,15 @@ 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;
|
||||||
{
|
|
||||||
|
if(GetPosition(snds[i]->snd) < snds[i]->flush_pos)
|
||||||
|
continue; /* stopping but still flushing */
|
||||||
|
|
||||||
/* This sound is done. */
|
/* This sound is done. */
|
||||||
snds[i]->snd->SoundStopped();
|
snds[i]->snd->SoundStopped();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void RageSound_DSound_Software::StopMixing(RageSound *snd)
|
void RageSound_DSound_Software::StopMixing(RageSound *snd)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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,10 +85,8 @@ 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;
|
||||||
if(sounds[i]->flush_bufs)
|
|
||||||
sounds[i]->flush_bufs--;
|
|
||||||
} else {
|
|
||||||
/* Call the callback. */
|
/* Call the callback. */
|
||||||
unsigned got = sounds[i]->snd->GetPCM((char *) buf, chunksize, last_cursor_pos);
|
unsigned got = sounds[i]->snd->GetPCM((char *) buf, chunksize, last_cursor_pos);
|
||||||
|
|
||||||
@@ -99,8 +97,7 @@ bool RageSound_WaveOut::GetPCM()
|
|||||||
{
|
{
|
||||||
/* This sound is finishing. */
|
/* This sound is finishing. */
|
||||||
sounds[i]->stopping = true;
|
sounds[i]->stopping = true;
|
||||||
sounds[i]->flush_bufs = num_chunks;
|
sounds[i]->flush_pos = last_cursor_pos + (got / samplesize);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,13 +130,15 @@ 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;
|
||||||
{
|
|
||||||
|
if(GetPosition(snds[i]->snd) < sounds[i]->flush_pos)
|
||||||
|
continue; /* stopping but still flushing */
|
||||||
|
|
||||||
/* This sound is done. */
|
/* This sound is done. */
|
||||||
snds[i]->snd->SoundStopped();
|
snds[i]->snd->SoundStopped();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void RageSound_WaveOut::StopMixing(RageSound *snd)
|
void RageSound_WaveOut::StopMixing(RageSound *snd)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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