ALSA中aplay -Dhw:0,0 和 aplay -Dplughw:0,0 的区别

aplay -Dhw:0,0 -c 2 -r 48000 -f S16_LE /usr/share/sounds/alsa/Front_Left.wav

Playing WAVE '/usr/share/sounds/alsa/Front_Left.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
aplay: set_params:1305: Channels count non available

aplay -Dplughw:0,0 -c 2 -r 48000 -f S16_LE /usr/share/sounds/alsa/Front_Left.wav 可以正常播放.

其中的区别就是hw 和 plughw , 参考 Difference between “hwplug” and “hw”得出结论

hw: accesses the hardware device directly. // 直接访问硬件

plughw: inserts sample rate and format conversion plugins, if needed. //经过采样率和格式转换插件。

可以通过mediainfo查看文件信息, 发现为1通道格式,而Codec driver 是需要播放的2 channel的,所以需要plug转换为2 channel才可以播放.

特意找了一个2 channel / 48kHz , 验证了猜想结果. 不加plug可以正常播放

➜  alsa mediainfo Front_Left.wav
General
Complete name                            : Front_Left.wav
Format                                   : Wave
File size                                : 139 KiB
Duration                                 : 1 s 480 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 768 kb/s

Audio
Format                                   : PCM
Format settings                          : Little / Signed
Codec ID                                 : 1
Duration                                 : 1 s 480 ms
Bit rate mode                            : Constant
Bit rate                                 : 768 kb/s
Channel(s)                               : 1 channel
Sampling rate                            : 48.0 kHz
Bit depth                                : 16 bits
Stream size                              : 139 KiB (100%)

hw accesses the hardware device directly.

plughw inserts sample rate and format conversion plugins, if needed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序手艺人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值