From: Takashi Iwai Date: Tue, 28 Jun 2005 09:58:48 +0000 (+0000) Subject: Fix the return value of snd_card_load() X-Git-Tag: v1.0.10rc1~21 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=0350a615b7883df14aafaf7796ae30880b9df3bb;p=alsa-lib.git Fix the return value of snd_card_load() Fix the return value of snd_card_load() to follow the document, 0 = not present, 1 = preset. The other parts calling snd_card_load() are fixed, too. --- diff --git a/src/control/cards.c b/src/control/cards.c index b775a62c..f97610fd 100644 --- a/src/control/cards.c +++ b/src/control/cards.c @@ -61,9 +61,9 @@ int snd_card_load(int card) #endif if (open_dev >= 0) { close (open_dev); - return 0; + return 1; } - return open_dev ? 1 : 0; + return 0; } /** @@ -85,7 +85,7 @@ int snd_card_next(int *rcard) card = *rcard; card = card < 0 ? 0 : card + 1; for (; card < 32; card++) { - if (!snd_card_load(card)) { + if (snd_card_load(card)) { *rcard = card; return 0; } @@ -112,15 +112,16 @@ int snd_card_get_index(const char *string) return -EINVAL; if ((isdigit(*string) && *(string + 1) == 0) || (isdigit(*string) && isdigit(*(string + 1)) && *(string + 2) == 0)) { - sscanf(string, "%i", &card); + if (sscanf(string, "%i", &card) != 1) + return -EINVAL; if (card < 0 || card > 31) return -EINVAL; - if (snd_card_load(card) >= 0) + if (snd_card_load(card)) return card; - return -EINVAL; + return -ENODEV; } for (card = 0; card < 32; card++) { - if (snd_card_load(card) < 0) + if (! snd_card_load(card)) continue; if (snd_ctl_hw_open(&handle, NULL, card, 0) < 0) continue;