Re: [linux-audio-dev] PCM Device Enumeration

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] PCM Device Enumeration
From: Paul Davis (pbd_AT_op.net)
Date: Fri May 10 2002 - 21:48:42 EEST


>Anyone out there know a good technique for getting an enumeration of all
>available PCM devices? (This is using ALSA-0.9.0). Currently, I'm doing
>something like:
>
>for(i=0;i<MAX_CARDS;i++) {
> for(j=0;j<MAX_DEVS;j++) {
> sprintf(device,"plughw:%d,%d",i,j);
> if(snd_pcm_open(&handle,device,SND_PCM_PLAYBACK,0)==0) {
> printf("%s exists\n",device);
> snd_pcm_close(handle);
> }
> }
>}
>
>This works, but alsa-lib sprews messages out on stderr for every call to
>snd_pcm_open that fails. UGLY! There's got to be a better way. Or is there
>a way to tell alsa-lib to suppress error messages to stderr?

if you want to see how to do it "the right way", look at what "aplay
-L" does, since this takes the contents of ~/.asoundrc into
account. your code above doesn't do that at all. because ALSA allows
the user to define PCM devices with specific characteristics that are
slaves and/or subsets of h/w devices, what you're trying to do above
is really circumventing the ALSA configuration system.

--p


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Fri May 10 2002 - 21:46:40 EEST