[Solved] Audio output changes every time screen goes to sleep

User Intro/Background:
Hello, I'm a new Manjaro user (roughly 4-6 weeks), been trying to make a go at using Linux-desktop as a daily-runner ... extra downtime due to COVID, and a long-coming desire to leave the Windows-camp. I've been a Windows user since about '92 (DOS 4.0/Win3.1 era and up); an Unraid user since 2015 - running Windows/Gaming as VM-guest on my Unraid host. So far I've enjoyed Manjaro, I really like it. Tinkering with Proton, Steam, has been a great distraction lately.

I have experienced one issue (annoyance-level not critical) which I've been unable to resolve. Part of my issue, trying to diagnosis/troubleshoot, is that I don't know all of the pieces/components which make up Linux - let alone how they interact with each other, So I don't know what terms/keywords, and what-not, to search for (generally speaking). Side note: I did try searching through newbie and driver categories as well as Duckduckgo, but failed to find a solution.

Description of Issue:
Default audio output is set to HDMI on my monitor, works great. Power Manager settings are all default. When my system goes idle for 10 minutes, the monitor blanks off - expected behavior.

When I, "wake up" (move mouse for monitor to come back on) the default audio output switches to my Corsair headset. I then have to click on the volume icon (bottom-right-hand corner of desktop, next to date/time) and select the HDMI output.

  • Reproducible: Yes, issue occurs every time monitor is put to sleep.

  • (My) Hypothesis cause of symptom: From my searches, when HDMI goes to sleep the audio subsystem (daemon? pulse? -- this is where my gaps in knowledge hurt) considers it disconnected and automatically switches the output to headphones.

  • Known workaround: Turn off, "Display power management" under Display-tab in Xfce Power Manager. However, this is an unsatisfactory solution for me - I prefer to have the display go to sleep/black.

System Background

System:
  Kernel: 5.6.15-1-MANJARO x86_64 bits: 64 compiler: gcc v: 10.1.0 
  Desktop: Xfce 4.14.2 tk: Gtk 3.24.20 info: xfce4-panel wm: xfwm4 
  dm: LightDM 1.30.0 Distro: Manjaro Linux 
Machine:
  Type: Qemu System: QEMU product: Standard PC (Q35 + ICH9, 2009) 
  v: pc-q35-4.2 serial: <filter> Chassis: type: 1 v: pc-q35-4.2 
  serial: <filter> 
  Mobo: N/A model: N/A serial: N/A UEFI: EFI Development Kit II / OVMF 
  v: 0.0.0 date: 02/06/2015 
Memory:
  RAM: total: 32.30 GiB used: 2.05 GiB (6.4%) 
  RAM Report: 
  permissions: Unable to run dmidecode. Root privileges required. 
CPU:
  Topology: Quad Core model: AMD Ryzen Threadripper 1950X bits: 64 
  type: MT MCP arch: Zen rev: 1 L2 cache: 2048 KiB bogomips: 54396 
  Speed: 3393 MHz min/max: N/A Core speeds (MHz): 1: 3393 2: 3393 3: 3393 
  4: 3393 5: 3393 6: 3393 7: 3393 8: 3393 
  Flags: 3dnowprefetch abm adx aes apic arat avx avx2 bmi1 bmi2 clflush 
  clflushopt cmov cmp_legacy cpuid cr8_legacy cx16 cx8 de extd_apicid f16c 
  fma fpu fsgsbase fxsr fxsr_opt ht hypervisor ibpb lahf_lm lm mca mce 
  misalignsse mmx mmxext movbe msr mtrr nopl npt nrip_save nx osvw pae pat 
  pclmulqdq pdpe1gb perfctr_core pge pni popcnt pse pse36 rdrand rdseed 
  rdtscp rep_good sep sha_ni smap smep ssbd sse sse2 sse4_1 sse4_2 sse4a 
  ssse3 svm syscall topoext tsc tsc_adjust tsc_deadline_timer virt_ssbd vme 
  vmmcall x2apic xgetbv1 xsave xsavec xsaveopt 
Graphics:
  Device-1: NVIDIA TU106 [GeForce RTX 2070] vendor: eVga.com. driver: nvidia 
  v: 440.82 bus ID: 04:00.0 chip ID: 10de:1f02 
  Display: x11 server: X.Org 1.20.8 driver: nvidia tty: N/A 
  OpenGL: renderer: GeForce RTX 2070/PCIe/SSE2 v: 4.6.0 NVIDIA 440.82 
  direct render: Yes 
