On Tue, Jun 10, 2025 at 12:05:24PM +0200, Alexandre Ratchov wrote: > On Mon, Jun 09, 2025 at 12:29:09AM +0100, Chris Narkiewicz wrote: > > I have a pair of wireless headphones with USB dongle. > > When connected, device is attached as uaudio0. > > > > I noticed frequent clicks when playing music and browsing web. > > I adjusted sndiod buffer size and number of frames, but no result. > > > > The clicking is probably caused by the browser "stealing" the CPU from > sndiod and/or from the usb driver. This can't be fixed by increasing > the audio buffer size; the default one is already huge, btw.
AFAIK the USB audio code still uses KERNEL_LOCK so anything doing heavy disk operations will cause noticable clicking. I normally notice it with git commands that just hammer the kernel and spin on KERNEL_LOCK for no good reason. > > I noticed that play.errors parameter is rising during clicking, > > suggesting buffer underruns: > > > > # audioctl -f /dev/audioctl1 > > audioctl -f /dev/audioctl1 > > name=uaudio0 > > mode=play,record > > pause=0 > > active=1 > > nblks=2 > > blksz=1020 > > rate=48000 > > encoding=s24le3 > > play.channels=2 > > play.bytes=2784600 > > play.errors=12240 > > record.channels=1 > > record.bytes=1392300 > > record.errors=0 > > > > I tried to adjust the nblks and blksz to larger values: > > > > # audioctl -f /dev/audioctl1 blksz=8192 nblks=16 > > audioctl -f /dev/audioctl1 blksz=8192 nblks=16 > > nblks: 2 -> 16 > > blksz: 1020 -> 8192 > > > > To change the hardware parameters, use "-f /dev/audio1", but > see below. > > > So far, so good - I thought. > > > > When starting mpv (or mpd), the value is reset to > > nblks: 2 > > blksz: 1020 > > > > and clicking continues. > > > > Why the value is accepted initially only to be reverted when I start > > playing sound? > > The program using the device (sndiod in your case) sets its own > parameters, so they change as soon as the program starts using the > device. > > To change the parameters, configure the program. Ex, for sndiod: > > rcctl set sndiod flags -z 480 -b 960 > -- :wq Claudio