Sound server

A sound server is used if multiple applications access sound. It manages the access to the sound hardware.

pipewire

The most new is pipewire that is considered a replacement to pulseaudio and jack. Alsa applications get aware about it when adding

pcm.!default {
  type pipewire
}

ctl.!default {
  type pipewire
}

to /etc/asound.conf

For Gentoo it seems to be necessary to copy the configuration file

cp /usr/share/pipewire/pipewire.conf /etc/pipewire/pipewire.conf

Pulseaudio

Without pulseaudio programs have to access the sound hardware directly and prevent other programs to access it. pulseaudio allows to configure what sound cards are used and allow to mute and adjust the volume also when the soundcard does not support it (as modern HDMI output)

Pulseaudio uses the terms sinks this is where it sends the audio and source where it takes the audio.

https://gavv.github.io/articles/pulseaudio-under-the-hood/

Unfortunately what program can access the hardware problem existed a long time so many programs got enhanced to be more flexible and autonomous. The backside is that those "historical" features might get in conflict with a central sound server as pulseaudio

Obviously pulseaudio puts also a middleware between ALSA and the application and get a more standard sound interface.

Under gentoo there is the pulseaudio and alsa-plugin useflag to let the system be aware of pulsaudio.https://wiki.gentoo.org/wiki/PulseAudio

Pulseaudio Configuration

To assure that just pulseaudio has control, the users should not be in the audio group https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/PerfectSetup/

For Desktop systems do not use system wide configuration, since every user might have its own setup. So do not run it as root.

/etc/asound.conf file could be a symolic link to /usr/share/alsa/pulse-default.conf ln -s /usr/share/alsa/pulse-default.conf /etc/asound.conf

There are tools as pavucontrol, pavucontrol-qt or pulsemixer for volume control of pulse and paprefs for it preferences.

Start pavucontrol and turn off the Configuration the profiles that have no speaker plugged in.

The programs should be made aware of the pulseaudio sound server.

mplayer needs to set /etc/mplayer/mplayer.conf

ao=pulse

mplayer /usr/share/sounds/alsa/* is a good test to see if it runs

Pulseaudio can be started as daemon pulseaudio --start and then the daemon can be stopped pulseaudio --kill

pacmd opens the pulseaudio shell where commands as in ~/.config/pulse/default.pa can be inserted. help shows all commands, Ctrl+d or exit exits the shell. Alternatively commands can be passed on the command line: pacmd <command>. In this case the command is executed and pacmd exits. As man pacmd shows there are not many command line options.

pactl behaves similar as pacmd <command> but has more command line options, more options to show things but supports less commands from ~/.config/pulse/default.pa

pacmd list-sinks|egrep -i 'index:|name:' lists the names of the sinks, the one with the * is the default sink

pacmd list-cards|egrep -i 'index:|name:' lists the names of the cards

pacmd list-cards shows all profiles

pactl set-sink-mute <n> toggle toggles mute <n> is the sink (= output device) number shown in pactl list

pactl set-sink-mute alsa_output.pci-0000_01_05.1.hdmi-stereo toggle does the same using the name

pactl set-sink-volume 1 70% set the volume

pactl set-sink-volume 1 +5% increases it

Troubleshoot pulseaudio

Pulseaudio might start without any sound. pavucontrol might show in the Configuration the profiles Off. So it simply does not know what to do and does not restore settings. To help the config file ~/.config/pulse/default.pa can be created as:

.include /etc/pulse/default.pa
set-default-sink alsa_output.pci-0000_01_05.1.hdmi-stereo
set-card-profile alsa_card.pci-0000_01_05.1 output:hdmi-stereo
set-sink-port alsa_output.pci-0000_01_05.1.hdmi-stereo hdmi-output-0

The first line loads the system default settings that might get lost if a ~/.config/pulse/default.pa exists. It is worth to set a default sink and have the card set a profile.

Do not run pulseaudio as root, if so it might create subdirectories under ~ that belong to root and create write permission errors. If this happen do chown -R <username> /home/<username>/. It might also happen that one users configuration gets messed up. I such cases try with an other user and if this works copy over the config file ~/.config/pulse/default.pa

HDMI audio might show "not available" and "unplugged" and therefore pulseaudio jumps to a next sink. xrandr --verbose might show that audio is auto, this can be set to on using xrandr --output HDMI-0 --set "audio" on or with pulse audio commands in ~/.config/pulse/default.pa that prevent from switching to the next and disabling unwanted profiles

unload-module module-switch-on-port-available
set-card-profile alsa_card.pci-0000_00_14.2 off

Linurs startpage