Audio:
  Device-1: NVIDIA TU106 High Definition Audio vendor: eVga.com. 
  driver: snd_hda_intel v: kernel bus ID: 05:00.0 chip ID: 10de:10f9 
  Device-2: Corsair Corsair VOID PRO USB Gaming Headset type: USB 
  driver: hid-generic,snd-usb-audio,usbhid bus ID: 1-4:5 chip ID: 1b1c:0a17 
  serial: <filter> 
  Sound Server: ALSA v: k5.6.15-1-MANJARO 
Network:
  Device-1: Red Hat Virtio network driver: virtio-pci v: 1 port: 1000 
  bus ID: 01:00.0 chip ID: 1af4:1041 
  IF-ID-1: enp1s0 state: up speed: -1 duplex: unknown mac: <filter> 
  IP v4: <filter> type: dynamic noprefixroute scope: global 
  broadcast: <filter> 
  IP v6: <filter> type: noprefixroute scope: link 
  WAN IP: <filter> 
Drives:
  Local Storage: total: 3.93 TiB used: 380.95 GiB (9.5%) 
  ID-1: /dev/sda vendor: QEMU model: HARDDISK size: 3.64 TiB speed: 1.5 Gb/s 
  serial: <filter> rev: 2.5+ scheme: GPT 
  ID-2: /dev/vda model: N/A size: 300.00 GiB speed: <unknown> serial: N/A 
  scheme: GPT 
  Optical-1: /dev/sr0 vendor: QEMU model: QEMU DVD-ROM rev: 2.5+ 
  dev-links: cdrom 
  Features: speed: 4 multisession: yes audio: yes dvd: yes rw: none 
  state: running 
RAID:
  Message: No RAID data was found. 
Partition:
  ID-1: / size: 294.00 GiB used: 16.52 GiB (5.6%) fs: ext4 dev: /dev/vda2 
  label: N/A uuid: b8eef2f0-fb49-47e0-ad06-025eac158ab2 
  ID-2: /boot/efi size: 299.4 MiB used: 280 KiB (0.1%) fs: vfat 
  dev: /dev/vda1 label: N/A uuid: 5112-AE1C 
  ID-3: /mnt/BTsync size: 15.46 TiB used: 3.19 TiB (20.7%) fs: cifs 
  remote: //192.168.100.50/btsync label: N/A uuid: N/A 
  ID-4: /mnt/Games size: 3.58 TiB used: 364.43 GiB (9.9%) fs: ext4 
  dev: /dev/sda1 label: games uuid: 464e127e-81fb-4afe-8413-5575d932aa5c 
  ID-5: /mnt/media size: 43.65 TiB used: 16.09 TiB (36.9%) fs: cifs 
  remote: //192.168.100.50/media label: N/A uuid: N/A 
Unmounted:
  Message: No unmounted partitions found. 
USB:
  Hub: 1-0:1 info: Full speed (or root) Hub ports: 15 rev: 2.0 
  speed: 480 Mb/s chip ID: 1d6b:0002 
  Device-1: 1-1:2 info: Logitech F310 Gamepad [XInput Mode] 
  type: <vendor specific> driver: xpad interfaces: 1 rev: 2.0 speed: 12 Mb/s 
  chip ID: 046d:c21d serial: <filter> 
  Device-2: 1-2:3 info: Razer USA Razer Naga 2014 type: Mouse,Keyboard 
  driver: hid-generic,usbhid interfaces: 3 rev: 2.0 speed: 12 Mb/s 
  chip ID: 1532:0040 
  Device-3: 1-3:4 info: Razer USA BlackWidow Ultimate 2013 
  type: Keyboard,Mouse driver: hid-generic,usbhid interfaces: 3 rev: 2.0 
  speed: 12 Mb/s chip ID: 1532:011a 
  Device-4: 1-4:5 info: Corsair Corsair VOID PRO USB Gaming Headset 
  type: Audio,HID driver: hid-generic,snd-usb-audio,usbhid interfaces: 4 
  rev: 2.0 speed: 12 Mb/s chip ID: 1b1c:0a17 serial: <filter> 
  Hub: 2-0:1 info: Full speed (or root) Hub ports: 15 rev: 3.0 speed: 5 Gb/s 
  chip ID: 1d6b:0003 
Sensors:
  Message: No sensors data was found. Is sensors configured? 
Info:
  Processes: 250 Uptime: 1h 11m Init: systemd v: 245 Compilers: gcc: 10.1.0 
  Shell: bash v: 5.0.17 running in: xfce4-terminal inxi: 3.0.37 

Research

