音频
1. 音频接口介绍
以M5-R1为例,其带一个耳机接口,可以通过该接口外接一个有线耳机。
2. 音频测试
# 插上HDMI显示屏、插上耳机的情况下,可以看到有两路输出可选择,这里可以看到0对应的是耳机、1对应的是HDMI
root@rk3588-buildroot:/# pactl list short sinks
0 alsa_output.0.HiFi__hw_rockchipes8388__sink module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
1 alsa_output.1.HDMI__hw_rockchiphdmi1__sink module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
# 查看当前默认输出为HDMI还是耳机
root@rk3588-buildroot:/# pactl get-default-sink
alsa_output.0.HiFi__hw_rockchipes8388__sink
# 为1表示设置声音从HDMI显示屏输出
root@rk3588-buildroot:/# pactl set-default-sink 1
# 验证
root@rk3588-buildroot:/# pactl get-default-sink
alsa_output.1.HDMI__hw_rockchiphdmi1__sink
root@rk3588-buildroot:/# aplay 1KHz.wav
Playing WAVE '1KHz.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
^CAborted by signal Interrupt...
aplay: pcm_write:2178: write error: Interrupted system call
E: [alsa-sink-rockchip-hdmi1 i2s-hifi-0] alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write.
E: [alsa-sink-rockchip-hdmi1 i2s-hifi-0] alsa-sink.c: Most likely this is a bug in the ALSA driver '(null)'. Please report this issue to the ALSA developers.
E: [alsa-sink-rockchip-hdmi1 i2s-hifi-0] alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.
# 使用耳机麦克风录音
amixer -c 0 cset name='Differential Mux' 'Line 1'
# 使用arecord指令,其中-d指定录制多少秒
arecord -D hw:0,0 --period-size=1024 --buffer-size=4096 -r 16000 -c 2 -f S16_LE r.wav -d 7
aplay r.wav
# 使用外置式麦克风录音
amixer -c 0 cset name='Differential Mux' 'Line 2'
# 使用arecord指令,其中-d指定录制多少秒
arecord -D hw:0,0 --period-size=1024 --buffer-size=4096 -r 16000 -c 2 -f S16_LE r.wav -d 7
aplay r.wav