mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
iOS: fix audio clicks immediately after playing a source. Resolves issue #1485.
This commit is contained in:
@@ -919,27 +919,31 @@ bool Source::playAtomic(ALuint source)
|
|||||||
// Clear errors.
|
// Clear errors.
|
||||||
alGetError();
|
alGetError();
|
||||||
|
|
||||||
alSourcePlay(source);
|
// 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;
|
bool success = alGetError() == AL_NO_ERROR;
|
||||||
|
|
||||||
|
alSourcePlay(source);
|
||||||
|
|
||||||
|
success &= alGetError() == AL_NO_ERROR;
|
||||||
|
|
||||||
if (sourceType == TYPE_STREAM)
|
if (sourceType == TYPE_STREAM)
|
||||||
{
|
{
|
||||||
valid = true; //isPlaying() needs source to be valid
|
valid = true; //isPlaying() needs source to be valid
|
||||||
if (!isPlaying())
|
if (!isPlaying())
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
else if (success)
|
|
||||||
{
|
|
||||||
alSourcef(source, AL_SAMPLE_OFFSET, offsetSamples);
|
|
||||||
success = alGetError() == AL_NO_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
valid = true; //stop() needs source to be valid
|
valid = true; //stop() needs source to be valid
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Static sources: reset the pending offset since it's not valid anymore.
|
||||||
if (sourceType != TYPE_STREAM)
|
if (sourceType != TYPE_STREAM)
|
||||||
offsetSamples = offsetSeconds = 0;
|
offsetSamples = offsetSeconds = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user