You are not logged in.
Hello,
I am trying to configure audio output (sound) for multiple system users. I am doing it for security reasons (new user will be sandboxed) - but i would like to share Alsa and PulseAudio (for me sharing system sound between users is acceptable risk).
I have implemented this
https://wiki.archlinux.org/title/wine#R … er_account
and this:
https://wiki.archlinux.org/title/PulseA … dio_daemon
And PulseAudio is working. I have sound in the new user. The main problem is very ugly text output (stdout) with Alsa sound.
For example, when i will run this command (openttd is a normal game):
sudo -u games env HOME=/home/games USER=games USERNAME=games LOGNAME=games /bin/openttd
then sound is working (because Pulse Audio server/socket is working for new user), but i have very ugly output in the terminal:
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5703:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5703:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM sysdefault
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
(...)
I found that the other difference is :
from main user:
rdbeni0 $ fuser -v /dev/snd/* # and the output is correct
/dev/snd/controlC0: rdbeni0 foo F.... pulseaudio
/dev/snd/controlC1: rdbeni0 foo F.... pulseaudio
/dev/snd/pcmC0D7p: rdbeni0 foo F...m pulseaudio
rdbeni0 $ aplay -l # and again - the output is correct
**** List of PLAYBACK Hardware Devices ****
card 0: Generic [HD-Audio Generic], device 3: HDMI 0 [PHL 243V7]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 7: HDMI 1 [PL2730H]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 8: HDMI 2 [HDMI 2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 0: ALC257 Analog [ALC257 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
but for new user:
rdbeni0 $ sudo -u games env HOME=/home/games USER=games USERNAME=games LOGNAME=games /bin/aplay -l
aplay: device_list:275: no soundcards found...
rdbeni0 $ sudo -u games env HOME=/home/games USER=games USERNAME=games LOGNAME=games fuser -v /dev/snd/*
# its empty! no output here
So it means that Alsa is not working (probably is locked) for new user.
I have installed below packages - maybe it is too much?
rdbeni0 $ pacman -Q |grep alsa
alsa-lib 1.2.7.2-1
alsa-oss 1.1.8-4
alsa-plugins 1:1.2.7.1-1
alsa-topology-conf 1.2.5.1-1
alsa-ucm-conf 1.2.7.2-1
alsa-utils 1.2.7-1
lib32-alsa-lib 1.2.7.2-1
lib32-alsa-oss 1.1.8-3
lib32-alsa-plugins 1.2.7.1-1
pulseaudio-alsa 1:1.2.7.1-1
rdbeni0 $ pacman -Q |grep pulse
apulse 0.1.13-1
lib32-libpulse 16.1-1
libpulse 16.1-1
pulseaudio 16.1-1
pulseaudio-alsa 1:1.2.7.1-1
xfce4-pulseaudio-plugin 0.4.5-1
Please note that:
-- for main user (rdbeni0) everything is working correctly. No issues.
-- lets say that games is the new user and he is using /home/games
-- user games is not in the sound group (he has only his group):
sudo -u games env HOME=/home/games USER=games USERNAME=games LOGNAME=games id
uid=1002(games) gid=1003(games) groups=1003(games)
-- i dont have file /home/games/.asoundrc (this file is not exist)
-- /etc/asound.conf is empty (this file is exist, but no config here - just empty)
-- i installed package pulseaudio-alsa and i have file /etc/alsa/conf.d/99-pulseaudio-default.conf
-- basically i have the sound, i can hear the music, voice, effects, etc. The main problem is very ugly cli output and it seems that Alsa is misconfigured - i would like just to fix it
Last edited by rdbeni0 (2022-10-16 15:35:01)
Offline
Try exposing the DBUS_SESSION_BUS_ADDRESS of your user so that the game can check for pulse directly, other than that I'd ignore the console spam, could be an implementation detail of the engine, e.g. if this is using OpenAL it might be necessary/useful to create a .alsoftrc in the game users home dir directing to pulse directly:
[general]
drivers = pulse
Offline
@V1del
thank you, I will update some env variables and will try experiments with .alsoftrc.
This topis is solved. I found that sound is working, but i have some troubles for few games which are using midi sound (and FluidSynth as backend). Basically for openttd I used solutions from there: https://wiki.archlinux.org/title/OpenTTD :
~/.openttd/openttd.cfg
[misc]
musicdriver = "extmidi:cmd=/home/<user>/.openttd/playmidi.sh"
... and after that - no issues.
I have also similar issue with game simutrans which is also using midi, but sound is working. Just ugly output. But i also found that in normal user, output for simutrans game is also ugly... basically we can say that this is "game specific" - and if game will use midi, then i can expect bad output. But game should work.
Last edited by rdbeni0 (2022-10-16 15:41:32)
Offline