update:
I can't find a way to determine what the maximum number of sources a device supports, but I think I've found how to determine the maximum a context supports(ALC_MONO_SOURCES
). It would follow that a context supports the same number as its parent device.
//error checking omitted for brevity
ALCdevice* device = alcOpenDevice(NULL);
ALCcontext* context = alcCreateContext(device,NULL);
ALCint size;
alcGetIntegerv( device, ALC_ATTRIBUTES_SIZE, 1, &size);
std::vector<ALCint> attrs(size);
alcGetIntegerv( device, ALC_ALL_ATTRIBUTES, size, &attrs[0] );
for(size_t i=0; i<attrs.size(); ++i)
{
if( attrs[i] == ALC_MONO_SOURCES )
{
std::cout << "max mono sources: " << attrs[i+1] << std::endl;
}
}
This returns 255 on Ubuntu 10.4 using the stock OpenAL driver.
The long answer is well kinda...
Software based OpenAL drivers generally allow an infinite number of sources. Well, not really infinite, eventually you'll max out either the CPU or the RAM eventually.
Most hardware based OpenAL drivers only support as many sources as the hardware has channels. Modernly that is at least 16, probably 32 or more but can be as much as 256. There are probably sound cards that support more but 256 is the largest I've ever looked at.
On Windows DirectSound based drivers are arbitrarily limited to 31 (why not 32?) sources. DirectSound has been deprecated so I don't know if this still applies to Vista and Windows 7.
The iPhone supports 32 sources.
I have seen one hardware based driver that was software backed. Meaning it would give each source a hardware channel until they ran out. Then it would mix some of the sounds in software before shipping it off the the hardware. This gives the best of both worlds, near infinite sources, while still using as much hardware acceleration as possible.
In practice if you're using a hardware based driver, just keep creating them until alGenSources fails. I have heard this doesn't work on the iPhone. There a some software based OpenAL drivers that will crash before alGenSources fails.
There really ought to be an API to check the max number of sources and number of sources that are hardware accelerated. Maybe there is in the extensions.