android alsa 相关命令

android 2.2 froyo版本提供三个命令行命令,

1. alsa_ctl 可用此命令输出当前的音频设置,alsa_ctl store ,在/system/etc下会生成asound.state,可与asound.conf对比

alsa_ctl store : 将当前音频配置参数设置导出到文件 /system/etc/asound.state

我们可以直接修改此文件进行系统初始化配置,当然别忘了在init.rc里面添加一个命令:

#####add to init.rc 
service asound_conf /system/bin/alsa_ctl restore
        oneshot

alsa_ctl restore : 将文件 /system/etc/asound.conf里的配置重新加载


2. alsa_aplay 可用此命令播放音频,不加参数只可以输出wav格式

3. alsa_amixer 文章http://blog.csdn.net/sepnic/article/details/6334922 对此命令有较好的解释。


另外还有alsa_arecord ,此命令不是默认就有的,需要使用下面工具生成。

By default alsa_arecord doesn't exist. It is a soft link to alsa_aplay. So to create the link run the following command from Android prompt.

Software loopback command to test capture-playback. Following command will record in "CD" format and play the recorded data.

下面链接对alsa有些比较有意思的东西

http://processors.wiki.ti.com/index.php/TI-Android-GingerBread-2.3.4-DevKit-2.1_PortingGuides

alsa_arecord 可对默认设备进行录音,

alsa_arecord 1.wav

alsa_arecord -f cd 1.wav //cd格式录音


alsa_amixer contents 可生成现在声卡的状态,alsa_ctl可生成asound.state,也可生成现在声卡的状态,只不过格式不同。使用alsa.amixer 可参考前者,而编写asound.conf可参考后者生成的文件。

原文地址:https://www.cnblogs.com/leino11121/p/2381897.html