>>> docker run -v /dev:/dev --privileged ...

进去后安装alsa-utils才能使用aplay

>>> aplay -f cd -c 1 -r 16000 demo.pcm 

但发现并没有声音
但确实可以获取到声卡

>>> aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
  Subdevices: 4/4
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 4/4
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3

这是由于默认的声卡选择错了,所以需要用配置文件选择一下默认声卡

>>> vim /etc/asound.conf 
pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw           
    card 1
}

参考:https://superuser.com/a/630048

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