public void PlayAnAvailableCopy() { SoundSource soundToBindAndPlay = null; if (s_AvailableSoundSources.Count < s_MaxSimultaneousSounds) { soundToBindAndPlay = new SoundSource(); s_AvailableSoundSources.Add(soundToBindAndPlay); } else { // Find the first sound not playing. foreach (SoundSource notPlayingSound in s_AvailableSoundSources) { #if USE_OPENAL int playingValue; Al.alGetSourcei(notPlayingSound.m_SourceHandle, (int)Al.AL_SOURCE_STATE, out playingValue); if (playingValue == (int)Al.AL_STOPPED) { soundToBindAndPlay = notPlayingSound; break; } #endif } // TODO: No sound is available that is not playing. Find the quietest sound and if it is quieter than // the sound we are about to play than play it. } if (soundToBindAndPlay != null) { soundToBindAndPlay.BindToBuffer(this); soundToBindAndPlay.Play(); } }
public SoundSource GetSoundSource() { SoundSource soundSource = new SoundSource(); if (soundSource.BindToBuffer(this)) { return soundSource; } return null; }