Fons Adriaensen wrote:
snd_ctl_elem_value_alloca(&value);
snd_ctl_elem_value_set_interface(value, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_value_set_name(value, "Sample Clock Source");
snd_ctl_elem_value_set_enumerated(value, 0, 3); /* 3: 48 kHz */
So it's actually quite simple (in this case -- I imagine there are
more complex things as well, if not why does the API have a zillion
functions).
Most of these functions are for accessing structure elements that ALSA
doesn't want to expose directly so that the structure layout can change
in future library versions. In an API like OSS, the code above would
look like this, without separate functions:
snd_ctl_elem_value_t value;
value.interface = SND_CTL_ELEM_IFACE_MIXER;
strcpy(value.name, "Sample Clock Source");
value.enumerated[0] = 3;
One mor question: is there a way to obtain a
'handle' on a
control element so it can be updated frequently without the
overhead of textual encoding and decoding each time ?
snd_ctl_elem_info_alloca(&info)
snd_ctl_elem_info_set_interface(info, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_info_set_name(info, "Sample Clock Source");
CHECK(snd_ctl_elem_info(ctl, info));
id = snd_ctl_elem_info_get_numid(info);
(This is the same id value as shown by alsactl/amixer.)
snd_ctl_elem_value_set_numid(value, id);
snd_ctl_elem_value_set_enumerated(value, 0, 3);
CHECK(snd_ctl_elem_write(ctl, value));
HTH
Clemens