List of ALSA Issues

Here's my list of issues I found with the current ALSA API while developing PA:

Mixer

There's no way to detect whether a snd_smixer element is implemented in software or not. Thus writing an application that uses the PCM device hw: (or front:, surround51:, ...) and the smixer/mixer interfaces at the same time with sensible behaviour is impossible. Because for those devices software volume adjustments don't take place, and thus the controls we find are useless.

There is no way to find the right mixer device for a PCM device. There is no way to find which one is the right mixer track to use to control input and output PCM volume, other then guessing by the name.

ctl, hctl, mixer, smixer. Come on!

It is not possible to enumerate the ctl/hctl elements that make up a smixer element.

It is possible to query the dB range of a smixer element. And it is possible to query and set the current dB level. However, it is not possible to have a dB value converted to an integer level or vice versa, without touching the actual setting. i.e. a question like "What is the integer level 0 dB corresponds to?" can not be answered by ALSA. Which happens to be a serious limitation. Update:This seems fixed now

the dB scale is is almost useless. dB is a relative scale and ALSA didn't define what the reference level is. All mixer controls on all sound drivers use different reference levels. Hence the dB scale is not any more useful than that they are pretty to look at and make you feel like oh-i-am-such-a-guru-i-look-at-dB-levels.

Naming hinting apparently cannot be used to enumerate mixer devices.

It's not possible to know the inter-relation of ctls (except single switch/track couple), and the relation with actual devices: internal mic, loudspeaker, laptop red jack, rear green jack, usb headset mike (or at least, this is quite tricky, or not well exposed)

There is no way to detect in advance (i.e. when setting up the hw parameters) if rewind() would ever work on a device, thus making this functionality pretty much useless. Update: There is now sndpcm_hw_params_can_forward in alsa-lib HG. I am happy!

There's no way to disable implicit sample type, channel map conversion in plughw:. You either get a fancy-we-do-it-all device (plughw:), or a completely raw device (hw:), there's no way to selectively disable/enable any of the additional features of plughw, except for resampling. That includes the previously mentioned sample type conversion or channel map, and softvol. Update: This is fixed now, the SND_PCM_NOAUTO_xxx flags in 1.0.16 offer exactly what I need.

There's no way to detect whether spdif: can be used at the same time as any of the ther other PCM devices (i.e. front: or suchlike) of the same card or if they are exclusive. There is no API to query if opening a certain PCM device with a specific configuration will make a related PCM device return EBUSY. (i.e. there seem to be some devices where opening a 6ch output stream will cause opening the device for capturing to return EBUSY)

There's no way to disable the buffer management of ALSA, it insists on deciding what a full or an empty buffer is. It is not possible to be notified about interrupts, independantly of the buffer fill level via poll().

The is no device string for mono-only devices in style of "front:", "surround50:" and suchlike.

There is no way to disable fragment interrupts for a device entirely, which would be useful in timer-based scheduling. Update:' This apparently has been fixed at least partially, there is now snd_pcm_sw_params_set_period_event().

There is no API to query the granularity of snd_pcm_delay()

The devices with an explicit channel mapping (i.e. "surround41:", ...) cannot be used for 10ch and 12ch sound cards. There is also no definition for surround91: and surround111.

An application which wants to use surround sound has no chance to do so in any sensible way unless it goes directly to the hw devices "surround41:0" and so on. This kicks virtual drivers like PA out of the game however. This boils down to: no practical surround sound for ioplug based plugins. For ioplug based plugins only stereo and mono can be implemented sensibly.

Currently there is no point in opening "default" in anything but 1ch or 2ch, since otherwise the channel mapping is unknown.

snd_pcm_rewind() breaks playback and returns nonsense, unless the naked audio device (hw) is accessed. (i.e. all plugins such as softvol break snd_pcm_rewind()) (Update: This has been fixed in alsa-lib git shortly after the 1.0.17 release)

ioplug

General

Documentation is really bad. Misses documentation of what terms like "trigger" mean and suchlike. However, terms like that are used extensively in the documentation. The examples from the documentation lack any comments.

The API is way too verbose and large. There are too many functions that seem to be obsolete today, or that are completely redundant, or should only be used internally, and not be exported, or even appear in the documentation.

The API is way overengineered. Even if the four abstraction levels of the mixer (ctl, hctl, mixer, smixer) might make some technical sense, there is no point whatsoever to export them all in the user interface. This applies to other stuff in the API as well.

The library spams to stderr. On my mono usb soundcard (a webcam) opening the PCM device via "front:" (which rightfully fails) produces a lot of noise on stderr, which apparently cannot be disabled. And there are lots of similar cases. Update: There's snd_lib_error_set_handler() which can be used to stop this.