android alsa 命令,[zz]Android下使用alsa-utils调试ALSA驱动
android下面的alsa utils提供三个工具,分别是:
alsa_amixer : 配置
alsa_aplay : 播放 录制
alsa_ctl: : store/restore 配置文件,与asound.conf有关
可以通过alsa_XXX --help 查看详细参数
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
【alsa_amixer】
/ $ alsa_amixer --help
Usage: amixer [command]
Available options:
-h,--help this help
-c,--card N select the card
-D,--device N select the device, default 'default'
-d,--debug debug mode
-n,--nocheck do not perform range checking
-v,--version print version of this program
-q,--quiet be quiet
-i,--inactive show also inactive controls
-a,--abstract L select abstraction level (none or
basic)
-s,--stdin Read and execute commands from stdin
sequentially
Available commands: //我们主要使用后面四个
scontrols show all mixer simple controls
scontents show contents of all mixer simple controls (default command)
sset sID P set contents for one mixer simple control
sget sID get contents for one mixer simple control
controls show all controls for given card
contents show contents of all controls for given card
cset cID P set control contents for one control
cget cID get control contents for one control
【使用方法】
alsa_amixer controls :列出alsa驱动里面注册的所有控制接口。
这些controls是在驱动里面通过struct snd_kcontrol_new twl4030_snd_controls[]
定义,函数static int twl4030_add_controls(struct snd_soc_codec
*codec)来添加的接口。
格式如下:
numid=19,iface=MIXER,name='Analog Capture Volume'
alsa_amixer contents : 列出以上接口的详细内容,格式如下:
numid=19,iface=MIXER,name='Analog Capture Volume'
;
type=INTEGER,access=rw---R--,values=2,min=0,max=5,step=0
: values=5,5
| dBscale-min=0.00dB,step=6.00dB,mute=0
以上,numid是在注册的时候顺序分配的,其他信息查看驱动里面的数据结构来了解。
我们可以通过两个命令来读取和设置相关参数:
cset cID P set control contents for one control
cget cID get control contents for one control
例如:
alsa_amixer cget numid=19,iface=MIXER,name='Analog Capture
Volume'
alsa_amixer cset numid=19,iface=MIXER,name='Analog Capture Volume'
5
其实,如果通过alsa_amixer
controls获取到这些controls的numid后,可以直接使用numid来操作,结果一样:
/ $ alsa_amixer cget numid=19
numid=19,iface=MIXER,name='Analog Capture Volume'
;
type=INTEGER,access=rw---R--,values=2,min=0,max=5,step=0
: values=5,5
| dBscale-min=0.00dB,step=6.00dB,mute=0
/ $ alsa_amixer cset numid=19 4
###reg_0x48 ==TWL4030_REG_ANAMIC_GAIN : 0x24
numid=19,iface=MIXER,name='Analog Capture Volume'
;
type=INTEGER,access=rw---R--,values=2,min=0,max=5,step=0
: values=4,4
| dBscale-min=0.00dB,step=6.00dB,mute=0
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
【alsa_aplay】
/ $ alsa_aplay --help
Usage: aplay [OPTION]... [FILE]...
-h, --help help
--version print current version
-l, --list-devices list all soundcards and digital audio
devices
-L, --list-pcms list device names
-D, --device=NAME select PCM by name
-q, --quiet quiet mode
-t, --file-type TYPE file type (voc, wav, raw or au)
-c, --channels=# channels
-f, --format=FORMAT sample format (case insensitive)
-r, --rate=# sample rate
-d, --duration=# interrupt after # seconds
-M, --mmap mmap stream
-N, --nonblock nonblocking mode
-F, --period-time=# distance between interrupts is #
microseconds
-B, --buffer-time=# buffer duration is # microseconds
--period-size=# distance between interrupts is # frames
--buffer-size=# buffer duration is # frames
-A, --avail-min=# min available space for wakeup is # microseconds
-R, --start-delay=# delay for automatic PCM start is # microseconds
(relative to buffer size if <= 0)
-T, --stop-delay=# delay for automatic PCM stop is # microseconds from xrun
-v, --verbose show PCM structure and setup
(accumulative)
-V, --vumeter=TYPE enable VU meter (TYPE: mono or
stereo)
-I, --separate-channels one file for each channel
--disable-resample disable automatic rate resample
--disable-channels disable automatic channel
conversions
--disable-format disable automatic format conversions
--disable-softvol disable software volume control
(softvol)
--test-position test ring buffer position
Recognized sample formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE
S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE
FLOAT_BE
FLOAT64_LE FLOAT64_BE IEC958_SUBFRAME_LE IEC958_SUBFRAME_BE MU_LAW
A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE
S20_3LE
S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE
Some of these may not be available on selected hardware
The availabled format shortcuts are:
-f cd (16 bit little endian, 44100, stereo)
-f cdr (16 bit big endian, 44100, stereo)
-f dat (16 bit little endian, 48000, stereo)
录音参数 S8 U8 S16_LE S16_BE U16_LE U16_B 的详细解释:
S是有符号 U是无符号
BE是大端
LE是小端
这都是PCM的一种表示范围的方法,所以表示方法中最小值等价,最大值等价,中间的数据级别就是对应的进度了,可以都映射到-1~1范围。
S8: signed 8 bits,有符号字符 = char, 表示范围 -128~127
U8: unsigned 8 bits,无符号字符 = unsigned char,表示范围 0~255
S16_LE: little endian signed 16 bits,小端有符号字 = short,表示范围
-32768~32767
S16_BE: big endian signed 16 bits,大端有符号字 = short倒序(PPC),表示范围
-32768~32767
U16_LE: little endian unsigned 16 bits,小端无符号字 = unsigned short,表示范围
0~65535
U16_BE: big endian unsigned signed 16 bits,大端无符号字 = unsigned
short倒序(PPC),表示范围 0~65535
还有S24_LE,S32_LE等,都可以表示数字的方法,PCM都可以用这些表示。
上面这些值中,所有最小值-128, 0, -32768, -32768, 0,
0对应PCM描叙来说都是一个值,表示最小值,可以量化到浮点-1。所有最大值也是一个值,可以量化到浮点1,其他值可以等比例转换。
example:
alsa_aplay -C -t wav -c 2 -r 44100 -f S16_LE -d 10 -v
record.wav
alsa_aplay record.wav
-C: record
-t, --file-type TYPE file type (voc, wav, raw or au)
-c, --channels=# channels
-f, --format=FORMAT sample format (case insensitive)
-r, --rate=# sample rate
-d, --duration=# interrupt after # seconds
-v, --verbose show PCM structure and setup (accumulative)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
【alsa_ctl】
/ $ alsa_ctl --help
Usage: alsactl command
Available global options:
-h,--help this help
-d,--debug debug mode
-v,--version print version of this program
Available state options:
-f,--file # configuration file (default /etc/asound.state)
-F,--force try to restore the matching controls as much as possible
(default mode)
-g,--ignore ignore 'No soundcards found' error
-P,--pedantic do not restore mismatching controls (old default)
-I,--no-init-fallback
don't initialize even if restore fails
-r,--runstate # save restore and init state to this file (only errors)
default settings is 'no file set'
-R,--remove remove runstate file at first, otherwise append
errors
Available init options:
-E,--env #=# set environment variable for init phase (NAME=VALUE)
-i,--initfile # main configuation file for init phase (default /system/usr/share/alsa/init/00main)
Available commands:
store save current driver setup for one or each soundcards
to configuration file
restore load current driver setup for one or each soundcards
from configuration file
init initialize driver to a default state
names dump information about all the known present
(sub-)devices
into configuration file (DEPRECATED)
主要用到两个命令:
alsa_ctl store : 将当前音频配置参数设置导出到文件 /system/etc/asound.conf
我们可以直接修改此文件进行系统初始化配置,当然别忘了在init.rc里面添加一个命令:
#####add to init.rc
service asound_conf /system/bin/alsa_ctl restore
oneshot
alsa_ctl restore : 将文件 /system/etc/asound.conf里的配置重新加载
android alsa 命令,[zz]Android下使用alsa-utils调试ALSA驱动相关推荐
- android冻结命令,在Android上使用冻结tensorflow图中的变量
TLDR:如何在Android上使用冻结tensorflow图中的变量? 1.我想做什么 我有一个Tensorflow模型,它在多个变量中保持一个内部状态,用:state_var = tf.Varia ...
- linux下的zz命令,[zz]Linux下压缩命令
一.Linux下和windows下的压缩文件的几个说明 在Windows下最常见的压缩文件就只有两种,一是,zip,另一个是.rar.可是Linux就不同了,它有.gz..tar.gz.tgz. bz ...
- android setting 命令,【Android】 adb shell 下 setting 指令
adb shell settings list system adb shell settings list global adb shell settings list secure 分别查看系统 ...
- android 手机命令大全,Android ADB命令大全
root uid 0 gid 0 system uid 1000 gid 1000 shell uid 2000 gid 2000 app uid 10000 gid 10000 jarsigner ...
- android iperf 命令行,Android 移植之 iperf
1 .移植准备 1 ,源代码地址: 2 ,解压到 Adroid_root/external/ iperf-2.0.4.tar.gz; tar –zxvf iperf-2.0.4.tar.gz 2. 创 ...
- Android系统在超级终端下必会的命令大全(二)
Android系统在超级终端下必会的命令大全(二) 安装和登录命令 reboot1.作用 reboot命令的作用是重新启动计算机,它的使用权限是系统管理者. 2.格式 reboot [-n] [-w] ...
- (转载)Mac系统下利用ADB命令连接android手机并进行文件操作
Mac系统下利用ADB命令连接android手机并进行文件操作 标签: Mac adb android 2016-03-14 10:09 5470人阅读 评论(1) 收藏 举报 分类: Androi ...
- android dd命令,【测试人员技能】Android shell 下dd命令浅析
一.前言 小编在最近的过程中遇到了一个需要构造存储空间不足的场景,并且还需要覆盖验证各种机型,而单个拷贝大文件到测试机器又太繁琐,小编查阅资料发现下的dd命令可以协助小编完成此项任务,正好借此机会给大 ...
- Android系统在超级终端下命令大全
Android系统在超级终端下必会的命令大全(一) busybox BusyBox 是标准 Linux 工具的一个单个可执行实现.BusyBox 包含了一些简单的工具,例如 cat 和 echo,还包 ...
最新文章
- ROS知识(4)----初级教程之常见问题汇总
- jquery判断多选框是否选中
- 顺序二叉树(基于数组存储树结点)
- redis类型[string 、list 、 set 、sorted set 、hash]
- 矩阵的二范数_【专题】GAN(二)—— 目标函数的优化
- 《Python编程从入门到实践》记录之第6章 字典操作知识总结——字典遍历、字典嵌套等(思维导图)
- Rust LeetCode 练习:929 Unique Email Addresses
- Wannafly挑战赛21: C. 大水题(DP)
- 深入理解JVM虚拟机
- 地铁应急指挥系统解决方案
- CRM客户管理系统源码,基于ThinkPHP开发
- [转]Windows服务“允许服务与桌面交互”的使用和修改方法
- 昇腾modelzoo复现yolov4_v1(模型训练+网络定义)
- android图片聊天背景图片,32张黑色简约手机壁纸图片大全 也适合作微信7.0聊天背景图片...
- 带你一起敲敲ES6的新特性,边解释边应用!
- Linux中ps命令详解
- 将MindManager添加到鼠标右键新建项
- 光敏电阻5506主要参数_常用光敏电阻参数表
- 算法mips与mcps 的分析
- 3 链表(LinkedList)