Skip to content

Instantly share code, notes, and snippets.

@shanev
Created February 17, 2011 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanev/832813 to your computer and use it in GitHub Desktop.
Save shanev/832813 to your computer and use it in GitHub Desktop.
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