Re: better audio defaults: please test
On 2021-11-04 16:21:12, Alexandre Ratchov wrote: > The current sndiod latency (minimum time between when the program > plays something and when sound reaches Joe's ears) is too large and > makes OpenBSD unpleasant to use for telephony, games, and makes > controls of video players slugish. > > [...] > > Please try to switch you system to 40ms buffers (i.e. 1920 samples at > the default 48kHz rate), for instance either apply diff below or > simply do: > > rcctl set sndiod flags -z 480 -b 1920 > rcctl restart sndiod > > then report any significant increase of stuttering, and what > software/hardware triggers it. If you think 20ms or 30ms (i.e. 960 and > 1440 sample buffers) are better, let me know as well. > I experienced stuttering while watching YouTube videos with "-z 480 -b 1920" when pegging all CPUs to 100% (building a large port like Firefox or building a kernel). I tried doubling it to "-z 960 -b 3840" and the stuttering went away. I then tried taking the middle and set "-z 720 -b 2880" and the audio was still OK. So it seems my system can't be set as low as 480/1920 but 720/2880 or higher works. This is on a: cpu0: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz, 3890.94 MHz, 06-9e-09 in a ThinkPad T470p running on: OpenBSD 7.0-current (GENERIC.MP) #93: Sat Nov 13 18:25:45 MST 2021 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP Hopefully this information helps. Please let me know if you require any more information. -- Bryan
Re: better audio defaults: please test
On Thu, Nov 04, 2021 at 04:21:12PM +0100, Alexandre Ratchov wrote: > The current sndiod latency (minimum time between when the program > plays something and when sound reaches Joe's ears) is too large and > makes OpenBSD unpleasant to use for telephony, games, and makes > controls of video players slugish. > > The defaut latency (of 160ms) was set ~10 years ago to workaround > various problems: KERNEL_LOCK used to block audio processing for very > long, azalia(4) and uaudio(4) were unable to recover after an error, > which aggravated the problem. > > The kernel improved a lot the last decade and such large buffers are > not necessary anymore. I think something between 20ms and 40ms is a > better default for the average OpenBSD system: > > * audio-conferencing software and games requires no sndiod_flags >tweaks anymore > > * on modern machines (like my 7 years old i5-2500K) building a kernel >doesn't make audio stutterer > > * sndiod_flags tweaks will still be needed for: > - very slow or overloaded machines used for audio > - machines running heavy/bogus SMM code > - real-time synths & effects (20ms is still too small) > > Please try to switch you system to 40ms buffers (i.e. 1920 samples at > the default 48kHz rate), for instance either apply diff below or > simply do: > > rcctl set sndiod flags -z 480 -b 1920 > rcctl restart sndiod This introduces noticable stuttering on my X230 runs a few xterms and firefox with idle tabs. The one thing I always use for testing audio is `pkg_add -u' while playing `mpv songXY.ogg': whether or not it installs pacakges does not matter. A noop run is enough to notice stuffer with this diff while the current sndio defaults do not produce any stutter. > then report any significant increase of stuttering, and what > software/hardware triggers it. If you think 20ms or 30ms (i.e. 960 and > 1440 sample buffers) are better, let me know as well. Trying above rcctl lines with `-b 1440' and `-b 960' made it worse: more stutter and noticably slower sound playback, in increasing order. ^Z the pkg_add process restores audio to normal. `fg' it brings stutter back, i.e. without `pkg_add' running I hear no difference using any of the three values. > Note that OpenBSD is not real-time (neither are programs we run) so > audio may stutter no matter how large the buffers are. The goal here > is to get a ballance between disconfort caused by latency and > probability of stuttering for the average OpenBSD system. > > If we reach a consensus, here's the diff to make above settings the > default. > > OK? > > Index: sndiod.c > === > RCS file: /cvs/src/usr.bin/sndiod/sndiod.c,v > retrieving revision 1.47 > diff -u -p -r1.47 sndiod.c > --- sndiod.c 1 Nov 2021 14:43:25 - 1.47 > +++ sndiod.c 1 Nov 2021 15:28:37 - > @@ -82,7 +82,7 @@ > * buffer size if neither ``-z'' nor ``-b'' is used > */ > #ifndef DEFAULT_BUFSZ > -#define DEFAULT_BUFSZ7680 > +#define DEFAULT_BUFSZ1920 > #endif > > void sigint(int); > So at least for my setup this is not an improvement. I quickly tried the mid-value between 7680 and 1920, 4800, and with that I hear no stutter while `pkg_add' is running! Smaller values probably work but I didn't bisect it to the lowest possible value.
Re: better audio defaults: please test
Hi Alexandre, * Alexandre Ratchov wrote: > The current sndiod latency (minimum time between when the program > plays something and when sound reaches Joe's ears) is too large and > makes OpenBSD unpleasant to use for telephony, games, and makes > controls of video players slugish. > > The defaut latency (of 160ms) was set ~10 years ago to workaround > various problems: KERNEL_LOCK used to block audio processing for very > long, azalia(4) and uaudio(4) were unable to recover after an error, > which aggravated the problem. > > The kernel improved a lot the last decade and such large buffers are > not necessary anymore. I think something between 20ms and 40ms is a > better default for the average OpenBSD system: > > * audio-conferencing software and games requires no sndiod_flags >tweaks anymore > > * on modern machines (like my 7 years old i5-2500K) building a kernel >doesn't make audio stutterer > > * sndiod_flags tweaks will still be needed for: > - very slow or overloaded machines used for audio > - machines running heavy/bogus SMM code > - real-time synths & effects (20ms is still too small) > > Please try to switch you system to 40ms buffers (i.e. 1920 samples at > the default 48kHz rate), for instance either apply diff below or > simply do: > > rcctl set sndiod flags -z 480 -b 1920 > rcctl restart sndiod I have sndiod on -current with this flag running and it quite makes a difference. Audio stutters when having a movie running and reloading some JS heavy websites in parallel are gone. So quite a good improvement! Cheers Matthias
better audio defaults: please test
The current sndiod latency (minimum time between when the program plays something and when sound reaches Joe's ears) is too large and makes OpenBSD unpleasant to use for telephony, games, and makes controls of video players slugish. The defaut latency (of 160ms) was set ~10 years ago to workaround various problems: KERNEL_LOCK used to block audio processing for very long, azalia(4) and uaudio(4) were unable to recover after an error, which aggravated the problem. The kernel improved a lot the last decade and such large buffers are not necessary anymore. I think something between 20ms and 40ms is a better default for the average OpenBSD system: * audio-conferencing software and games requires no sndiod_flags tweaks anymore * on modern machines (like my 7 years old i5-2500K) building a kernel doesn't make audio stutterer * sndiod_flags tweaks will still be needed for: - very slow or overloaded machines used for audio - machines running heavy/bogus SMM code - real-time synths & effects (20ms is still too small) Please try to switch you system to 40ms buffers (i.e. 1920 samples at the default 48kHz rate), for instance either apply diff below or simply do: rcctl set sndiod flags -z 480 -b 1920 rcctl restart sndiod then report any significant increase of stuttering, and what software/hardware triggers it. If you think 20ms or 30ms (i.e. 960 and 1440 sample buffers) are better, let me know as well. Note that OpenBSD is not real-time (neither are programs we run) so audio may stutter no matter how large the buffers are. The goal here is to get a ballance between disconfort caused by latency and probability of stuttering for the average OpenBSD system. If we reach a consensus, here's the diff to make above settings the default. OK? Index: sndiod.c === RCS file: /cvs/src/usr.bin/sndiod/sndiod.c,v retrieving revision 1.47 diff -u -p -r1.47 sndiod.c --- sndiod.c1 Nov 2021 14:43:25 - 1.47 +++ sndiod.c1 Nov 2021 15:28:37 - @@ -82,7 +82,7 @@ * buffer size if neither ``-z'' nor ``-b'' is used */ #ifndef DEFAULT_BUFSZ -#define DEFAULT_BUFSZ 7680 +#define DEFAULT_BUFSZ 1920 #endif void sigint(int);