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

Borg Onion borg.onion at gmail.com
Thu Nov 24 06:52:55 CET 2011

> > 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.)
Wow, I NEVER would have guessed that, and I can truly find no documentation
on the call semantics here, hence my basic questions to this mailing list.

The good news is, your guidance did produce the right results.  But it
sucks you have to probe for devices with *_next_device()...you'd think ALSA
would give you a nice table of devices that are present on the card.  I was
hoping the element list would be that.  Even the "enum _snd_ctl_elem_iface"
definition hints at these element lists containing PCM devices.  Am I
missing something here?

Lastly, my calls to snd_ctl_elem_list_get_index() always return 0.
 Shouldn't they be returning the index passed in?  (I don't really get the
purpose of this function)

The source code for what I've got so far is here:


More information about the Alsa-devel mailing list