Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio capturing using ALSA library - snd_pcm_open => No such file or directory

I'm trying to implement audio capturing on a SoC using ALSA library. I've a precompiled libasound.so.2.0.0 a asoundlib.h together with other headers.

now I have

int returnCode;
snd_pcm_t *pcm_Handle;
char *pcm_device_name = "hw:0,0";

returnCode = snd_pcm_open(&pcm_Handle, pcm_device_name, SND_PCM_STREAM_CAPTURE, 0);

which returns snd_strerror(returnCode) of No such file or directory

Does this indicate that the capturing device isn't properly installed (e.g. drivers or something)?

How can I find out what's wrong/missing?

Can I list whether ANY alsa accessible sound device is installed?

UPDATE:

I found out how to scan for devices by: Finding available sound cards on Linux programmatically

snd_card_next finds a single cardNum : 0 but I still fail on snd_ctl_open(&cardHandle, "hw:0", 0) and snd_pcm_open(&pcm_Handle, "hw:0,0", SND_PCM_STREAM_CAPTURE, 0) with No such file or directory. Is that an indication for that the sound device isn't properly installed?

UPDATE::

I found some more information on http://www.tldp.org/HOWTO/Alsa-sound-4.html

"4.6 Preparing the devices There is a script in the driver-directory that will install the ALSA-sound-devices in your /dev directory. Type ./snddevices from the driver-directory. There should be a /dev/snd subdirectory now (test if it is there. If you are not familiar with even the "ls" command, please consider reading other HOWTO's first. You should have some basic Linux knowledge to install these drivers). Now you're ready to insert the driver, so please turn over to the next paragraph."

I remember that I've run a snddevices script that was provided with the SoC alsa version, but I wasnt sure whether it was successful or whether it just didn't show the errors. But the link says I'll have to install drivers afterwards? Unfortunately I can't test before tomorrow.

UPDATE:

From CL. and http://www.tldp.org/HOWTO/Alsa-sound-6.html I tested the following: dev/snd/ has the following entries:

crw-rw----    1 root     audio     116,   0 Mar 11 04:44 controlC0
crw-rw----    1 root     audio     116,  24 Mar 11 04:44 pcmC0D0c
crw-rw----    1 root     audio     116,  16 Mar 11 04:44 pcmC0D0p
crw-rw----    1 root     audio     116,  25 Mar 11 04:44 pcmC0D1c
crw-rw----    1 root     audio     116,  26 Mar 11 04:44 pcmC0D2c
crw-rw----    1 root     audio     116,  27 Mar 11 04:44 pcmC0D3c
crw-rw----    1 root     audio     116,  28 Mar 11 04:44 pcmC0D4c

where cat controlC0 cat pcmC0D0c and cat pcmC0D1c return cat: read error: File descriptor in bad state while the others return like cat: can't open 'pcmC0D2c': No such device

While cat /proc/asound/cards gives

 0 [VPL_AUDIO      ]: VPL AUDIO - VPL Audio TW2866 Driver
                      VPL Audio Codec Driver, TW2866.
 1 [Mozart_SSM2603 ]: I2S - I2S driver
                      I2S driver

Here is some more information. Since I'n not any experienced with audio, I don't know whether they are important or to help...

cat /proc/asound/pcm
00-00: tw2866#0 : VPL Audio TW2866 Driver : capture 1
00-01: tw2866#1 : VPL Audio TW2866 Driver : playback 1 : capture 1
01-00: I2S AIC23 PCM : I2S driver : playback 1 : capture 1
like image 830
Micka Avatar asked Oct 13 '15 17:10

Micka


2 Answers

Your problem is that the alsa-lib package is not installed correctly (and it looks as if there is no package for your hardware).

To find out which files you need, get the alsa-lib source package, compile it, and install it into a temporary directory with

make install DESTDIR=/tmp/test

Then look into /tmp/test/; the compiled library file itself (libasound.so*) cannot be used if you didn't use the correct cross compiler, but the other files are text files suitable for any architecture.

like image 62
CL. Avatar answered Oct 29 '22 00:10

CL.


I had different version of the snddevices script. I had to use the right script int he right directory to get snd_pcm_open to work. I had to copy the script to the driver directory of the SoC.

I copied the .conf file to the same directory as in the reference implementation.

The bad file descriptor error message seems to be present if no capturing device is running. The capturing still doesn't work as of now.

like image 35
Micka Avatar answered Oct 28 '22 22:10

Micka