From 03801e49d6bada79d65d867ba686ab792b666f8b Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 3 Apr 2016 09:58:17 -0300 Subject: [PATCH] Fix a potential issue when an OpenAL source that was previously static is reused for a streaming Source. --- src/modules/audio/openal/Source.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/audio/openal/Source.cpp b/src/modules/audio/openal/Source.cpp index a58c1fe79..99f3b7923 100644 --- a/src/modules/audio/openal/Source.cpp +++ b/src/modules/audio/openal/Source.cpp @@ -595,6 +595,11 @@ bool Source::isLooping() const bool Source::playAtomic() { + // This Source may now be associated with an OpenAL source that still has + // the properties of another love Source. Let's reset it to the settings + // of the new one. + reset(); + if (type == TYPE_STATIC) { alSourcei(source, AL_BUFFER, staticBuffer->getBuffer()); @@ -618,11 +623,6 @@ bool Source::playAtomic() alSourceQueueBuffers(source, usedBuffers, streamBuffers); } - // This Source may now be associated with an OpenAL source that still has - // the properties of another love Source. Let's reset it to the settings - // of the new one. - reset(); - // Clear errors. alGetError(); @@ -714,6 +714,7 @@ void Source::rewindAtomic() void Source::reset() { + alSourcei(source, AL_BUFFER, 0); alSourcefv(source, AL_POSITION, position); alSourcefv(source, AL_VELOCITY, velocity); alSourcefv(source, AL_DIRECTION, direction);