[openal] number of maximum sources. was: distance model questions

Chris Robinson chris.kcat at gmail.com
Thu Jul 30 06:29:39 EDT 2015

On 07/29/2015 11:55 PM, Victorious wrote:
> How was the limit of 255 mono and 1 stereo source chosen? Also, I'd
> like to increase this for stereo sources e.g 1 stereo source for
> background music, another stereo source for environmental ambient
> sounds.

You can request a specific number of stereo sources during context creation.

ALCint attr[3] = {
     0 /* end-of-list */
context = alcCreateContext(device, attr);

For OpenAL Soft, this will result in a "limit" of 254 mono sources and 2 
stereo sources. Though these are only soft limits... OpenAL Soft 
ultimately doesn't care how many non-mono sources you play; as long as 
you have a source ID generated, you can play something with it. But 
other implementations may reduce the number of sources you can play for 
each stereo source playing above the specified limit.

Personally, I'd like to see these separate mono/stereo source limits 
removed. I understand why it exists (certain implementations have a hard 
limit on the number of simultaneous voices, particularly hardware, and a 
single source doesn't necessarily map to a single voice, so increasing 
the stereo source count may take away extra mono sources, and so on), 
but it's extremely clunky because an app doesn't necessarily know how 
many stereo sources they'll play at once, and 4+ channel sources aren't 
accounted for at all. There has to be a better way to handle the issue.

As for why there's the 256 (255+1) limit with OpenAL Soft, it's partly a 
hold-over (IIRC, that's what both Creative's software driver and the old 
SI had), but also partly precautionary (I remember certain old tutorials 
suggesting that you could generate sources in a loop and just stop when 
it fails to create any more; if there was no source limit, this would 
cause such an app to lock up while it eats up all the system memory). 
There are things I could do to remove the limit without risking poorly 
programmed apps breaking, it would just require interested apps to be a 
bit proactive.

More information about the openal mailing list