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

View file

@ -1730,7 +1730,7 @@ main (int argc,
case '?': case '?':
case 'h': case 'h':
fprintf (stderr, "%s %s\n", PRGNAME_UPPER, VERSION); 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); mixer_abort (ERR_NONE, "", 0);
case 'c': case 'c':
card_id = optarg; card_id = optarg;

View file

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