mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Don't reset song counter (for tell) when the decoder loops, but when the song does (bug #251)
This commit is contained in:
@@ -34,7 +34,8 @@ namespace openal
|
|||||||
|
|
||||||
Source::Source(Pool * pool, love::sound::SoundData * soundData)
|
Source::Source(Pool * pool, love::sound::SoundData * soundData)
|
||||||
: love::audio::Source(Source::TYPE_STATIC), pool(pool), valid(false),
|
: love::audio::Source(Source::TYPE_STATIC), pool(pool), valid(false),
|
||||||
pitch(1.0f), volume(1.0f), looping(false), offsetSamples(0), offsetSeconds(0), decoder(0)
|
pitch(1.0f), volume(1.0f), looping(false), offsetSamples(0), offsetSeconds(0),
|
||||||
|
decoder(0), toLoop(0)
|
||||||
{
|
{
|
||||||
alGenBuffers(1, buffers);
|
alGenBuffers(1, buffers);
|
||||||
ALenum fmt = getFormat(soundData->getChannels(), soundData->getBits());
|
ALenum fmt = getFormat(soundData->getChannels(), soundData->getBits());
|
||||||
@@ -49,7 +50,8 @@ namespace openal
|
|||||||
|
|
||||||
Source::Source(Pool * pool, love::sound::Decoder * decoder)
|
Source::Source(Pool * pool, love::sound::Decoder * decoder)
|
||||||
: love::audio::Source(Source::TYPE_STREAM), pool(pool), valid(false),
|
: love::audio::Source(Source::TYPE_STREAM), pool(pool), valid(false),
|
||||||
pitch(1.0f), volume(1.0f), looping(false), offsetSamples(0), offsetSeconds(0), decoder(decoder)
|
pitch(1.0f), volume(1.0f), looping(false), offsetSamples(0), offsetSeconds(0),
|
||||||
|
decoder(decoder), toLoop(0)
|
||||||
{
|
{
|
||||||
decoder->retain();
|
decoder->retain();
|
||||||
alGenBuffers(MAX_BUFFERS, buffers);
|
alGenBuffers(MAX_BUFFERS, buffers);
|
||||||
@@ -496,11 +498,25 @@ namespace openal
|
|||||||
alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate());
|
alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate());
|
||||||
|
|
||||||
if(decoder->isFinished() && isLooping()) {
|
if(decoder->isFinished() && isLooping()) {
|
||||||
offsetSamples = 0;
|
int queued, processed;
|
||||||
offsetSeconds = 0;
|
alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
|
||||||
|
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
||||||
|
if (queued > processed)
|
||||||
|
toLoop = queued-processed;
|
||||||
|
else
|
||||||
|
toLoop = MAX_BUFFERS-processed;
|
||||||
d->rewind();
|
d->rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toLoop > 0)
|
||||||
|
{
|
||||||
|
if (--toLoop == 0)
|
||||||
|
{
|
||||||
|
offsetSamples = 0;
|
||||||
|
offsetSeconds = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return decoded;
|
return decoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ namespace openal
|
|||||||
|
|
||||||
love::sound::Decoder * decoder;
|
love::sound::Decoder * decoder;
|
||||||
|
|
||||||
|
unsigned int toLoop;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Source(Pool * pool, love::sound::SoundData * soundData);
|
Source(Pool * pool, love::sound::SoundData * soundData);
|
||||||
Source(Pool * pool, love::sound::Decoder * decoder);
|
Source(Pool * pool, love::sound::Decoder * decoder);
|
||||||
|
|||||||
Reference in New Issue
Block a user