diff --git a/src/modules/audio/openal/Audio.cpp b/src/modules/audio/openal/Audio.cpp index f81415e59..38a5867ae 100644 --- a/src/modules/audio/openal/Audio.cpp +++ b/src/modules/audio/openal/Audio.cpp @@ -27,6 +27,7 @@ namespace audio namespace openal { Audio::Audio() + : finish(false) { // Passing zero for default device. device = alcOpenDevice(0); @@ -52,7 +53,10 @@ namespace openal Audio::~Audio() { - //SDL_KillThread(thread); + finish = true; + + int status; + SDL_WaitThread(thread, &status); pool->stop(); @@ -61,18 +65,13 @@ namespace openal alcMakeContextCurrent(0); alcDestroyContext(context); alcCloseDevice(device); - - printf("waiting on thread to finish...\n"); - int status; - SDL_WaitThread(thread, &status); - printf("%d", status); } int Audio::run(void * d) { Audio * instance = (Audio*)d; - while(true) + while(!instance->finish) { instance->pool->update(); SDL_Delay(10); diff --git a/src/modules/audio/openal/Audio.h b/src/modules/audio/openal/Audio.h index 94f0e0e03..ba22b4216 100644 --- a/src/modules/audio/openal/Audio.h +++ b/src/modules/audio/openal/Audio.h @@ -70,6 +70,11 @@ namespace openal // The Pool. Pool * pool; + // Set this to true when the thread should finish. + // Main thread will write to this value, and Audio::run + // will read from it. + bool finish; + static int run(void * unused); public: