I am uncertain which is at fault (or both), but I noticed that Veloren runs at a high CPU with many ALSA underruns. It also caused visual and auditory stuttering. The CPU can be observed by running Veloren in a single world game then suspending it by opening the menu to remove game activities. On my system, the CPU usage hovers around 70%. The process will output many of these messages: ALSA lib pcm.c:8526:(snd_pcm_recover) underrun occurred The underruns can be verified via /dev/sndstat with hw.snd.verbose=2. To reduce the CPU usage to below 10% (on my system again) and greatly reduce the underruns, I decreased the value of ALSA_OSS_BUFSZ_MAX in audio/alsa-plugins/files/patch-oss_pcm__oss.c from 131072 to 16384. 32768 appeared to be the maximum value that could be used without underruns. I am not sure if this is the best decision or not, but it fixed Veloren for me.
Is this with BUFSZ_P2 disabled like ports 27f51d17e156 requires? (In reply to Sean Farley from comment #0) > On my system, the CPU usage hovers around 70%. For me CPU usage is around 10% in foreground (current workspace) and 5% in background (different workspace). In both cases music is still playing, and I don't see "underrun occurred" ALSA warnings. Tested under sway-devel.
(In reply to Jan Beich from comment #1) Actually, no. My options were: BLKCNT_P2: on BUFSZ_P2: on FFMPEG: off JACK: off PULSEAUDIO: off SAMPLERATE: off SPEEX: off VERBOSE: off However, aplay worked for me for 16- and 32-bit WAV files but not the 8-bit file. $ aplay /usr/local/lib/python3.9/test/audiodata/pluck-pcm16.wav Playing WAVE '/usr/local/lib/python3.9/test/audiodata/pluck-pcm16.wav' : Signed 16 bit Little Endian, Rate 11025 Hz, Stereo $ aplay /usr/local/lib/python3.9/test/audiodata/pluck-pcm8.wav Playing WAVE '/usr/local/lib/python3.9/test/audiodata/pluck-pcm8.wav' : Unsigned 8 bit, Rate 11025 Hz, Stereo Assertion failed: (err >= 0), function set_params, file aplay.c, line 1399. Aborted by signal Abort trap... Apparently, that option was the issue. I disabled both *_P2 options, and it is now stable. Thank you very much! I probably kept them enabled when they were switched back and forth a few times. Out of curiosity, is there any use for those two options?
I also want to mention that with these options disabled, wine-devel can now play sounds when it could not with these options enabled. I do see a few underruns in wine-devel running https://github.com/BlueDragon28/MicrophoneLoopback, with ALSA_OSS_BUFSZ_MAX at either value. However, it does work now, so that is a good thing.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=95a0d0389f594dd16b293141bac889151303a560 commit 95a0d0389f594dd16b293141bac889151303a560 Author: Jan Beich <jbeich@FreeBSD.org> AuthorDate: 2023-09-23 17:02:11 +0000 Commit: Jan Beich <jbeich@FreeBSD.org> CommitDate: 2023-09-23 17:14:53 +0000 audio/alsa-plugins: remove debug options to prevent footshooting - BLKCNT_P2 and VERBOSE exposed compile knobs from https://people.freebsd.org/~ariff/libasound/20090928_00-alsa-plugins-1.0.21.diff - BUFSZ_P2 worked around crashes and high CPU usage in Firefox until native OSS support phased out ALSA - hselasky@ fixed many ALSA issues over the years - users can still adjust compile knobs via make.conf(5) or Makefile.local PR: 274047 audio/alsa-plugins/Makefile | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
Let's see if anyone complains.
(In reply to Jan Beich from comment #5) Thank you! No complaints from my foot either! :D