From 3180b940995481351e778e68570f65931920b01d Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 30 Nov 2000 19:25:50 +0000 Subject: [PATCH] Updates for the latest API (the next device changes). --- alsactl/alsactl.c | 48 +++++++++++++++++++++++++------------------ alsamixer/alsamixer.c | 2 +- aplay/aplay.c | 20 +++++++++++------- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c index 39edbfe..dc738a8 100644 --- a/alsactl/alsactl.c +++ b/alsactl/alsactl.c @@ -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; diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c index d32a0da..92c6264 100644 --- a/alsamixer/alsamixer.c +++ b/alsamixer/alsamixer.c @@ -1730,7 +1730,7 @@ main (int argc, case '?': case 'h': fprintf (stderr, "%s %s\n", PRGNAME_UPPER, VERSION); - fprintf (stderr, "Usage: %s [-c ] [-z]\n", PRGNAME, snd_cards () - 1); + fprintf (stderr, "Usage: %s [-c ] [-z]\n", PRGNAME); mixer_abort (ERR_NONE, "", 0); case 'c': card_id = optarg; diff --git a/aplay/aplay.c b/aplay/aplay.c index c7dd5a0..90bac3e 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -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; + } } }