一、查看声卡和pcm设备
1、查看当前的声卡:
cat /proc/asound/cards
2、查看pcm设备列表:
cat /proc/asound/pcm
3、查看当前有哪些进程占用了pcm设备节点
lsof |grep pcm
4、查看有哪些音频设备节点
ls /dev/snd/
xxxx:/ $ ls /dev/snd/
controlC0 pcmC0D12p pcmC0D16c pcmC0D19p pcmC0D21p pcmC0D24c pcmC0D27p pcmC0D2c pcmC0D31p pcmC0D34c pcmC0D3p pcmC0D6c pcmC0D8p sequencer2
pcmC0D0p pcmC0D13c pcmC0D17c pcmC0D1c pcmC0D22p pcmC0D25p pcmC0D28c pcmC0D2p pcmC0D32p pcmC0D34p pcmC0D4c pcmC0D6p pcmC0D9p timer
pcmC0D10c pcmC0D14c pcmC0D18c pcmC0D20c pcmC0D23c pcmC0D26p pcmC0D28p pcmC0D30c pcmC0D33c pcmC0D35c pcmC0D4p pcmC0D7c seq
pcmC0D11p pcmC0D15p pcmC0D19c pcmC0D20p pcmC0D23p pcmC0D27c pcmC0D29c pcmC0D30p pcmC0D33p pcmC0D3c pcmC0D5p pcmC0D7p sequencer
音频设备的命名规则为 [device type]C[card index]D[device index][capture/playback],即名字中含有4部分的信息:
- device type
设备类型,通常只有comtrol/pcm这2种。从上图可以看到声卡会管理很多设备,PCM设备只是其中的一种设备。 - card index
声卡的id,代表第几块声卡。通常都是0,代表第一块声卡。手机上通常都只有一块声卡。 - device index
设备的id,代表这个设备是声卡上的第几个设备。设备的ID只和驱动中配置的DAI link的次序有关。如果驱动没有改变,那么这些ID就是固定的。 - capture/playback
只有PCM设备才有这部分,只有c和p两种。c代表capture,说明这是一个提供录音的设备,p代表palyback,说明这是一个提供播放的设备。
系统会在/proc/asound/pcm文件中列出所有的音频设备的信息,如果是肉眼查看,cat /proc/asound/pcm中的信息会更直观一些:
xxxx:/ $ cat /proc/asound/pcm
00-00: MultiMedia1_PLayback ak7739-aif4-0 : : playback 1
00-01: MultiMedia1_Capture ak7739-aif3-1 : : capture 1
00-02: Voice_MD1_PLayback mt-soc-codec-voicemd1-dai-2 : : playback 1 : capture 1
00-03: TDM_PLayback mt-soc-hdmi-dummy-dai-codec-3 : : playback 1 : capture 1
00-04: ULDL_Loopback mt-soc-codec-uldlloopback-dai-4 : : playback 1 : capture 1
00-05: I2S0_PLayback mt-soc-i2s0-dummy-dai-codec-5 : : playback 1
00-06: MRGRX_PLayback mt-soc-mrgrx-dai-codec-6 : : playback 1 : capture 1
00-07: MRGRX_CAPTURE mt-soc-mrgrx-dummy-dai-codec-7 : : playback 1 : capture 1
00-08: I2S0DL1_PLayback mt-soc-codec-I2s0tx-dai-8 : : playback 1
00-09: Deep_Buffer_PLayback mt-soc-codec-deepbuffer-tx-dai-9 : : playback 1
00-10: DL1_AWB_Record mt-soc-codec-dl1awb-dai-10 : : capture 1
00-11: Voice_MD1_BT_Playback mt-soc-codec-voicemd1-bt-dai-11 : : playback 1
00-12: VOIP_Call_BT_Playback mt-soc-codec-voipcall-btout-dai-12 : : playback 1
00-13: VOIP_Call_BT_Capture mt-soc-codec-voipcall-btin-dai-13 : : capture 1
00-14: TDM_Debug_Record mt-soc-tdmrx-dai-codec-14 : : capture 1
00-15: FM_MRGTX_Playback mt-soc-fmmrg2tx-dummy-dai-codec-15 : : playback 1
00-16: MultiMediaData2_Capture mt-soc-codec-rx-dai2-16 : : capture 1
00-17: MultiMediaData3_Capture mt-soc-codec-rx-dai3-17 : : capture 1
00-18: I2S0AWB_Capture ak7739-aif2-18 : : capture 1
00-19: Voice_MD2_PLayback mt-soc-codec-voicemd2-dai-19 : : playback 1 : capture 1
00-20: MultiMedia_Routing mt-soc-dummy-dai-codec-20 : : playback 1 : capture 1
00-21: Voice_MD2_BT_Playback mt-soc-codec-voicemd2-bt-dai-21 : : playback 1
00-22: HP_IMPEDANCE_Playback mt-soc-codec-hp-impedance-dai-22 : : playback 1
00-23: FM_I2S_Playback a2b24xx-hifi-23 : : playback 1 : capture 1
00-24: FM_I2S_Capture mt-soc-fm-i2s-dummy-dai-codec-24 : : capture 1
00-25: MultiMedia2_PLayback mt-soc-codec-tx-dai2-25 : : playback 1
00-26: MultiMedia3_PLayback mt-soc-codec-offload-dai-26 : : playback 1
00-27: BTCVSD_Capture snd-soc-dummy-dai-27 : : playback 1 : capture 1
00-28: BTCVSD_Playback snd-soc-dummy-dai-28 : : playback 1 : capture 1
00-29: ANC_Record mt-soc-dummy-dai-codec-29 : : capture 1
00-30: Voice_USB_PLayback mt-soc-codec-voiceusb-dai-30 : : playback 1 : capture 1
00-31: Voice_USB_EchoRef mt-soc-codec-voiceusb-echoref-dai-31 : : playback 1
00-32: I2S5DL1_PLayback ak7739-aif1-32 : : playback 1
00-33: Headphone_PLayback snd-soc-dummy-dai-33 : : playback 1 : capture 1
00-34: Speaker_PLayback snd-soc-dummy-dai-34 : : playback 1 : capture 1
00-35: I2S2ADC2_Capture snd-soc-dummy-dai-35 : : capture 1
以上面的左侧00-01为例来说明下:前面2位数字指的card index:00,后面2位是device index:01。
二、tinyalsa的使用
1、编译tinyalsa
aosp/external/tinyalsa$ mma
2、编译完后就生成tinyplay、tinymix、tinycap等工具。
xxxx/aosp/out/target/product/ecarxICp1_64/system/bin$ ls tiny*
tinycap tinyhostless tinymix tinypcminfo tinyplay
3、将生成的这些可执行斌文件拷贝到开发板的/system/bin下,并加可执行权限。
xxxx:/system/bin $ ls tiny* -l
-rwxr-xr-x 1 root shell 68488 2021-12-06 22:56 tinycap
-rwxr-xr-x 1 root shell 68408 2021-12-06 22:56 tinyhostless
-rwxr-xr-x 1 root shell 68656 2021-12-06 22:56 tinymix
-rwxr-xr-x 1 root shell 68448 2021-12-06 22:56 tinypcminfo
-rwxr-xr-x 1 root shell 68408 2021-12-06 22:56 tinyplay
4、tinyplay
tinyplay只能播放wav格式的音频文件 :
xxxx:/storage/emulated/0/Music # tinyplay 48000_2ch_16bit.wav
Playing sample: 2 ch, 48000 hz, 16 bit
5、tinymix
直接输入tinymix可以得到音频通路相关的各项配置参数。也可以通过添加参数修改其中的配置。
:/sdcard # tinymix | grep -E "V01|SRC3"
33 ENUM 1 xxxxx Audio Noise Clean Type V01
97 ENUM 1 SRC3 Sync Domain SD3
199 ENUM 1 SRC3 Digital Filter HF
203 ENUM 1 SRC3 Group Delay Matching Disable
207 BOOL 1 SRC3 Soft Mute Off
211 ENUM 1 SRC3 Soft Mute Mode Manual
215 BOOL 1 SRC3 Lock Signal Output Off
219 BOOL 1 SRC3 Lock Status On
223 BOOL 1 SRC3 Overflow Status Off
522 ENUM 1 SRC3 Source Selector SDIN2
:/ # tinymix 33
Ecarx Audio Noise Clean Type: SW Baidu >V01
设置:
:/ # tinymix 33 SW
再查看:
127|:/ # tinymix | grep 33
33 ENUM 1 xxxxx Audio Noise Clean Type SW
:/ # tinymix 33
xxxxx Audio Noise Clean Type: >SW Baidu V01
:/ # tinymix | grep SRC3
97 ENUM 1 SRC3 Sync Domain SD3
199 ENUM 1 SRC3 Digital Filter HF
203 ENUM 1 SRC3 Group Delay Matching Disable
207 BOOL 1 SRC3 Soft Mute Off
211 ENUM 1 SRC3 Soft Mute Mode Manual
215 BOOL 1 SRC3 Lock Signal Output Off
219 BOOL 1 SRC3 Lock Status On
223 BOOL 1 SRC3 Overflow Status Off
522 ENUM 1 SRC3 Source Selector ADC1
6、tinycap
接上mic就可以录音了:
:/ # tinycap /sdcard/456.wav -d 1
Capturing sample: 2 ch, 44100 hz, 16 bit
^CCaptured 307200 frames
7、tinypcminfo
tinypcminfo用于查看pcm通道的相关信息:
xxxx:/storage/emulated/0/Music # tinypcminfo -D /proc/asound/cards
Info for card 0, device 0:
PCM out:
Access: 0x000009
Format[0]: 0x000ccc
Format[1]: 00000000
Format Name: S16_LE, S16_BE, S24_LE, S24_BE, S32_LE, S32_BE
Subformat: 0x000001
Rate: min=8000Hz max=192000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=0 max=24576
Period count: min=1 max=16
PCM in:
cannot open device '/dev/snd/pcmC0D0c'
Device does not exist.
也可以直接带上声卡和设备信息来查看:
如:device id:0,表示playback
:/ # tinypcminfo -D 0 -d 0
Info for card 0, device 0:
PCM out:
Access: 0x000009
Format[0]: 0x000ccc
Format[1]: 00000000
Format Name: S16_LE, S16_BE, S24_LE, S24_BE, S32_LE, S32_BE
Subformat: 0x000001
Rate: min=8000Hz max=192000Hz
Channels: min=1 max=2
Sample bits: min=16 max=32
Period size: min=0 max=24576
Period count: min=1 max=16
PCM in:
cannot open device '/dev/snd/pcmC0D0c'
Device does not exist.
如:device id:1,表示capture
:/ # tinypcminfo -D 0 -d 1
Info for card 0, device 1:
PCM out:
cannot open device '/dev/snd/pcmC0D1p'
Device does not exist.
PCM in:
Access: 0x000009
Format[0]: 0x000ccc
Format[1]: 00000000
Format Name: S16_LE, S16_BE, S24_LE, S24_BE, S32_LE, S32_BE
Subformat: 0x000001
Rate: min=8000Hz max=192000Hz
Channels: min=1 max=4
Sample bits: min=16 max=32
Period size: min=0 max=24576
Period count: min=1 max=49152
从上面获得的信息中可以知道PCM的采样率,通道个数,采样点数等信息。文章来源:https://www.toymoban.com/news/detail-430753.html
Android tinyAlsa命令详解:
Android tinyAlsa命令详解_Linux驱动专栏的博客-CSDN博客_tinyplay命令文章来源地址https://www.toymoban.com/news/detail-430753.html
到了这里,关于如何查看声卡、pcm设备以及tinyplay、tinymix、tinycap的使用 Android tinyAlsa命令详解:的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!