Browse Source

Added potential fix for MacOSX thread problem.

rude 16 years ago
parent
commit
37745bf745
2 changed files with 11 additions and 2 deletions
  1. 6 2
      src/modules/audio/openal/Audio.cpp
  2. 5 0
      src/modules/audio/openal/Audio.h

+ 6 - 2
src/modules/audio/openal/Audio.cpp

@@ -27,6 +27,7 @@ namespace audio
 namespace openal
 namespace openal
 {
 {
 	Audio::Audio()
 	Audio::Audio()
+		: finish(false)
 	{
 	{
 		// Passing zero for default device.
 		// Passing zero for default device.
 		device = alcOpenDevice(0);
 		device = alcOpenDevice(0);
@@ -52,7 +53,10 @@ namespace openal
 
 
 	Audio::~Audio()
 	Audio::~Audio()
 	{
 	{
-		SDL_KillThread(thread);
+		finish = true;
+
+		int status;
+		SDL_WaitThread(thread, &status);
 
 
 		pool->stop();
 		pool->stop();
 
 
@@ -67,7 +71,7 @@ namespace openal
 	{
 	{
 		Audio * instance = (Audio*)d;
 		Audio * instance = (Audio*)d;
 		
 		
-		while(true)
+		while(!instance->finish)
 		{
 		{
 			instance->pool->update();
 			instance->pool->update();
 			SDL_Delay(10);
 			SDL_Delay(10);

+ 5 - 0
src/modules/audio/openal/Audio.h

@@ -65,6 +65,11 @@ namespace openal
 		// The Pool.
 		// The Pool.
 		Pool * 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);
 		static int run(void * unused);
 
 
 	public:
 	public: