Relative Content

Tag Archive for ubuntualsausb-audio

snd_pcm_wait timeout with USB driver and certain buffer sizes

I’m testing audio playback using ALSA on Ubuntu 22.04, using USB audio devices that I think use the USB class audio driver.
I’ve found that for certain ranges of buffer size, snd_pcm_wait() always times out.
Two example buffer sizes are 1024 (512 period x2) and 2048 (1024 period x2) at 48000hz
They are ranges as opposed to specific values, but they are quite narrow, e.g. the behavior is the same from 998 to 1028.
At 96000hz, the problematic buffer sizes are twice the size of those at 48000hz.
If I don’t wait or wait for a small timeout (i.e. period size) instead of a large one (e.g. 1 second), it still times out but the audio streaming works nonetheless as snd_pcm_avail_update() correctly reports samples being available. This workaround is however not ideal and results in slightly higher cpu usage.