mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Don't try to put zero-length data into OpenAL buffers (see issue #1083.)
This commit is contained in:
@@ -308,8 +308,11 @@ bool Source::update()
|
|||||||
offsetSamples += (curOffsetSamples - newOffsetSamples);
|
offsetSamples += (curOffsetSamples - newOffsetSamples);
|
||||||
offsetSeconds += (curOffsetSecs - newOffsetSecs);
|
offsetSeconds += (curOffsetSecs - newOffsetSecs);
|
||||||
|
|
||||||
streamAtomic(buffer, decoder.get());
|
// FIXME: We should put freed buffers into a list that we later
|
||||||
alSourceQueueBuffers(source, 1, &buffer);
|
// consume here, so we can keep track of all free buffers even if we
|
||||||
|
// tried to stream data to one but the decoder didn't have data for it.
|
||||||
|
if (streamAtomic(buffer, decoder.get()) > 0)
|
||||||
|
alSourceQueueBuffers(source, 1, &buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -575,8 +578,11 @@ bool Source::playAtomic()
|
|||||||
|
|
||||||
for (unsigned int i = 0; i < MAX_BUFFERS; i++)
|
for (unsigned int i = 0; i < MAX_BUFFERS; i++)
|
||||||
{
|
{
|
||||||
streamAtomic(streamBuffers[i], decoder.get());
|
if (streamAtomic(streamBuffers[i], decoder.get()) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
++usedBuffers;
|
++usedBuffers;
|
||||||
|
|
||||||
if (decoder->isFinished())
|
if (decoder->isFinished())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -736,13 +742,18 @@ ALenum Source::getFormat(int channels, int bitDepth) const
|
|||||||
int Source::streamAtomic(ALuint buffer, love::sound::Decoder *d)
|
int Source::streamAtomic(ALuint buffer, love::sound::Decoder *d)
|
||||||
{
|
{
|
||||||
// Get more sound data.
|
// Get more sound data.
|
||||||
int decoded = d->decode();
|
int decoded = std::max(d->decode(), 0);
|
||||||
decoded = decoded >= 0 ? decoded : 0;
|
|
||||||
|
|
||||||
int fmt = getFormat(d->getChannels(), d->getBitDepth());
|
// OpenAL implementations are allowed to ignore 0-size alBufferData calls.
|
||||||
|
if (decoded > 0)
|
||||||
|
{
|
||||||
|
int fmt = getFormat(d->getChannels(), d->getBitDepth());
|
||||||
|
|
||||||
if (fmt != 0)
|
if (fmt != 0)
|
||||||
alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate());
|
alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate());
|
||||||
|
else
|
||||||
|
decoded = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (decoder->isFinished() && isLooping())
|
if (decoder->isFinished() && isLooping())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user