Created
February 17, 2011 21:56
-
-
Save shanev/832813 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OSStatus PrimeEffect(UInt32 inEffectID, ALuint *sourceID) | |
{ | |
// Locate an available source. We consider a source available if it is either not primed or is in the stoppped state | |
for (int i = 0; i < MAX_SOURCES; ++i){ | |
if (! mSourcePrimed[i]){ | |
mSourcePrimed[i] = TRUE; | |
alSourcei(mSourceID[i], AL_BUFFER, inEffectID); | |
*sourceID = mSourceID[i]; | |
return alGetError(); | |
} | |
ALint sourceState; | |
alGetSourcei(mSourceID[i], AL_SOURCE_STATE, &sourceState); | |
if (sourceState == AL_STOPPED){ | |
alSourcei(mSourceID[i], AL_BUFFER, inEffectID); | |
*sourceID = mSourceID[i]; | |
return 0; | |
} | |
} | |
// If we fell through the loop, then no available sources | |
return kSoundEngineErrNoSourcesAvailable; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment