Skip to contentSkip to conversation

- Need list of hardware devices

App development Garrett Kajmowicz 2 participants 2 messages Jul 9, 2003 – Jul 11, 2003

lore
Share & tools
lore
#0 lore raw

I'm just begining my first ALSA application. As a part of the GUI I need to prompt the user to select from a list the soundcard and input device for both recording and playback. How would you suggest doing this? Examples welcome.

Thanks for your time,

Garrett Kajmowicz

-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps

#1 lore raw

RE: [App development] - Need list of hardware devic

Quoted 3 lines · On 09-Jul-2003 Garrett Kajmowicz wrote:

I'm just begining my first ALSA application. As a part of the GUI I need to prompt the user to select from a list the soundcard and input device for both recording and playback. How would you suggest doing this? Examples welcome.

Try this:

int err, i, n, cardnum;
char devname[8], cardname[32];
snd_ctl_card_info_t *hw_info;

  // Scans all installed cards
  snd_ctl_card_info_alloca(&hw_info);
  cardnum=-1;
  ctlhandle=0;

  while (snd_card_next(&cardnum)>=0 && cardnum>=0) {
    sprintf(devname, "hw:%d", cardnum);
    if ((err=snd_ctl_open(&ctlhandle, devname, 0))<0) {
      printf("snd_ctl_open(%s) Error: %s\n", devname, snd_strerror(err));
      continue;
    }
    if ((err=snd_ctl_card_info(ctlhandle, hw_info))>=0) {
      if (!strcmp(snd_ctl_card_info_get_driver(hw_info), "Echoaudio")) {
        strcpy(card, devname);
        strcpy(cardname, snd_ctl_card_info_get_name(hw_info));
        printf("Card found: %s  (%s)\n", snd_ctl_card_info_get_longname(hw_info), devname);
        break;
      }
    } else {
      printf("snd_ctl_card_info(%s) Error: %s\n", devname, snd_strerror(err));
      exit(1);
    }
    snd_ctl_close(ctlhandle);
    ctlhandle=0;
  }

  if (!ctlhandle) {
    printf("No Echoaudio cards found, sorry.\n");
    return(0);
  }

Bye.

-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1