Updates for the latest API (the next device changes).

This commit is contained in:
Jaroslav Kysela 2000-11-30 19:25:50 +00:00
parent b62a07a9db
commit 3180b94099
3 changed files with 42 additions and 28 deletions

View file

@ -915,19 +915,23 @@ static int save_state(char *file, const char *cardname)
}
if (!cardname) {
unsigned int card_mask, idx;
unsigned int card, first = 1;
card_mask = snd_cards_mask();
if (!card_mask) {
error("No soundcards found...");
return 1;
}
for (idx = 0; idx < 32; idx++) {
if (card_mask & (1 << idx)) { /* find each installed soundcards */
if ((err = get_controls(idx, config))) {
return err;
card = -1;
/* find each installed soundcards */
while (1) {
if (snd_card_next(&card) < 0)
break;
if (card < 0) {
if (first) {
error("No soundcards found...");
return 1;
}
break;
}
first = 0;
if ((err = get_controls(card, config)))
return err;
}
} else {
int cardno;
@ -987,19 +991,23 @@ static int load_state(char *file, const char *cardname)
}
if (!cardname) {
unsigned int card_mask, idx;
unsigned int card, first = 1;
card_mask = snd_cards_mask();
if (!card_mask) {
error("No soundcards found...");
return 1;
}
for (idx = 0; idx < 32; idx++) {
if (card_mask & (1 << idx)) { /* find each installed soundcards */
if ((err = set_controls(idx, config))) {
return err;
card = -1;
/* find each installed soundcards */
while (1) {
if (snd_card_next(&card) < 0)
break;
if (card < 0) {
if (first) {
error("No soundcards found...");
return 1;
}
break;
}
first = 0;
if ((err = set_controls(card, config)))
return err;
}
} else {
int cardno;

View file

@ -1730,7 +1730,7 @@ main (int argc,
case '?':
case 'h':
fprintf (stderr, "%s %s\n", PRGNAME_UPPER, VERSION);
fprintf (stderr, "Usage: %s [-c <card: 0...%i>] [-z]\n", PRGNAME, snd_cards () - 1);
fprintf (stderr, "Usage: %s [-c <card: 0...7>] [-z]\n", PRGNAME);
mixer_abort (ERR_NONE, "", 0);
case 'c':
card_id = optarg;

View file

@ -171,19 +171,16 @@ static void device_list(void)
{
snd_ctl_t *handle;
int card, err, dev, idx;
unsigned int mask;
snd_ctl_hw_info_t info;
snd_pcm_info_t pcminfo;
mask = snd_cards_mask();
if (!mask) {
card = -1;
if (snd_card_next(&card) < 0 || card < 0) {
error("no soundcards found...");
return;
}
for (card = 0; card < SND_CARDS; card++) {
while (card >= 0) {
char name[32];
if (!(mask & (1 << card)))
continue;
sprintf(name, "hw:%d", card);
if ((err = snd_ctl_open(&handle, name)) < 0) {
error("control open (%i): %s", card, snd_strerror(err));
@ -194,7 +191,12 @@ static void device_list(void)
snd_ctl_close(handle);
continue;
}
for (dev = 0; dev < info.pcmdevs; dev++) {
dev = -1;
while (1) {
if (snd_ctl_pcm_next_device(handle, &dev)<0)
error("snd_ctl_pcm_next_device");
if (dev < 0)
break;
pcminfo.device = dev;
pcminfo.stream = -stream - 1;
pcminfo.subdevice = -1;
@ -221,6 +223,10 @@ static void device_list(void)
}
}
snd_ctl_close(handle);
if (snd_card_next(&card) < 0) {
error("snd_card_next");
break;
}
}
}