[Openal] Max number of sources (and legit id values) for
eachOpenAL implementation
Chris Robinson
chris.kcat at gmail.com
Wed Jul 22 18:45:39 PDT 2009
On Wednesday 22 July 2009 5:32:54 pm Jason Daly wrote:
> Chris Robinson wrote:
> > AFAIK, you can get the maximum number of sources by:
> >
> > ALCint nummono, numstereo;
> > alcGetIntegerv(device, ALC_MONO_SOURCES, &nummono);
> > alcGetIntegerv(device, ALC_STEREO_SOURCES, &numstereo);
> >
> > printf("Max sources: %d\n", nummono+numstereo);
>
> That query is not in the spec. It might have been added as an extension
> (you'd probably know that better than me), but it's not a standard
> query. The only standard way to get the number of available sources is
> to generate them until you get an error.
According to the spec for alcGetIntegerv, "All tokens in table 6-2 (context
creation) and table 6-4 (context query types) are valid for this call."
There's a slight error there as table 6-1 is actually context creation, and
6-2 is error conditions. The error condition enums don't make much sense for
the function, so table 6-1 is likely what it meant.
The same table also has ALC_REFRESH and ALC_FREQUENCY (which would be useful
for apps to know) with ALC_MONO_SOURCES and ALC_STEREO_SOURCES.
> Since there's no standard query for available sources, most apps will do
> this, although they also typically have their own artificial cap (give
> me as many sources as you can, up to 256). The old SI didn't have an
> arbitrary limit, so an artificial cap was necessary.
Though even if apps queried for the maximum number of sources, they would need
to force an artificial cap, all the same. There's nothing stopping an
implementation from reporting 2^31-1 sources, but you wouldn't want an app to
try blindly allocating that many up front.
Apps need to treat sources as a limited resource for maximum compatibility,
anyway. Testing and developing on a system with unlimited sources, and then
having it run on hardware with only 64 voices, would be a rather big problem.
Sources need to be managed so they can be reused/stolen/etc, on systems from
as few as 16 voices, up to however many. Fewer maximum voices will of course
degrade quality, but when you get up to 256 simultaneous sources, a good
manager should be able to make that virtually imperceptible, I think.
More information about the Openal
mailing list