Browse Source

Unbreak stop (issue #250)

Bart van Strien 14 years ago
parent
commit
0b0d8fe3e5
2 changed files with 9 additions and 10 deletions
  1. 8 9
      src/modules/audio/openal/Source.cpp
  2. 1 1
      src/modules/audio/openal/Source.h

+ 8 - 9
src/modules/audio/openal/Source.cpp

@@ -65,7 +65,7 @@ namespace openal
 
 
 	Source::~Source()
 	Source::~Source()
 	{
 	{
-		stop();
+		pool->stop(this);
 		alDeleteBuffers((type == TYPE_STATIC) ? 1 : MAX_BUFFERS, buffers);
 		alDeleteBuffers((type == TYPE_STATIC) ? 1 : MAX_BUFFERS, buffers);
 		if (decoder)
 		if (decoder)
 			decoder->release();
 			decoder->release();
@@ -93,7 +93,10 @@ namespace openal
 	void Source::stop()
 	void Source::stop()
 	{
 	{
 		if (!isStopped())
 		if (!isStopped())
+		{
 			pool->stop(this);
 			pool->stop(this);
+			rewind();
+		}
 	}
 	}
 
 
 	void Source::pause()
 	void Source::pause()
@@ -269,7 +272,7 @@ namespace openal
 				// Because we still have old data
 				// Because we still have old data
 				// from before the seek in the buffers
 				// from before the seek in the buffers
 				// let's empty them.
 				// let's empty them.
-				stopAtomic(false);
+				stopAtomic();
 				playAtomic();
 				playAtomic();
 				if (waspaused)
 				if (waspaused)
 					pauseAtomic();
 					pauseAtomic();
@@ -407,7 +410,7 @@ namespace openal
 		//but this prevents a horrible, horrible bug
 		//but this prevents a horrible, horrible bug
 	}
 	}
 
 
-	void Source::stopAtomic(bool rewind)
+	void Source::stopAtomic()
 	{
 	{
 		if(valid)
 		if(valid)
 		{
 		{
@@ -418,21 +421,17 @@ namespace openal
 			else if(type == TYPE_STREAM)
 			else if(type == TYPE_STREAM)
 			{
 			{
 				alSourceStop(source);
 				alSourceStop(source);
-
 				int queued = 0;
 				int queued = 0;
 				alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
 				alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
 
 
-				while(queued--)
+				while (queued--)
 				{
 				{
 					ALuint buffer;
 					ALuint buffer;
 					alSourceUnqueueBuffers(source, 1, &buffer);
 					alSourceUnqueueBuffers(source, 1, &buffer);
 				}
 				}
 			}
 			}
-
 			alSourcei(source, AL_BUFFER, AL_NONE);
 			alSourcei(source, AL_BUFFER, AL_NONE);
 		}
 		}
-		if (rewind)
-			rewindAtomic();
 		toLoop = 0;
 		toLoop = 0;
 		valid = false;
 		valid = false;
 	}
 	}
@@ -470,7 +469,7 @@ namespace openal
 			// Because we still have old data
 			// Because we still have old data
 			// from before the seek in the buffers
 			// from before the seek in the buffers
 			// let's empty them.
 			// let's empty them.
-			stopAtomic(false);
+			stopAtomic();
 			playAtomic();
 			playAtomic();
 			if (waspaused)
 			if (waspaused)
 				pauseAtomic();
 				pauseAtomic();

+ 1 - 1
src/modules/audio/openal/Source.h

@@ -105,7 +105,7 @@ namespace openal
 		bool isStatic() const;
 		bool isStatic() const;
 
 
 		void playAtomic();
 		void playAtomic();
-		void stopAtomic(bool rewind = true);
+		void stopAtomic();
 		void pauseAtomic();
 		void pauseAtomic();
 		void resumeAtomic();
 		void resumeAtomic();
 		void rewindAtomic();
 		void rewindAtomic();