Fix a potential issue when an OpenAL source that was previously static is reused for a streaming Source.

This commit is contained in:
Alex Szpakowski
2016-04-03 09:58:17 -03:00
parent 901cc362df
commit 03801e49d6
+6 -5
View File
@@ -595,6 +595,11 @@ bool Source::isLooping() const
bool Source::playAtomic() 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) if (type == TYPE_STATIC)
{ {
alSourcei(source, AL_BUFFER, staticBuffer->getBuffer()); alSourcei(source, AL_BUFFER, staticBuffer->getBuffer());
@@ -618,11 +623,6 @@ bool Source::playAtomic()
alSourceQueueBuffers(source, usedBuffers, streamBuffers); 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. // Clear errors.
alGetError(); alGetError();
@@ -714,6 +714,7 @@ void Source::rewindAtomic()
void Source::reset() void Source::reset()
{ {
alSourcei(source, AL_BUFFER, 0);
alSourcefv(source, AL_POSITION, position); alSourcefv(source, AL_POSITION, position);
alSourcefv(source, AL_VELOCITY, velocity); alSourcefv(source, AL_VELOCITY, velocity);
alSourcefv(source, AL_DIRECTION, direction); alSourcefv(source, AL_DIRECTION, direction);