Improve Source controls

This commit is contained in:
Bart van Strien
2011-08-06 14:02:37 +02:00
parent defd6c5ee4
commit 416370b595
2 changed files with 16 additions and 5 deletions
+15 -5
View File
@@ -34,8 +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), pitch(1.0f), volume(1.0f), looping(false), paused(false), offsetSamples(0),
decoder(0), toLoop(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());
@@ -50,8 +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), pitch(1.0f), volume(1.0f), looping(false), paused(false), offsetSamples(0),
decoder(decoder), toLoop(0) offsetSeconds(0), decoder(decoder), toLoop(0)
{ {
decoder->retain(); decoder->retain();
alGenBuffers(MAX_BUFFERS, buffers); alGenBuffers(MAX_BUFFERS, buffers);
@@ -78,6 +78,12 @@ namespace openal
void Source::play() void Source::play()
{ {
if (valid && paused)
{
pool->resume(this);
return;
}
valid = pool->play(this, source); valid = pool->play(this, source);
if(valid) if(valid)
@@ -433,14 +439,16 @@ namespace openal
if(valid) if(valid)
{ {
alSourcePause(source); alSourcePause(source);
paused = true;
} }
} }
void Source::resumeAtomic() void Source::resumeAtomic()
{ {
if(valid) if(valid && paused)
{ {
alSourcePlay(source); alSourcePlay(source);
paused = false;
} }
} }
@@ -449,6 +457,8 @@ namespace openal
if(valid && type == TYPE_STATIC) if(valid && type == TYPE_STATIC)
{ {
alSourceRewind(source); alSourceRewind(source);
if (!paused)
alSourcePlay(source);
} }
else if(valid && type == TYPE_STREAM) else if(valid && type == TYPE_STREAM)
{ {
+1
View File
@@ -62,6 +62,7 @@ namespace openal
float velocity[3]; float velocity[3];
float direction[3]; float direction[3];
bool looping; bool looping;
bool paused;
float offsetSamples; float offsetSamples;
float offsetSeconds; float offsetSeconds;