On Fri, Nov 14, 2008 at 10:31:14AM +0100, Clemens Ladisch wrote:
   Is there,
after X years of ALSA, any documentation that
 explains the basic concepts and tells me how to do this ? 
 No. 
 
Thanks for the confirmation, and for the example code.
The first ever LAC lecture I attended was Takashi
introducing ALSA at the first conference.
I'd like to invite those who know more to present a
paper / workshop on the subject at LAC 2009...
   how I can e.g.
set the sample clock source on a RME MADI card
 in less than ten lines of C code 
 system("amixer cset name='Sample Clock Source' 3"); 
 
:-)
  #include <stdio.h>
 #include <stdlib.h>
 #include <alsa/asoundlib.h>
 static void check(int err, const char *f)
 {
         if (err < 0) {
                 fprintf(stderr, "%s failed: %s\n", f, snd_strerror(err));
                 exit(EXIT_FAILURE);
         }
 }
 #define CHECK(f) check(f, #f)
 int main()
 {
         snd_ctl_t *ctl;
         snd_ctl_elem_value_t *value;
         CHECK(snd_ctl_open(&ctl, "default", 0));
         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 */
         CHECK(snd_ctl_elem_write(ctl, value));
         snd_ctl_close(ctl);
         return 0;
 } 
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).  The problem is that starting from the existing docs it's
near impossible to find out even these simple things.
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 ?
Ciao,
--
FA
Laboratorio di Acustica ed Elettroacustica
Parma, Italia
Lascia la spina, cogli la rosa.