Fix slow (90-100ms) sound shutdown.

This commit is contained in:
Glenn Maynard
2003-11-01 06:41:14 +00:00
parent 16e3bef257
commit af93453cc9
3 changed files with 13 additions and 0 deletions
@@ -62,6 +62,12 @@ void RageSound_DSound::MixerThread()
; ;
} }
} }
/* I'm not sure why, but if we don't stop the stream now, then the thread will take
* 90ms (our buffer size) longer to close. */
for(unsigned i = 0; i < stream_pool.size(); ++i)
if(stream_pool[i]->state != stream_pool[i]->INACTIVE)
stream_pool[i]->str_ds->Stop();
} }
void RageSound_DSound::Update(float delta) void RageSound_DSound::Update(float delta)
@@ -51,6 +51,10 @@ void RageSound_DSound_Software::MixerThread()
while(GetData()) while(GetData())
; ;
} }
/* I'm not sure why, but if we don't stop the stream now, then the thread will take
* 90ms (our buffer size) longer to close. */
str_ds->Stop();
} }
bool RageSound_DSound_Software::GetData() bool RageSound_DSound_Software::GetData()
@@ -56,6 +56,8 @@ void RageSound_WaveOut::MixerThread()
WaitForSingleObject(sound_event, 10); WaitForSingleObject(sound_event, 10);
} }
waveOutReset(wo);
} }
bool RageSound_WaveOut::GetData() bool RageSound_WaveOut::GetData()
@@ -209,6 +211,7 @@ RageSound_WaveOut::~RageSound_WaveOut()
{ {
/* Signal the mixing thread to quit. */ /* Signal the mixing thread to quit. */
shutdown = true; shutdown = true;
SetEvent( sound_event );
LOG->Trace("Shutting down mixer thread ..."); LOG->Trace("Shutting down mixer thread ...");
MixingThread.Wait(); MixingThread.Wait();
LOG->Trace("Mixer thread shut down."); LOG->Trace("Mixer thread shut down.");