From 14abf2c9e8533bece2d1b8570306e7b0be29312c Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 23 Apr 2019 21:30:32 -0300 Subject: [PATCH] Move source seeking from Source::playAtomic to prepareAtomic. Fixes love.audio.play(sources) for sources which had seek() called before the play call. --- src/modules/audio/openal/Source.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/modules/audio/openal/Source.cpp b/src/modules/audio/openal/Source.cpp index 934229746..a6aee3cb5 100644 --- a/src/modules/audio/openal/Source.cpp +++ b/src/modules/audio/openal/Source.cpp @@ -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) {