[alsa-devel] What's the deal with elements?

Clemens Ladisch clemens at ladisch.de
Wed Nov 23 09:03:21 CET 2011

Borg Onion wrote:
> Element used = 0, count = 7
> Whenever I try to access the elements by their index though, I get errors.

It's hard to find out what you're talking about without the code, but
this looks as if you've called snd_ctl_elem_list_get_used/count() and
are now wondering why the other snd_ctl_elem_list_get_* functions don't

> What's the meaning of "used" vs. "count"?

The count is the number of elements that the card has.
"used" is the number of elements that you have in the list.

To actually get element IDs, you have to allocate space for them with
snd_ctl_elem_list_alloc_space() (and then don't forget to call
snd_ctl_elem_list_free_space() afterwards), and call snd_ctl_elem_list()
again.  (All this is quite undocumented.)

> What are these elements used for?

Mixer controls.

> How does one do device discovery?

snd_device_name_hint(), or functions like snd_ctl_pcm_next_device().


More information about the Alsa-devel mailing list