I've tried to RTM and research, but I'll admit knowledge-gaps and I'm still working on my learning-curve, so fair chance I've missed or overlooked something. Any assistance would be appreciated. If I've omitted diagnostics, please let me know. Partly my issue, in troubleshooting, I don't know if this is with Pulse, ALSA, or something else? (I don't know how ALSA and pulse differ)

In simple terms ALSA is a low-level sound card driver for your hardware and PulseAudio is the middleware between applications and ALSA.

From a little searching around I found that your desktop environment, XFCE doesn't have an elegant way to switch your default pulseaudio output sink.

Gnome and KDE have a more robust method through their system tray icons. Have you considered those DEs?

If not, and you want to stick with XFCE than you'll need to read up on these pages.
Pulseaudio example - Set the default output sink
Freedesktop Pulseaudio Documentation - Default/fallback devices

Xfce PulseAudio Panel Plugin

pavucontrol may also have this option, but I'm not sure. Hope something here helps.

pasystray from community repository show or change default sink for playback

but do not need to install extra packages just to change default sink
to find out default sink on pulseaudio use either:
pactl info
or
pacmd dump
2nd command is better for this case as it will also show names of other playback sinks

on my system there is an HDMI sink -

alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1

but default sink is set to analog-stereo

set-default-sink alsa_output.pci-0000_04_06.0.analog-stereo

command to change default sink to the HDMI output is:

pacmd set-default-sink alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1
1 Like

@nikgnomic and @mooselimb thank you for your replies, while neither had a "silver-bullet fix," the URL on Pulseaudio examples and the some of the cli from Nik's post gave me a lot of insight. Your posts were great nudges and helped me find my fix. While it took me a number of trial-and-error steps I found/brute-forced the solution, fixing my issue.

After a number of tries, and a few web-searches later I stumbled upon: https://askubuntu.com/questions/1183052/selected-sound-output-device-not-persisting-between-reboots-in-gnome-control-cen/1183074#1183074
Which, has a piece of insight that contributed to my fix.

Solution to my Issue:

  • In the file: /etc/pulse/default.pa added the entry on line#34.
load-module module-switch-on-connect
  • In the file /etc/pulse/default.pa changed 2nd-to-last line from:
#set-default-sink output

to:

set-default-sink alsa_output.pci-0000_05_00.0.hdmi-stereo-extra1

Full /etc/pulse/default.pa config file as example:

#!/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
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
load-module module-switch-on-connect

### 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
load-module module-dbus-protocol
.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 GSettings. 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-gsettings.so
.nofail
load-module module-gsettings
.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

### 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 alsa_output.pci-0000_05_00.0.hdmi-stereo-extra1
#set-default-source input
  • Save the file and use: pluseaudio -k

Adding load-module module-switch-on-connect line enabled my desired effect Switching back to HDMI-audio on wakeup, however it also seem to break my settings regarding the default-output sink; the second change fixed the breakage by explicitly setting default (I think this is what's going on LOL).

I hope this is useful to someone other than myself.

1 Like

Great! Glad you you got through it. Audio can be a pain sometimes.

Is everything working as it should? Does hot plugging bluetooth / speaker / mic etc. work correctly?

Save the file and use: pluseaudio -k

the askubuntu command has a typo and would not work
but not good to use -k or --kill on pulseaudio anyway

pulseaudio respawns without the systemd pulseaudio.service
and a couple of modules will not be reloaded:
module-x11-publish
module-x11-xsmp

not a big deal as a reboot will reset everything

to restart pulseaudio without altering state:
systemctl --user restart pulseaudio.service

Great question, which I didn't consider - I was too focused on fixing my issue to check for unobvious breakage. I haven't tested for all that yet.

I don't have anything Bluetooth, so apologies I can't test for adding/removing BT sources and seeing what happens. I'm presently in a virtual-machine, under my Unraid host, and I've found the virtual-machine has issues, unplugging then plug back in the USB passed through to VM -- it's due to the fact the devices are being passed-over to the virtual machine (rather than passing through a USB-controller to virtual-machine and then letting guest OS handle USB normally); and my motherboard sound-card has not been pushed into the VM (I tend to just push in the hardware I intend on using in the guest-OS).

I really like your question, as it's great information for community-level/generalize troubleshooting, so in the next few days I'll make another VM (pass through mobo sound-card and video), clean install of Manjaro, do some testing and update post with findings.

Thank you, all of this, to me, is great info! Honestly, I probably used the reboot system method more often than not as I really didn't know how to kick/reset pulseaudio properly.

That's ok. Just pop back with a new post if anything goes wrong. In the meantime, well done for finding the fix and letting us know. Keep on keeping on.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by