[alsa-devel] snd_ctl_card_info_t type does not resolve on ubuntu 11.10?

Borg Onion borg.onion at gmail.com
Tue Nov 15 14:10:05 CET 2011


Starting to write an ALSA app and trying to just list sound card info.  The
type "snd_ctl_card_info_t" doesn't seem to resolve by just including
<alsa/asoundlib.h>.  This type is needed for me to
call snd_ctl_card_info().  OS is Ubuntu 11.10 with libasound2-dev
installed.  What am I doing wrong?  Code is below:

#include <stdio.h>
#include <alsa/asoundlib.h>

void print_card_info(snd_ctl_card_info_t info)
        printf("Card #=%d, id=%s, driver=%s, name=%s, longname=%s,
mixername=%s, components=%s\n",
                info.card, info.id, info.driver, info.name, info.longname,
info.mixername, info.components);

int main(int argc, char **argv)
        int card = -1;
        char cardascii[3];
        char *name, *longname;
        snd_ctl_t *handle;
        snd_ctl_card_info_t info;

        while (snd_card_next(&card) >= 0) {
                if (card < 0) {
                        printf("No more cards!\n");
                printf("Card %d\n", card);
                if (snd_card_get_name(card, &name))
                        printf("Error getting card %d's name, skipping\n",
                printf("Name = %s\n", name);
                if (snd_card_get_longname(card, &longname))
                        printf("Error getting card %d's long name,
skipping\n", card);
                printf("Long name = %s\n", longname);
                snprintf(cardascii, sizeof(cardascii), "%d", card);
                if (snd_ctl_open(&handle, cardascii, 0))
                        printf("Error opening card #%d, skipping\n", card);
                if (snd_ctl_card_info(handle, &info))
                        printf("Error getting info for card #%d,
skipping\n", card);

        return 0;

$ make
mkdir .deps
cc -O2 -std=gnu99 -Wall -Wextra -pedantic -g   -c -DPREFIX=\"/usr/local\"
-Wp,-MD,.deps/list.d -o list.o list.c
list.c:4:42: error: parameter 1 (âinfoâ) has incomplete type
list.c: In function âprint_card_infoâ:
list.c:4:42: warning: unused parameter âinfoâ [-Wunused-parameter]
list.c: In function âmainâ:
list.c:16:22: error: storage size of âinfoâ isnât known
list.c:16:22: warning: unused variable âinfoâ [-Wunused-variable]
list.c:10:14: warning: unused parameter âargcâ [-Wunused-parameter]
list.c:10:27: warning: unused parameter âargvâ [-Wunused-parameter]
make: *** [list.o] Error 1

More information about the Alsa-devel mailing list