package projectzombie.audio;

import static org.lwjgl.openal.AL10.alGenSources;

import java.util.ArrayList;

public class AudioSources
{
	static ArrayList<Integer> sources = new ArrayList<Integer>();
	public static int upto = 0;
	private static int max = 0;
	
	public static void init()
	{
		// Generate the first source
		int source = alGenSources();
		boolean first = true;
		
		// Generate sources until OpenAL errors out
		while(source != 0 || first) {
			max = source;
			first = false;
			sources.add(source);
			source = alGenSources();
		}
	}
	
	static int getSource()
	{
		// Get the next source
		int source = sources.get(upto);
		
		// Increase the upto iterator
		upto += 1;
		upto %= max;
		
		// Send back the source
		return source;
	}
}
