[LAD] ALSA doumentation

Clemens Ladisch cladisch at fastmail.net
Fri Nov 14 09:31:14 UTC 2008


Fons Adriaensen wrote:
> I now want to write some hopefully not too convolved
> C or C++ code to read and write these parameters.
>
> Is there, after X years of ALSA, any documentation that
> explains the basic concepts and tells me how to do this ?

No.

> 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");

or like this:

#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;
}



More information about the Linux-audio-dev mailing list