[][src]Type Definition alsa_sys::snd_ctl_elem_value_t

type snd_ctl_elem_value_t = _snd_ctl_elem_value;

CTL element value container

Contains the value(s) (i.e. members) of a single element. All values of a given element are of the same type.

\par Memory management

To access a value, a snd_ctl_elem_value_t must be allocated using snd_ctl_elem_value_alloca() or snd_ctl_elem_value_malloc(). When using the latter, it must be freed again using snd_ctl_elem_value_free().

\par Identifier

Then, the ID must be filled. It is sufficient to fill only the numid, if known. Otherwise, interface type, device, subdevice, name, index must all be given. The following functions can be used to fill the ID:

  • snd_ctl_elem_value_set_id(): Set the ID. Requires an snd_ctl_elem_id_t object.

  • snd_ctl_elem_value_set_numid(): Set the numid.

  • Or use all of the following:

    • snd_ctl_elem_value_set_interface()
    • snd_ctl_elem_value_set_device()
    • snd_ctl_elem_value_set_subdevice()
    • snd_ctl_elem_value_set_name()
    • snd_ctl_elem_value_set_index()

When communicating with the driver (snd_ctl_elem_read(), snd_ctl_elem_write()), and the numid was given, the interface, device, ... are filled (even if you set the before). When the numid is unset (i.e. it is 0), it is filled.

\par Communicating with the driver

After the value container was created and filled with the ID of the desired element, the value(s) can be fetched from the driver (and thus from the hardware) or written to the driver.

To fetch a value, use snd_ctl_elem_read(). Thereafter, use the snd_ctl_elem_value_get_*() functions to obtain the actual value.

To write a new value, first use a snd_ctl_elem_value_set_*() to set it, then call snd_ctl_elem_write() to write it to the driver.