微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c – 使用ALSA库进行音频捕获 – snd_pcm_open =>没有这样的文件或目录

我正在尝试使用ALSA库在SoC上实现音频捕获.
我有一个预编译的libasound.so.2.0.0和一个asoundlib.h以及其他头文件.

我现在有

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);

返回没有这样的文件或目录的snd_strerror(returnCode)

这是否表明捕获设备未正确安装(例如驱动程序或其他东西)?

我怎样才能找出错误/缺失的内容

我可以列出是否安装了任何alsa可访问的声音设备?

更新:

我发现了如何扫描设备:Finding available sound cards on Linux programmatically

snd_card_next找到一个cardNum:0但我仍然在snd_ctl_open(& cardHandle,“hw:0”,0)和snd_pcm_open(& pcm_Handle,“hw:0,0”,0)上没有这样的文件或目录.这是否表明声音设备没有正确安装?

更新::

我在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.”

我记得我运行了一个随SoC alsa版本提供的snddevices脚本,但我不确定它是否成功或是否只是没有显示错误.但链接说我之后必须安装驱动程序?不幸的是我明天才能测试.

更新:

来自CL.和http://www.tldp.org/HOWTO/Alsa-sound-6.html我测试了以下内容
dev / snd /具有以下条目:

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

其中cat controlC0 cat pcmC0D0c和cat pcmC0D1c返回cat:读错误文件描述符处于不良状态,而其他文件描述符像cat一样返回:无法打开’pcmC0D2c’:没有这样的设备

而cat / proc / asound / cards给出了

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

这是一些更多信息.由于我没有任何音频经验,我不知道它们是重要的还是帮助…

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

解决方法

您的问题是alsa-lib软件包安装不正确(看起来好像没有硬件包).

要找出您需要的文件,请获取alsa-lib源包,编译它,然后将其安装到临时目录中

make install DESTDIR=/tmp/test

然后看看/ tmp / test /;如果您没有使用正确的交叉编译器,则无法使用已编译的库文件本身(libasound.so *),但其他文件是适用于任何体系结构的文本文件.

原文地址:https://www.jb51.cc/c/118063.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