alsa-lib/test/mixer.c

58 lines
1.4 KiB
C
Raw Normal View History

1998-08-13 15:42:56 +00:00
#include <stdio.h>
#include <string.h>
1998-08-30 21:08:44 +00:00
#include "../include/asoundlib.h"
1998-08-13 15:42:56 +00:00
1998-11-27 15:07:56 +00:00
static void mixer_test(int card, int device)
1998-08-13 15:42:56 +00:00
{
int err;
1999-06-03 21:41:29 +00:00
snd_mixer_t *handle;
1998-11-27 15:07:56 +00:00
snd_mixer_info_t info;
if ((err = snd_mixer_open(&handle, card, device)) < 0) {
printf("Mixer open error: %s\n", snd_strerror(err));
return;
}
printf("Mixer %i/%i open ok...\n", card, device);
if ((err = snd_mixer_info(handle, &info)) < 0) {
printf("Mixer info error: %s\n", snd_strerror(err));
return;
}
printf(" Info:\n");
printf(" type - %i\n", info.type);
printf(" elements - %i\n", info.elements);
printf(" groups - %i\n", info.groups);
printf(" switches - %i\n", info.switches);
1999-06-03 21:41:29 +00:00
printf(" attrib - 0x%x\n", info.attrib);
1998-11-27 15:07:56 +00:00
printf(" id - '%s'\n", info.id);
printf(" name - '%s'\n", info.name);
snd_mixer_close(handle);
1998-08-13 15:42:56 +00:00
}
1999-06-03 21:41:29 +00:00
int main(void)
1998-08-13 15:42:56 +00:00
{
1998-11-27 15:07:56 +00:00
int idx, idx1, cards, err;
1999-06-03 21:41:29 +00:00
snd_ctl_t *handle;
2001-02-07 15:13:15 +00:00
snd_ctl_card_info_t info;
1998-11-27 15:07:56 +00:00
cards = snd_cards();
printf("Detected %i soundcard%s...\n", cards, cards > 1 ? "s" : "");
if (cards <= 0) {
printf("Giving up...\n");
1999-06-03 21:41:29 +00:00
return 0;
1998-11-27 15:07:56 +00:00
}
for (idx = 0; idx < cards; idx++) {
if ((err = snd_ctl_open(&handle, idx)) < 0) {
printf("Open error: %s\n", snd_strerror(err));
continue;
}
2001-02-07 15:13:15 +00:00
if ((err = snd_ctl_card_info(handle, &info)) < 0) {
1998-11-27 15:07:56 +00:00
printf("HW info error: %s\n", snd_strerror(err));
continue;
}
for (idx1 = 0; idx1 < info.mixerdevs; idx1++)
mixer_test(idx, idx1);
snd_ctl_close(handle);
}
1999-06-03 21:41:29 +00:00
return 0;
1998-08-13 15:42:56 +00:00
}