[openal] Make OpenAL use ALSA PLUG:DMIX
chris.kcat at gmail.com
Mon Apr 21 03:59:51 EDT 2014
On 04/20/2014 11:08 PM, rogerx.oss at gmail.com wrote:
> I'm trying to get FlightGear to work around my custom .asoundrc file for which
> intentionally prevents dmix from being used. FlightGear alongside it's now
> internal FGCom, tends to assume ALSA is using DMix from the start. If a user
> has a custom ALSA $HOME/.soundrc file, FlightGear's internal FGCom may not work
> at all if the default ALSA dmix is being bypassed, as the sound device is
> already being used by FlightGear. And with little error output I may mention!
> So, I have tried the following without success:
> drivers = alsa
> device = dmix
> device-prefix = plug:
> (Prior versions seem to allow "device = plug:dmix", until device-prefix was
> implemented? Many on the mailing lists seem to have used this plug:dmix in the
> past with success.)
Setting "device = plug:dmix" should still work as it always has. The
device-prefix option only affects discovered devices (i.e. the hw:x,y
devices; it allows for replacing the 'hw:' portion of the device
string). ALSA Default still uses the device config option as-is.
> Using the above, and performing the following I can see openal picking up the
> dmix device, but openal/FlightGear does not use the device and still insists on
> using the hardware devices only! (ie. aplay -l)
> $ ALSOFT_LOGLEVEL=3 fgfs
> AL lib: (II) probe_devices: Got device "Xonar STX, Multichannel (CARD=STX,DEV=0)", "plug:CARD=STX,DEV=0"
> AL lib: (II) GetConfigValue: Key alsa:device-prefix-STX-1 not found
> AL lib: (II) probe_devices: Got device "Xonar STX, Digital (CARD=STX,DEV=1)", "plug:CARD=STX,DEV=1"
> AL lib: (II) GetConfigValue: Found alsa:device = "dmix"
> AL lib: (II) GetConfigValue: Found alsa:device-prefix = "plug:"
> AL lib: (II) alcOpenDevice: Created device 0xc989280, "ALSA Default"
According to this, it's opening the "ALSA Default" device which
corresponds to the 'device = dmix' config option, so it is using dmix.
The AL lib: (II) probe_devices: Got device ... lines are merely
logging the extra devices it found for enumeration, but aren't opening them.
Note that dmix itself will open a hardware device (anything that
ultimately plays audio must have a hardware device open somewhere), so
when an app opens dmix, aplay -l will show a hardware device as being in
use. However, other apps that also try to open dmix will still work
since dmix will share the device and do software mixing.
Do you have PulseAudio installed? Normally when it's installed, ALSA's
'default' device is mapped to 'pulse', and PulseAudio (which provides
its own software mixing) needs hardware access to do low-level work. So
if one app tries to use dmix and another tries default/pulse, one will
fail to work properly since they both want hardware to provide software
mixing. If that's the case, making both apps use the same device
(default or dmix) should work.
> Another funny thing, specifying "frequency = 44100", openal still insists on
> using 48000 even though this S/PDIF bus do 44100. Likely this is indicative
> FlightGear is hard-coding some values?
An application shouldn't be able to override what you have set (it can
provide its own hint, but the config option overrides it). If you
specify 44100 and ALSA is opening it with 48000, then ALSA can't open
the device with 44100hz and gets 48000hz instead for some reason.
More information about the openal