Re: Silent noise while running simple OSS program and moving mouse?

From: Florian Walpen <dev_at_submerge.ch>
Date: Sun, 16 May 2021 22:56:30 UTC
On Monday, May 17, 2021 12:01:31 AM CEST Evgeniy Khramtsov via freebsd-
multimedia wrote:
> Hi.
> 
> I wrote this simple OSS program that outputs sound from microphone back
> to the speakers (the close() and stuff is omitted):
> https://pastebin.com/raw/yX4gm5fL

Maybe not the culprit, but I'd definitely recommend to prefill the playback 
buffer with some silence before starting the loop. Like 3-4 times your buffer 
size of zeros. Otherwise you are very likely to produce underruns.

> 
> It works, though for some reason I get some silent noise while moving
> mouse around. Any ideas what could be wrong? Thanks.

You can check for underruns programmatically via SNDCTL_DSP_GETERROR, or 
through sndstat with:

sysctl hw.snd.verbose=2
cat /dev/sndstat

Hope that helps.

Florian Walpen