Есть встроенная в материнскую плату звуковая карта Realtek ALC892, и есть еще звук по HMDI, через монитор. Видеокарты нет, монитор подключен через встройку. К монитору подключены колонки, к передней панели системного блоки иногда бывают подключены наушники.
$ inxi -SA
System: Host: ryzen Kernel: 5.4.44-damix x86_64 bits: 64 Desktop: KDE Plasma 5.12.6
Distro: Ubuntu 18.04.1 LTS
Audio: Card-1 Advanced Micro Devices [AMD] Device 15e3 driver: snd_hda_intel Sound: ALSA v: k5.4.44-damix
Card-2 Advanced Micro Devices [AMD/ATI] Device 15de driver: snd_hda_intel
Настроил автоматическое переключение между наушниками и колонками, создав такие файлы.
ls ~/.config/pulse
6fd01137a9dd4721a04e7ac812867525-card-database.tdb 6fd01137a9dd4721a04e7ac812867525-default-source 6fd01137a9dd4721a04e7ac812867525-device-volumes.tdb client.conf daemon.conf system.pa
6fd01137a9dd4721a04e7ac812867525-default-sink 6fd01137a9dd4721a04e7ac812867525-device-manager.tdb 6fd01137a9dd4721a04e7ac812867525-stream-volumes.tdb cookie default.pa
$ cat ~/.config/pulse/default.pa
#!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)
.fail
### Automatically restore the volume of streams and devices
load-module module-device-restore
#load-module module-stream-restore
# to automatically switch between speakers and headphones https://forum.ubuntu.ru/index.php?topic=302863.msg2371550#msg2371550
load-module module-stream-restore restore_device=false
load-module module-card-restore
### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties
### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available
### Use hot-plugged devices like Bluetooth or USB automatically (LP: #1702794)
.ifexists module-switch-on-connect.so
load-module module-switch-on-connect
.endif
### Load audio drivers statically
### (it's probably better to not load these drivers manually, but instead
### use module-udev-detect -- see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink
### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif
### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif
### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif
### Load several protocols
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix
### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#load-module module-native-protocol-tcp
#load-module module-zeroconf-publish
### Load the RTP receiver module (also configured via paprefs, see above)
#load-module module-rtp-recv
### Load the RTP sender module (also configured via paprefs, see above)
#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'"
#load-module module-rtp-send source=rtp.monitor
### Load additional modules from GConf settings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gconf.so
.nofail
load-module module-gconf
.fail
.endif
### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore
### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams
### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink
### Honour intended role device property
load-module module-intended-roles
### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle
### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif
### Enable positioned event sounds
load-module module-position-event-sounds
### Cork music/video streams when a phone stream is active
load-module module-role-cork
### Block audio recording for snap confined packages unless they have
### the "pulseaudio" or "audio-record" interfaces plugged.
.ifexists module-snap-policy.so
load-module module-snap-policy
.endif
### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply
### Make some devices default
#set-default-sink output
#set-default-source input
$ cat /etc/acpi/jack-connected.sh
inputs=$(sudo -u homa XDG_RUNTIME_DIR=/run/user/`id -u homa` pacmd list-sink-inputs | awk '$1 == "index:" {print $2}')
for INPUT in $inputs; do # Move all current inputs to the new default sound card
sudo -u homa XDG_RUNTIME_DIR=/run/user/`id -u homa` pacmd move-sink-input $INPUT alsa_output.pci-0000_38_00.6.analog-stereo
done
$ cat /etc/acpi/jack-disconnected.sh
inputs=$(sudo -u homa XDG_RUNTIME_DIR=/run/user/`id -u homa` pacmd list-sink-inputs | awk '$1 == "index:" {print $2}')
for INPUT in $inputs; do # Move all current inputs to the new default sound card
sudo -u homa XDG_RUNTIME_DIR=/run/user/`id -u homa` pacmd move-sink-input $INPUT alsa_output.pci-0000_38_00.1.hdmi-stereo
done
$ cat /etc/acpi/events/jack-connected
event=jack/headphone HEADPHONE plug
action=/etc/acpi/jack-connected.sh
$ cat /etc/acpi/events/jack-disconnected
event=jack/headphone HEADPHONE unplug
action=/etc/acpi/jack-disconnected.sh
При подключенных наушниках ситуация такая
$ pacmd list-sinks
2 sink(s) available.
index: 0
name: <alsa_output.pci-0000_38_00.1.hdmi-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9030
volume: front-left: 39320 / 60% / -13,31 dB, front-right: 39320 / 60% / -13,31 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 0,00 ms
max request: 0 KiB
max rewind: 0 KiB
monitor source: 0
sample spec: s16le 2-канальный 4800
channel map: front-left,front-right
Стерео
used by: 0
linked by: 0
configured latency: 0,00 ms; range is 0,50 .. 341,33 ms
card: 0 <alsa_card.pci-0000_38_00.1>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "HDMI 0"
alsa.id = "HDMI 0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "3"
alsa.card = "0"
alsa.card_name = "HD-Audio Generic"
alsa.long_card_name = "HD-Audio Generic at 0xfe688000 irq 55"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:38:00.1"
sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:38:00.1/sound/card0"
device.bus = "pci"
device.vendor.id = "1002"
device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
device.product.id = "15de"
device.string = "hdmi:0"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "hdmi-stereo"
device.profile.description = "Digital Stereo (HDMI)"
device.description = "HD-Audio Generic Digital Stereo (HDMI)"
alsa.mixer_name = "ATI R6xx HDMI"
alsa.components = "HDA:1002aa01,00aa0100,00100700"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: yes)
properties:
device.icon_name = "video-display"
device.product.name = "27MB35"
active port: <hdmi-output-0>
* index: 1
name: <alsa_output.pci-0000_38_00.6.analog-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9039
volume: front-left: 60948 / 93% / -1,89 dB, front-right: 60948 / 93% / -1,89 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 0,00 ms
max request: 0 KiB
max rewind: 0 KiB
monitor source: 1
sample spec: s16le 2-канальный 4410
channel map: front-left,front-right
Стерео
used by: 0
linked by: 0
fixed latency: 100,14 ms
card: 1 <alsa_card.pci-0000_38_00.6>
module: 8
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "ALC892 Analog"
alsa.id = "ALC892 Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "HD-Audio Generic"
alsa.long_card_name = "HD-Audio Generic at 0xfe680000 irq 56"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:38:00.6"
sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:38:00.6/sound/card1"
device.bus = "pci"
device.vendor.id = "1022"
device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
device.product.id = "15e3"
device.string = "front:1"
device.buffering.buffer_size = "17664"
device.buffering.fragment_size = "2944"
device.access_mode = "mmap"
device.profile.name = "analog-stereo"
device.profile.description = "Аналоговый стерео"
device.description = "HD-Audio Generic Аналоговый стерео"
alsa.mixer_name = "Realtek ALC892"
alsa.components = "HDA:10ec0892,1462fa34,00100302"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
analog-output-lineout: Линейный выход (priority 9900, latency offset 0 usec, available: no)
properties:
analog-output-headphones: Аналоговые наушники (priority 9000, latency offset 0 usec, available: yes)
properties:
device.icon_name = "audio-headphones"
active port: <analog-output-headphones>
При отключенных такая
$ pacmd list-sinks
2 sink(s) available.
* index: 0
name: <alsa_output.pci-0000_38_00.1.hdmi-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9030
volume: front-left: 39320 / 60% / -13,31 dB, front-right: 39320 / 60% / -13,31 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 0,00 ms
max request: 0 KiB
max rewind: 0 KiB
monitor source: 0
sample spec: s16le 2-канальный 4800
channel map: front-left,front-right
Стерео
used by: 0
linked by: 0
configured latency: 0,00 ms; range is 0,50 .. 341,33 ms
card: 0 <alsa_card.pci-0000_38_00.1>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "HDMI 0"
alsa.id = "HDMI 0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "3"
alsa.card = "0"
alsa.card_name = "HD-Audio Generic"
alsa.long_card_name = "HD-Audio Generic at 0xfe688000 irq 55"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:38:00.1"
sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:38:00.1/sound/card0"
device.bus = "pci"
device.vendor.id = "1002"
device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
device.product.id = "15de"
device.string = "hdmi:0"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "hdmi-stereo"
device.profile.description = "Digital Stereo (HDMI)"
device.description = "HD-Audio Generic Digital Stereo (HDMI)"
alsa.mixer_name = "ATI R6xx HDMI"
alsa.components = "HDA:1002aa01,00aa0100,00100700"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: yes)
properties:
device.icon_name = "video-display"
device.product.name = "27MB35"
active port: <hdmi-output-0>
index: 1
name: <alsa_output.pci-0000_38_00.6.analog-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9039
volume: front-left: 60948 / 93% / -1,89 dB, front-right: 60948 / 93% / -1,89 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 0,00 ms
max request: 0 KiB
max rewind: 0 KiB
monitor source: 1
sample spec: s16le 2-канальный 4410
channel map: front-left,front-right
Стерео
used by: 0
linked by: 0
fixed latency: 100,14 ms
card: 1 <alsa_card.pci-0000_38_00.6>
module: 8
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "ALC892 Analog"
alsa.id = "ALC892 Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "HD-Audio Generic"
alsa.long_card_name = "HD-Audio Generic at 0xfe680000 irq 56"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:38:00.6"
sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:38:00.6/sound/card1"
device.bus = "pci"
device.vendor.id = "1022"
device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
device.product.id = "15e3"
device.string = "front:1"
device.buffering.buffer_size = "17664"
device.buffering.fragment_size = "2944"
device.access_mode = "mmap"
device.profile.name = "analog-stereo"
device.profile.description = "Аналоговый стерео"
device.description = "HD-Audio Generic Аналоговый стерео"
alsa.mixer_name = "Realtek ALC892"
alsa.components = "HDA:10ec0892,1462fa34,00100302"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
analog-output-lineout: Линейный выход (priority 9900, latency offset 0 usec, available: no)
properties:
analog-output-headphones: Аналоговые наушники (priority 9000, latency offset 0 usec, available: no)
properties:
device.icon_name = "audio-headphones"
active port: <analog-output-headphones>
Но иногда вновь открытые программы воспроизводят звук не через тот sink, который default, а как раз через другой.
Вставляю наушники, открываю любую программу, которой нужен звук.
Ожидаемое поведение: звук идет через наушники.
Реальное поведение: звук идет через колонки.
Обход: закрыть программу, вынуть наушники
pulseaudio -k
тогда система снова функционирует как настроена.
После каких действий система перестает функционировать как настроена, не знаю. Предположительно после долгого (несколько недель) аптайма. Но вот это время, прошедшее с последней перезагрузки или последнего перезапуска пульсы, необходимое для самопроизвольной поломки пульсы, каждый раз случайно.