Ktam3874/pitx software guide, Without device number) are possible – Kontron KTAM3874-pITX User Manual
Page 117

KTD-S0057-I
Page 113 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
The sourcecode below shows an example for mixer programming. However you cannot use the well-known
identifiers for the card name - only
default
and
hw:0
(without device number) are possible.
/***************************************************************
* Mixer demo program
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
****************************************************************/
#include <stdio.h>
#include <alsa/asoundlib.h>
static const char *card = "default";
/* do not use plughw:0,0 or hw:0,0 */
static const char *playb_name = "Line Out";
typedef struct {
snd_mixer_t
*handle;
snd_mixer_elem_t
*elem;
} mixer_dev;
typedef struct {
long
left;
long
right;
} playb_vol;
static int init_mixer (mixer_dev *dev)
{
const char *elem_name;
snd_mixer_elem_t
*elem;
if (snd_mixer_attach (dev->handle, card) < 0)
{
fprintf (stderr, "Cannot attach card device\n");
return
EXIT_FAILURE;
}
if (snd_mixer_selem_register (dev->handle, NULL, NULL) < 0)
{
fprintf (stderr, "Cannot register simple element class\n");
return
EXIT_FAILURE;
}
if (snd_mixer_load (dev->handle) < 0)
{
fprintf (stderr, "Cannot open an empty mixer\n");
return
EXIT_FAILURE;
}
elem = snd_mixer_first_elem (dev->handle);