mirror of
https://github.com/love2d/love.git
synced 2026-08-17 02:58:31 +02:00
Added looping in love.audio (though needs implementation in love.sound).
This commit is contained in:
@@ -55,7 +55,7 @@ namespace openal
|
||||
{
|
||||
for(int i = 0; i < NUM_BUFFERS; i++)
|
||||
{
|
||||
if(!stream(buffers[i]))
|
||||
if(!stream(s, buffers[i]))
|
||||
{
|
||||
std::cout << "Could not stream music." << std::endl;
|
||||
return;
|
||||
@@ -82,7 +82,7 @@ namespace openal
|
||||
// Get a free buffer.
|
||||
alSourceUnqueueBuffers(source, 1, &buffer);
|
||||
|
||||
if(stream(buffer))
|
||||
if(stream(s, buffer))
|
||||
alSourceQueueBuffers(source, 1, &buffer);
|
||||
}
|
||||
}
|
||||
@@ -111,8 +111,11 @@ namespace openal
|
||||
play(s);
|
||||
}
|
||||
|
||||
bool Music::stream(ALuint buffer)
|
||||
bool Music::stream(love::audio::Source * source, ALuint buffer)
|
||||
{
|
||||
if(source->isLooping() && decoder->isFinished())
|
||||
decoder->rewind();
|
||||
|
||||
// Get more sound data.
|
||||
int decoded = decoder->decode();
|
||||
|
||||
@@ -131,6 +134,7 @@ namespace openal
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // openal
|
||||
} // audio
|
||||
} // love
|
||||
@@ -48,10 +48,10 @@ namespace openal
|
||||
Pool * pool;
|
||||
love::sound::Decoder * decoder;
|
||||
ALuint source;
|
||||
|
||||
public:
|
||||
Music(Pool * pool, love::sound::Decoder * decoder);
|
||||
virtual ~Music();
|
||||
|
||||
|
||||
// Implements Audible.
|
||||
void play(love::audio::Source * source);
|
||||
@@ -63,7 +63,7 @@ namespace openal
|
||||
love::audio::Music * clone();
|
||||
|
||||
private:
|
||||
bool stream(ALuint buffer);
|
||||
bool stream(love::audio::Source * source, ALuint buffer);
|
||||
}; // Sound
|
||||
|
||||
} // openal
|
||||
|
||||
@@ -58,12 +58,16 @@ namespace openal
|
||||
source = pool->find(s);
|
||||
|
||||
if(source)
|
||||
{
|
||||
alSourcei(source, AL_BUFFER, buffer);
|
||||
alSourcei(source, AL_LOOPING, s->isLooping() ? AL_TRUE : AL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void Sound::update(love::audio::Source * s)
|
||||
{
|
||||
// No need.
|
||||
// Looping mode could have changed.
|
||||
alSourcei(source, AL_LOOPING, s->isLooping() ? AL_TRUE : AL_FALSE);
|
||||
}
|
||||
|
||||
void Sound::stop(love::audio::Source * s)
|
||||
|
||||
Reference in New Issue
Block a user