Browse Source

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

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

+ 4 - 8
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)
 	{