[openal] Releasing openal-soft with linux games

Chris Robinson chris.kcat at gmail.com
Wed Jun 18 18:32:31 EDT 2014


On 06/15/2014 08:44 PM, Mark Sibly wrote:
> Another quicky: How can I tell whether the system openal is in fact
> openal-soft? And if so, which version?

Generally speaking, you should check for the capabilities that you 
actually want (extensions, function behaviors, etc), rather than the 
specific implementation/version. It's entirely possible for another 
implementation to come around, now or in the future, that does 
everything you need, and there's no real reason to restrict it. Of 
course, having a default version (which you built/tested with, and ship 
with) is entirely reasonable.

But if you really want to check, the AL_VERSION string will tell you. 
For OpenAL Soft, it's in the format:

<core_major>.<core_minor> ALSOFT <lib_major>.<lib_minor>[.<lib_rev>]

So to parse that using sscanf, you can do:

int alsoftver[2];
const ALchar *verstring = alGetString(AL_VERSION);
int ret = sscanf(verstring, "%*d.%*d ALSOFT %d.%d", &alsoftver[0],
                  &alsoftver[1]);
if(ret == 2)
     printf("Detected OpenAL Soft, library version %d.%d",
             alsoftver[0], alsoftver[1]);

The lib may have a third version point, but not all versions report it. 
If you want it, you could do:

int alsoftver[3];
const ALchar *verstring = alGetString(AL_VERSION);
int ret = sscanf(verstring, "%*d.%*d ALSOFT %d.%d.%d", &alsoftver[0],
                  &alsoftver[1], &alsoftver[2]);
if(ret >= 2)
{
     if(ret == 2)
         alsoftver[2] = 0;
     printf("Detected OpenAL Soft, library version %d.%d.%d",
             alsoftver[0], alsoftver[1], alsoftver[2]);
}


Note that you can only safely call alGetString after a context has been 
made current, and it applies only to the device that context belongs to.


More information about the openal mailing list