ALSA音訊庫的移植 ARM 交叉編譯 環境變數
[ 2: : timer 3: : sequencer 4: [ 0- 0]: raw midi 5: [ 0- 1]: digital audio playback 6: [ 0- 0]: digital audio playback 7: [ 0- 0]: digital audio capture 8: [ 0] : control |
[[email protected] alsa-lib-1.0.22]# ls -l /dev/snd total 0 crw------- 1 root root 116, 8 Mar 2 02:41 controlC0 crw------- 1 root root 116, 4 Mar 2 02:41 midiC0D0 crw------- 1 root root 116, 7 Mar 2 02:41 pcmC0D0c crw------- 1 root root 116, 6 Mar 2 02:41 pcmC0D0p crw------- 1 root root 116, 5 Mar 2 02:41 pcmC0D1p crw------- 1 root root 116, 3 Mar 2 02:41 seq crw------- 1 root root 116, 2 Mar 2 02:41 timer |
- 播放wave檔案
- aplay /mnt/nfs/test.wav
- 變頻播放,(以是以 44 KHz來播放音訊)
- aplay -D rate_44k /mnt/nfs/test.wav
- 錄音,以20秒的間隔(-d 20),立體聲(-c 2),頻率是 8000Hz來錄製Wave格式音訊
- arecord -d 20 -c 2 -t wav -r 8000 -f "Signed 16 bit Little Endian" /mnt/nfs/test.wav
- 測試混音播放(先是播放test1.wav,然後再同時播放test2.wav)
- aplay -D plug:dmix_44k /mnt/nfs/test1.wav &
- aplay -D plug:dmix_44k /mnt/nfs/test2.wav
- 設定放音增益(0 to 3)
- amixer set Master 1
- 設定錄音音量(0-31)
- amixer set Line 10
./configure --host=arm-linux --prefix=$PWD/../../output/arm-linux --enable-static --enable-shared --disable-python --with-configdir=/usr/local/share --with-plugindir=/usr/local/lib/alsa_lib |
ALSA lib pcm.c:2145:(snd_pcm_open_noupdate) Unknown PCM default aplay: main:546: audio open error: No such file or directory |
./configure --host=arm-linux --prefix=$PWD/../../output/arm-linux --enable-static --enable-shared --with-configdir=/usr/local/share --with-libiconv-prefix=$PWD/../../output/arm-linux CFLAGS="-I$PWD/../../output/arm-linux/include" LDFLAGS="-L$PWD/../../output/arm-linux/lib -lasound -liconv" --disable-alsamixer --disable-xmlto |
交叉編譯 alsa-lib
./configure --host=arm-none-linux-gnueabi --prefix=/usr/share/arm-alsa
make & make install
交叉編譯 alsa-utils
./configure --host=arm-none-linux-gnueabi --with-alsa-inc-prefix=/usr/share/arm-alsa/include -- with-alsa-prefix=/usr/share/arm-alsa/lib --without-alsamixer // avoid the ncurses lib
without 要改成disable
make
Copy lib to target board
cp -avr /usr/share/arm-alsa {$rootfs}/usr/share/arm-alsa
環境變數
export ALSA_CONFIG_PATH=/usr/share/arm-alsa/share/alsa/alsa.conf
未新增環境變數前出現的錯誤:
~ # ./aplay
ALSA lib conf.c:2827:(snd_config_hook_load) cannot access file /usr/share/arm-alsa/share/alsa/cards/aliases.conf
ALSA lib pcm.c:1959:(snd_pcm_open_conf) Invalid type for PCM default definition (id: default, value: cards.pcm.default)
aplay: main:533: audio open error: Invalid argument
~ # ./aplay
ALSA lib pcm.c:2090:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:533: audio open error: No such file or directory
MIPS:
alsa-lib-1.0.24.1配置編譯
CC=/opt/buildroot-gcc342/bin/mipsel-linux-gcc ./configure --host=mipsel-linux --prefix=/opt/mips/alsa_lib/ --enable-shared --disable-python
alsa-utils-1.0.24.2配置編譯
CC=/opt/buildroot-gcc342/bin/mipsel-linux-gcc ./configure --prefix=/opt/mips/alsa_utils/ --host=mips --with-alsa-prefix=/opt/mips/alsa_lib/lib_1.0.24.1/lib/ --with-alsa-inc-prefix=/opt/mips/alsa_lib/lib_1.0.24.1/include/
CC=/opt/buildroot-gcc342/bin/mipsel-linux-gcc ./configure --host=mipsel-linux --prefix=/home/armmlinux/zdfwork/project/audio/alsa/output/mips-linux/ --enable-shared --disable-python --with--configdir=/lib/
交叉編譯其他程式:
Add included file in program: #include <alsa/asoundlib.h>
~# arm-none-linux-gnueabi-gcc -lasound -L/usr/share/arm-alsa/lib/ -I/usr/share/arm-alsa/include/ -o test my_test.c