[openal] Querying format type/channels for non-loopback devices

Chris Robinson chris.kcat at gmail.com
Thu Aug 21 23:34:40 EDT 2014

On 08/21/2014 08:22 AM, Peter Mulholland wrote:
> Hi,
> a real (non loopback) device is gated off, and returns
> ALC_INVALID_VALUE. I really dont see why this is the case. It could be
> very useful to know this.
> For example, I'd like to use this in our Witcher 2 port to detect
> whether the audio system has been configured to provide 5.1/7.1 support.
> If it is, we could create a source with the appropriate format and send
> 5.1/7.1 data directly through openal-soft.

The biggest problem is because there might not necessarily be a valid 
enum to provide back. For instance, OpenAL Soft has an internal "5.1 
Side" speaker configuration, which is like "5.1 Surround" except the 
rear channels (at +/-120 degrees) are replaced by side channels (at 
+/-90 degrees). If you were to match the 5.1 Side configuration to a 
known configuration that fits (only contains speakers that are available 
for output), you'd simply get stereo.

Future updates may even provide a way for users to manually define a 
configuration, like 3-channel (left, right, center), 4.1, 5.0, etc, 
rather than having to use one from a premade selection.

A better way I think would be to make a set of speaker defines, such as 
ALC_FRONT_LEFT, ALC_FRONT_CENTER, ALC_LFE, etc. Then you can query the 
number of channels and what those channels are, so you can decide how to 
construct your input stream(s). The downside, though, is that it would 
require defining every speaker that could be used, which could be a lot 
(for reference, PulseAudio defines 18 distinct speakers/channel 
positions, or 19 including 'mono', along with 32 'auxiliary' positions).

> In fact, finding out what the user has manually configured in their
> .alsoftrc could be useful.. but thats a larger problem :)

You can enable info-level logging by setting the ALSOFT_LOGLEVEL 
environment variable to 3 when running the app, and that will print out 
what configuration settings it detects, what devices get opened, what 
device settings are set, etc. By default it prints to stderr, but you 
can change that with the ALSOFT_LOGFILE environment variable. e.g.

$ ALSOFT_LOGLEVEL=3 ALSOFT_LOGFILE=/dev/stdout ./myapp

will print info-level output to stdout, and


will write info-level output to the mylog.txt in the current directory 
(any existing contents will be erased).

More information about the openal mailing list