Usb audio playback has frame drop

I could hear the frame drop from my speaker when I use the USB sound card. But I did not hear that from HDMI. Does anyone knows how to fix that issue? Also, I dump the playback data from the output. you can see the frame drop.

I am not sure who can help me answer this question. But I am still waiting for the solution.

Audio lag sometimes is caused by the audio buffer’s overrun or underrun. In some cases, it’s caused by the driver’s verbose logs. So if see many logs output in the UART console, you could try below command:

echo 0 > /proc/sys/kernel/printk

If there have long latency caused by disabling interrupt or preemption, need to dig into the software flow to find what’s the cause for long latency. Please check if Ftrace’s latency tracers can help or not [1].

For more complex case, need to analyse Ftrace log to review the flows and find bottleneck.

[1] https://www.osadl.org/fileadmin/dam/presentations/RTLWS11/rostedt-ftrace.pdf; page 20

Yeah, that’s probably an underrun. Likely the clock on the sound card is running a little too fast and consuming data faster than you are feeding it.

What is the source of the data that you are feeding into it? My suggestion, if this isn’t what you have already done, is to try playback of a pcm/wav file using tinyplay, which should be able to keep the buffer filled.

This works for me. Thanks for your great support.

thanks again,
Kylin

You are welcome!

Just follow up @doitright, base on the I2S driver [1], you could specify period count to enlarge the audio buffer. This would be more flexible for usage cases. E.g. for tinyplay command, you could use option ‘-n’ to specify period number (period size is fixed to 4KB, so finally buffer size is 4KB * period number).

[1] sound/soc/hisilicon/hisi-i2s.c - kernel/hikey-linaro - Git at Google