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.
# ln -s /system/bin/alsa_aplay /system/bin/alsa_arecord
Software loopback command to test capture-playback. Following command will record in "CD" format and play the recorded data.
alsa_arecord -f cd | alsa_aplay
下面連結對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可參考後者產生的檔案。