Martin Stransky 1f34d9
/* Copyright 2005 Red Hat, Inc.
Martin Stransky 1f34d9
 *
Martin Stransky 1f34d9
 * This software may be freely redistributed under the terms of the GNU
Martin Stransky 1f34d9
 * public license.
Martin Stransky 1f34d9
 *
Martin Stransky 1f34d9
 * You should have received a copy of the GNU General Public License
Martin Stransky 1f34d9
 * along with this program; if not, write to the Free Software
Martin Stransky 1f34d9
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Martin Stransky 1f34d9
 *
Martin Stransky 1f34d9
 */
Martin Stransky 1f34d9
#include <stdio.h>
Martin Stransky 1f34d9
#include <string.h>
Martin Stransky 1f34d9
#include <alsa asoundlib.h="">
Martin Stransky 1f34d9
Martin Stransky 1f34d9
int get_card_device(const char *p_device)
Martin Stransky 1f34d9
{
Martin Stransky 1f34d9
  int err;
Martin Stransky 1f34d9
  snd_ctl_t *handle;
Martin Stransky 1f34d9
  snd_ctl_card_info_t *info;
Martin Stransky 1f34d9
Martin Stransky 1f34d9
  snd_ctl_card_info_alloca(&info);
Martin Stransky 1f34d9
Martin Stransky 1f34d9
  if ((err = snd_ctl_open(&handle, "default", 0)) < 0) {
Martin Stransky 1f34d9
    fprintf(stderr,"Open error: %s\n", snd_strerror(err));
Martin Stransky 1f34d9
    return(0);
Martin Stransky 1f34d9
  }
Martin Stransky 1f34d9
  if ((err = snd_ctl_card_info(handle, info)) < 0) {
Martin Stransky 1f34d9
    fprintf(stderr,"HW info error: %s\n", snd_strerror(err));
Martin Stransky 1f34d9
    return(0);
Martin Stransky 1f34d9
  }
Martin Stransky 1f34d9
Martin Stransky 1f34d9
  return (snd_ctl_card_info_get_card(info));
Martin Stransky 1f34d9
}
Martin Stransky 1f34d9
Martin Stransky 1f34d9
int main(int argc, char *argv[])
Martin Stransky 1f34d9
{
Martin Stransky 1f34d9
  char *p_device = "default";
Martin Stransky 1f34d9
  int   card;
Martin Stransky 1f34d9
Martin Stransky 1f34d9
  if (argc > 1 && argv[1])
Martin Stransky 1f34d9
    p_device = argv[1];
Martin Stransky 1f34d9
Martin Stransky 1f34d9
  card = get_card_device(p_device);
Martin Stransky 1f34d9
  printf("%d",card);
Martin Stransky 1f34d9
  return (card);
Martin Stransky 1f34d9
}