有谁用过audio gadget这个功能吗?我用了录音会报错
在内核配置usb gadget 选择 audio gadget,开启 uac1编译后,开启板子能够被识别为 ac interface 麦克风和扬声器设备
但是使用Windows录音机点击录音,板子提示如下错误:
====read frame error = -32===
Overrun occurred: -32
ALSA lib pcm.c:8905:(snd_pcm_recover) overrun occurred
====write frame error = -32===
Underrun occurred from write: -32
ALSA lib pcm.c:8905:(snd_pcm_recover) underrun occurred
rk eq_drc v2.02 2019-07-20 Oct 11 2019 09:26:56
psEqualizer->m_pfControlValue = 0.000000
param_name = /data/cfg/eq_bin/Para_48000Hz_2ch.bin
EQ/DRC Algorithm 3BAND_IIR_DIVFREQ PEAK VALUE V1.0...Oct 11 2019 09:26:56
GetLMTVersion v1.03 2019-10-10 Oct 11 2019 09:26:57,force=0 firstInit=1 贴出PC端和开发板端的操作步骤 firefly_zhongw 发表于 2020-4-25 09:33
贴出PC端和开发板端的操作步骤
在 kernel 中执行
make rk3308_linux_defconfig
make menuconfig
device drivers-->
<*>usb support -->
<*>usb gadget support-->
<*> usb gadget drivers (audio gadget)
audio gadget
<*> uac 1.0
该选项选中后,编译烧写进去板子,windows端识别到ac interface ,没有adb
音频设备与usb枚举log:
[ 0.556550] ALSA device list:
[ 0.556588] #0: UAC1_Gadget 0
[ 0.556608] #1: rockchip,rk3308-pcm
[ 0.556629] #2: rockchip,rk3308-vad
[ 0.556687] #7: Loopback 1
[ 0.559306] VFS: Mounted root (squashfs filesystem) readonly on device 31:6.
[ 0.560543] devtmpfs: mounted
[ 0.560835] Freeing unused kernel memory: 320K
[ 0.567647] dwc2 ff400000.usb: new address 11
[ 0.762785] dwc2 ff400000.usb: new device is high-speed
[ 0.795656] dwc2 ff400000.usb: new address 12
[ 0.818172] g_audio gadget: high-speed config #1: Linux USB Audio Gadget
eq/drc 程序运行log
==========EQ/DRC process release version 1.23===============
snd_pcm_open
snd_pcm_hw_params_malloc
snd_pcm_hw_params_any!
snd_pcm_hw_params_set_access!
snd_pcm_hw_params_set_format
channels = 2
bufferSize = 20480
periodSize = 1024
Rate = 48000
Open record device done
Open PCM: fake_play
[ 3.494665] dwmmc_rockchip ff4a0000.dwmmc: Busy; trying anyway
[ 3.494707] mmc_host mmc0: Timeout sending command (cmd 0x202000 arg 0x0 status 0x0)
interleaved mode
snd_pcm_hw_params_alloca
interleaved mode
format successed
3.507831]c hmamncn_eholsst=m m2c0:
Bus speed (slot 0) = 200000Hz (slot req 200000Hz, actual 200000HZ div = 0)
setting sampling rate (48000)
write_bufferSize = 4096
write_periodSize = 1024
rk eq_drc v2.02 2019-07-20 Oct 11 2019 09:26:56
psEqualizer->m_pfControlValue = 0.000000
open write device is successful
WAKE_LOCK id=eq_drc_process
param_name = /data/cfg/eq_bin/Para_48000Hz_2ch.bin
EQ/DRC Algorithm 3BAND_IIR_DIVFREQ PEAK VALUE V1.0...Oct 11 2019 09:26:56
GetLMTVersion v1.03 2019-10-10 Oct 11 2019 09:26:57,force=0 firstInit=1
串口端输出arecord -f dat -t wav -r 48000 -c 2 -D hw:2,0 /tmp/test.wav,执行录音
ctrl+c停止,得到音乐文件 test.wav
然后执行aplay /tmp/test.wav -c 2 -r 48000 -D hw:2,0 播放
Windows打开 录音机 软件 点击录音
串口提示错误log
:/$:aplay /tmp/test.wav -c 2 -r 48000 -D hw:2,0
Playing WAVE '/tmp/test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
====read frame error = -32===
Overrun occurred: -32
ALSA lib pcm.c:8905:(snd_pcm_recover) overrun occurred
你的UAC1是声卡Card 0,那对应的应该是 hw:0,0[ 0.556550] ALSA device list:
[ 0.556588] #0: UAC1_Gadget 0
[ 0.556608] #1: rockchip,rk3308-pcm
[ 0.556629] #2: rockchip,rk3308-vad
[ 0.556687] #7: Loopback 1 firefly_zhongw 发表于 2020-4-26 09:50
你的UAC1是声卡Card 0,那对应的应该是 hw:0,0
执行 arecord -f dat -t wav -r 48000 -c 2 -D hw:0,0 /tmp/test.wav
提示:
Recording WAVE '/tmp/test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
arecord: pcm_read:2143: read error: Input/output error
执行 aplay /tmp/test.wav -c 2 -r 48000 -D hw:0,0
提示报错:
aplay: main:828: audio open error: Device or resource busy
是这样设置是被Windows占用了声卡吗
Windows直接按录音一样报错
====read frame error = -32===
Overrun occurred: -32
ALSA lib pcm.c:8905:(snd_pcm_recover) overrun occurred
====read frame error = 64===
====write frame error = -32===
Underrun occurred from write: -32
ALSA lib pcm.c:8905:(snd_pcm_recover) underrun occurred
rk eq_drc v2.02 2019-07-20 Oct 11 2019 09:26:56
psEqualizer->m_pfControlValue = 0.000000
====read frame error = -32===
Overrun occurred: -32
ALSA lib pcm.c:8905:(snd_pcm_recover) overrun occurred
param_name = /data/cfg/eq_bin/Para_48000Hz_2ch.bin
EQ/DRC Algorithm 3BAND_IIR_DIVFREQ PEAK VALUE V1.0...Oct 11 2019 09:26:56
GetLMTVersion v1.03 2019-10-10 Oct 11 2019 09:26:57,force=0 firstInit=1
这个是什么错误 读写溢出? moose0 发表于 2020-4-26 11:41
执行 arecord -f dat -t wav -r 48000 -c 2 -D hw:0,0 /tmp/test.wav
提示:
Recording WAVE '/tmp/tes ...
请问怎么解决? moose0 发表于 2020-4-26 11:41
执行 arecord -f dat -t wav -r 48000 -c 2 -D hw:0,0 /tmp/test.wav
提示:
Recording WAVE '/tmp/tes ...
我解决,给后来人参考,我的理解是这样的,要是选择楼主这个配置就不需要按照rk文档每次都需要执行那个配置 UAC1 的脚本,每次开机电脑都能识别,所以每次执行最后这个脚本的"echo ff400000.usb > /sys/kernel/config/usb_gadget/rockchip/UDC"就会出现设备忙的现象,因为已经被识别了所以在此写的操作就会出现这个现象,但是这样做就会出现楼主的情况arecord出现错误,解决办法我按照rk文档来做的:
device drivers-->
<*>usb support -->
<*>USB Gadget Support--->
<*>USB Gadget Drivers(选择第一个)
[*]Audio Class 1.0
[*]Audio Class 2.0
[*]Audio Class 1.0和[*]Audio Class 2.0是我自己添加的类(没试过不选中的情况),然后编译内核烧入板子
最后在按照rk的文档《Rockchip-Developer-Guide-Linux4.4-USB-Gadget-UAC-CN.pdf》
执行命令就可以了,arecord就没出现楼主的问题了。关于怎么关闭adb参看如下帖子:
https://dev.t-firefly.com/forum.php?mod=viewthread&tid=101743&highlight=%B9%D8%B1%D5adb
页:
[1]