Move source seeking from Source::playAtomic to prepareAtomic. Fixes love.audio.play(sources) for sources which had seek() called before the play call.

This commit is contained in:
Alex Szpakowski
2019-04-23 21:30:32 -03:00
parent 276bdd1dbf
commit 14abf2c9e8
+4 -8
View File
@@ -863,6 +863,9 @@ void Source::prepareAtomic()
case TYPE_MAX_ENUM:
break;
}
// Seek to the current/pending offset.
alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
}
void Source::teardownAtomic()
@@ -919,16 +922,9 @@ bool Source::playAtomic(ALuint source)
// Clear errors.
alGetError();
// Seek to the current/pending offset before playing. If this call happens
// immediately after alSourcePlay it could introduce a click depending on
// the platform, because the source is asynchronously playing by then.
alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
bool success = alGetError() == AL_NO_ERROR;
alSourcePlay(source);
success &= alGetError() == AL_NO_ERROR;
bool success = alGetError() == AL_NO_ERROR;
if (sourceType == TYPE_STREAM)
{