Browse Source

Fix modplug-decoded streaming Sources when looping repeatedly, and when stop() is called on them. Resolves issue #1493.

Alex Szpakowski 6 years ago
parent
commit
3c77edb68b
1 changed files with 14 additions and 1 deletions
  1. 14 1
      src/modules/audio/openal/Source.cpp

+ 14 - 1
src/modules/audio/openal/Source.cpp

@@ -425,6 +425,18 @@ bool Source::update()
 						unusedBuffers.push(buffer);
 						unusedBuffers.push(buffer);
 				}
 				}
 
 
+				while (!unusedBuffers.empty())
+				{
+					ALuint b = unusedBuffers.top();
+					if (streamAtomic(b, decoder.get()) > 0)
+					{
+						alSourceQueueBuffers(source, 1, &b);
+						unusedBuffers.pop();
+					}
+					else
+						break;
+				}
+
 				return true;
 				return true;
 			}
 			}
 			return false;
 			return false;
@@ -869,7 +881,8 @@ void Source::teardownAtomic()
 		ALint queued = 0;
 		ALint queued = 0;
 		ALuint buffers[MAX_BUFFERS];
 		ALuint buffers[MAX_BUFFERS];
 
 
-		decoder->seek(0);
+		// Some decoders (e.g. ModPlug) can rewind() more reliably than seek(0).
+		decoder->rewind();
 
 
 		// Drain buffers.
 		// Drain buffers.
 		// NOTE: The Apple implementation of OpenAL on iOS doesn't return
 		// NOTE: The Apple implementation of OpenAL on iOS doesn't return