8

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
Community
  • 1
  • 1
Micka
  • 19,585
  • 4
  • 56
  • 74
  • The snddevices script should not be necessary on any modern distribution. Have you access to the files in `/dev/snd/`? – CL. Oct 13 '15 at 21:29
  • @CL. thank you for the interest. I can't say anything about whether the distribution is "modern". Since it is a system on a chip, the OS is limited to the absolute necessary parts and there really might be missing things. I had a similar problem with video capturing earlier, where some nodes were missing. In `/dev/snd/` there are entries `controlC0 pcmC0D0c pcmC0D0p pcmC0D1c pcmC0D2c pcmC0D3c pcmC0D4c` each of them has a size of 116. If I try `cat pcmC0D0c` it tells me `File descriptor in bad state`, same for pcmC0D1c and controlC0 while the others return `No such device` – Micka Oct 14 '15 at 07:21
  • The "116" is not the size. Anyway, how did you install the other needed files of alsa-lib? – CL. Oct 14 '15 at 07:30
  • I just had the preocompiled library and the binary for that hardware platform. Some drivers might have been added by the guy who installed the OS on that platform. So basically I would have to find out which installation steps are missing from the current system state, if that is possible. – Micka Oct 14 '15 at 07:38
  • I just edited the question to add some more information of `/proc/asound/cards` – Micka Oct 14 '15 at 07:39
  • So you do not have the files in `/usr/share/alsa/`? – CL. Oct 14 '15 at 07:42
  • that's right, folder `/usr/share/alsa/` isn't existing. Which files should be there? – Micka Oct 14 '15 at 07:45

2 Answers2

3

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.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • Just have seen that there was a makefile for my cross-compiler and ALSA source code present. Using the cross-compiler will create 4 folders: `bin` `include` `lib` `share`. Is my assumption right that I should copy the content of the `share` folder (with subfolders `alsa and `aclocal`) to my SoC `usr/share` folder? Will I have to reboot it or sth? – Micka Oct 14 '15 at 08:16
  • Yes, but you don't need `aclocal`. You don't need to reboot. – CL. Oct 14 '15 at 09:28
3

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.

abunickabhi
  • 558
  • 2
  • 9
  • 31
Micka
  • 19,585
  • 4
  • 56
  • 74
  • I just faced the same issue with `No such file or directory`. Can you please a bit more explanation about how did you trace this issue? – Some Name Nov 17 '18 at 10:22
  • sorry, afair I couldn't find a solution to capture audio, so I cancelled this project and it didn't get any new priority yet. Additionally, I can't remember details :-( – Micka Nov 17 '18 at 14:06