diff --git a/stepmania/src/arch/Sound/RageSoundDriver_Linux.cpp b/stepmania/src/arch/Sound/RageSoundDriver_Linux.cpp index 55bb5a5275..5727794871 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_Linux.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_Linux.cpp @@ -244,26 +244,33 @@ float RageSound_Linux::GetPlayLatency() const { RageSound_Linux::RageSound_Linux() { last_pos = 0; + shutdown = false; MixerThreadPtr = SDL_CreateThread(MixerThread_start,this); } RageSound_Linux::~RageSound_Linux() { LOG->Trace("RageSoundDriver_Linux::~RageSoundDriver_Linux(): Shutting down mixer thread ..."); + shutdown = true; SDL_WaitThread(MixerThreadPtr, NULL); LOG->Trace("Mixer thread shut down."); CloseAudio(); } -void RageSound_Linux::MixerThread() { - ; -} - int RageSound_Linux::MixerThread_start(void *p) { ((RageSound_Linux *) p)->MixerThread(); return 0; } +void RageSound_Linux::MixerThread() { + /* SOUNDMAN will be set once RageSoundManager's ctor returns and + * assigns it; we might get here before that happens, though. */ + while(!SOUNDMAN && !shutdown) sleep(10); + while(!shutdown) { while (GetData()); } +} + + + diff --git a/stepmania/src/arch/Sound/RageSoundDriver_Linux.h b/stepmania/src/arch/Sound/RageSoundDriver_Linux.h index c0e86cb3b2..c64ea1a11d 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_Linux.h +++ b/stepmania/src/arch/Sound/RageSoundDriver_Linux.h @@ -35,6 +35,7 @@ class RageSound_Linux : public RageSoundDriver { Sint16 *chunks[8]; /* chunks of sound buffer */ snd_pcm_t *playback_handle; /* Handle for PCM device */ int last_pos; + bool shutdown; void RecoverState(long state); /* Recover from various states */