Source:play now returns false if alSourcePlay failed

This commit is contained in:
Alex Szpakowski
2014-01-29 17:04:03 -04:00
parent 007d0d5216
commit 33f12a6091
3 changed files with 12 additions and 5 deletions
+1 -3
View File
@@ -161,9 +161,7 @@ bool Pool::play(Source *source, ALuint &out)
source->retain();
source->playAtomic();
ok = true;
ok = source->playAtomic();
}
else
{
+10 -1
View File
@@ -513,7 +513,7 @@ bool Source::isLooping() const
return looping;
}
void Source::playAtomic()
bool Source::playAtomic()
{
if (type == TYPE_STATIC)
{
@@ -540,10 +540,19 @@ void Source::playAtomic()
// of the new one.
reset();
// Clear errors.
alGetError();
alSourcePlay(source);
// alSourcePlay may fail if the system has reached its limit of simultaneous
// playing sources.
bool success = alGetError() == AL_NO_ERROR;
valid = true; //if it fails it will be set to false again
//but this prevents a horrible, horrible bug
return success;
}
void Source::stopAtomic()
+1 -1
View File
@@ -118,7 +118,7 @@ public:
virtual float getMaxDistance() const;
virtual int getChannels() const;
void playAtomic();
bool playAtomic();
void stopAtomic();
void pauseAtomic();
void resumeAtomic();