前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ALSA中aplay -Dhw:0,0 和 aplay -Dplughw:0,0 的区别

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

作者头像
程序手艺人
发布2019-08-14 14:38:14
5.5K0
发布2019-08-14 14:38:14
举报
文章被收录于专栏:程序手艺人程序手艺人

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

代码语言:javascript
复制
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可以正常播放

代码语言:javascript
复制
➜  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%)
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019年08月10日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档