Random audio source switching in Plasma

When I am on a VOIP call, using Zoom, or listening to music through Clementine or Spotify, the audio source will randomly change from my speakers to the USB headset, or to HDMI audio output for about 5 seconds and then it switches back to the defined sound source. And it will randomly change from the USB headset to the speakers or HDMI sound source so it's happening in both directions. It happens about every ten minutes or so.

I have also disabled HDMI audio output in System Settings > Audio > Advanced by setting it to "off" but it will randomly turn on again as a sound source even after turning it off.

This is something I've had issues with for the last few years on two different computers with kernels 4.19, 5.2, and now 5.4 so I don't think the kernel version is the issue.

This computer has an AMD graphics card but the other computer with the same issue has an NVIDIA card so I don't think it's the graphics cards either.

I searched the forums and everywhere I could online and this issue can't be found to my knowledge with random audio source switching in Plasma.

This is happening with different motherboard manufacturers, MSI on this computer and Gigabyte on the other both with Ryzen processors but different video cards.

Any help appreciated.

Below is inxi -Fx with all three sound sources activated.

System:    Host: 3600 Kernel: 5.4.36-1-MANJARO x86_64 bits: 64 compiler: gcc v: 9.3.0 Desktop: KDE Plasma 5.18.4 
           Distro: Manjaro Linux 
Machine:   Type: Desktop System: Micro-Star product: MS-7C02 v: 1.0 serial: <root required> 
           Mobo: Micro-Star model: B450 TOMAHAWK (MS-7C02) v: 1.0 serial: <root required> UEFI: American Megatrends v: 1.D0 
           date: 11/07/2019 
Battery:   Device-1: hidpp_battery_0 model: Logitech Wireless Keyboard K360 charge: 100% (should be ignored) 
           status: Discharging 
CPU:       Topology: 6-Core model: AMD Ryzen 5 3600 bits: 64 type: MT MCP arch: Zen L2 cache: 3072 KiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 86425 
           Speed: 3592 MHz min/max: 2200/3600 MHz Core speeds (MHz): 1: 3144 2: 1963 3: 2066 4: 2072 5: 1956 6: 3716 7: 2063 
           8: 2070 9: 2951 10: 2104 11: 1956 12: 3702 
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] vendor: Gigabyte 
           driver: amdgpu v: kernel bus ID: 26:00.0 
           Display: x11 server: X.Org 1.20.8 driver: amdgpu FAILED: ati unloaded: modesetting resolution: 1920x1200~60Hz 
           OpenGL: renderer: Radeon RX 570 Series (POLARIS10 DRM 3.35.0 5.4.36-1-MANJARO LLVM 10.0.0) v: 4.6 Mesa 20.0.6 
           direct render: Yes 
Audio:     Device-1: AMD Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] vendor: Gigabyte driver: snd_hda_intel 
           v: kernel bus ID: 26:00.1 
           Device-2: Advanced Micro Devices [AMD] Starship/Matisse HD Audio vendor: Micro-Star MSI driver: snd_hda_intel 
           v: kernel bus ID: 28:00.4 
           Device-3: Logitech Headset H390 type: USB driver: hid-generic,snd-usb-audio,usbhid bus ID: 1-2.4.1:9 
           Sound Server: ALSA v: k5.4.36-1-MANJARO 
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: Micro-Star MSI driver: r8169 v: kernel 
           port: f000 bus ID: 22:00.0 
           IF: enp34s0 state: up speed: 1000 Mbps duplex: full mac: 00:d8:61:fd:4f:15 
           IF-ID-1: tun0 state: unknown speed: 10 Mbps duplex: full mac: N/A 
Drives:    Local Storage: total: 931.51 GiB used: 117.13 GiB (12.6%) 
           ID-1: /dev/nvme0n1 model: Sabrent Rocket Q size: 931.51 GiB 
Partition: ID-1: / size: 898.63 GiB used: 109.59 GiB (12.2%) fs: ext4 dev: /dev/nvme0n1p2 
           ID-2: swap-1 size: 17.21 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/nvme0n1p3 
Sensors:   System Temperatures: cpu: 49.1 C mobo: N/A gpu: amdgpu temp: 30 C 
           Fan Speeds (RPM): N/A gpu: amdgpu fan: 819 
Info:      Processes: 298 Uptime: 3h 28m Memory: 15.65 GiB used: 3.23 GiB (20.6%) Init: systemd Compilers: gcc: 9.3.0 
           Shell: bash v: 5.0.16 inxi: 3.0.37 

Did you:

  • Disable Automatically switch all running streams when a new output becomes available in the advanced audio system settings?
  • Choose the right output in your application itself? (E.G. Zoom, please provide screenshot of Zoom audio settings )

:sob:

2 Likes

I have not checked that box to "automatically switch all running streams when a new output becomes available." I guess I was confused as to what that really means? I will give that a try and test it.

Part of my question was the fact that if I turn the HDMI profile to "off", it will randomly turn itself back on without me making any changes to the audio. That seems like a bug but I could be wrong.

I definitely select the specific audio profiles in Zoom that I want when I use it. Sometimes I do have the system default set differently to what I have set in Zoom so perhaps that's a problem. I can try setting the system default audio device and also selecting that in Zoom, so they are the same.

Good! Keep it that way!

Where exactly?

:stuck_out_tongue_winking_eye:

Great, I'll leave it unchecked.

See attached screenshot where I turn off HDMI. This randomly turns back on even when set to off.

See Zoom screenshot with my USB headset chosen.


Do you mean "random" = "when you plug in HDMI"?

:innocent:

When I say "random" I mean it just happens without me doing anything. I may leave my computer for an hour and when I come back it has turned back on. There is no application change, setting change, peripheral change etc., nothing that can cause it to turn back on.

The second issue happens when I do have it turned on but the audio source randomly changes from my USB headset to the HDMI audio source for about 5 seconds and then it switches back to the headset. It happens about every 10-15 minutes or so while I'm using Zoom, Zoiper, Spotify etc.

other KDE users have reported similar problem - changing audio settings using DE controls does not appear to be saved to home folder configuration
user settings are stored in 4 databses files (.tdb) in ~/.config/pulse/

suggest install pavucontrol-qt(qt version of Pulseaudio Volume Control mixer package)
that will save a settings change like turning off HDMI

sometimes just opening pavucontrol and clicking on something causes audio to start working normally

2 Likes

Ok, it's good to know others have had thi sissue and thank you for the suggestion. I've attached a screenshot of what comes up for me when I search for pavucontrol in the package manager. Do you know which one I should try? The pavucontrol-qt-git hasn't been updated since 2017. Thanks

pamac search pavucontrol
shows the 2 at top and bottom of your screenshot in Manjaro repositories

pavucontrol                                      1:4.0-1              extra 
  PulseAudio Volume Control

pavucontrol-qt                                   0.15.0-1             community 
  A Pulseaudio mixer in Qt (port of pavucontrol)

either of these will work, but pavucontrol is based on GTK and will want to install extra packages

QT version is a better match for KDE - that is the one at bottom of screenshot - v0.15.0-1

1 Like

Ok, thanks. I've installed it and will give it a try. It looks like it has a full suite of configuration options.

Unfortunately this didn't work. I deactivated the HDMI audio source in pavucontrol and rebooted my system and it was turned back on. I then deactivated HDMI audio and it randomly turned back on after about an hour so the behavior hasn't changed.

I haven't tested Zoom etc. yet but one of the issues still persists. :slightly_frowning_face:

I deactivated the HDMI audio source in pavucontrol and rebooted my system and it was turned back on.

Pulseaudio should respect user changes made in pavucontrol

suggest clear Pulseaudio databases of any old user preferences

  • tdbtool ~/.config/pulse/*stream-volumes.tdb erase
  • tdbtool ~/.config/pulse/*device-volumes.tdb erase
  • tdbtool ~/.config/pulse/*card-database.tdb erase
  • tdbtool ~/.config/pulse/*device-manager.tdb erase

the reboot system

if that does not resolve problem, please post pulseaudio information

systemctl --user status pulseaudio.service

pacmd dump

1 Like

I did the tdbtool commands and rebooted and the HDMI audio continued to remain off which is a good sign. However, when I turned on the second monitor connected to this HDMI cable, the audio source turned back on. If I'm not mistaken, that shouldn't happen if I have an audio source set to off but I could be wrong.

I haven't had the opportunity to test Zoom, Zoiper etc. but I will this week.

systemctl --user status pulseaudio.service
● pulseaudio.service - Sound Service
     Loaded: loaded (/usr/lib/systemd/user/pulseaudio.service; disabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-05-11 14:32:39 EDT; 3min 19s ago
TriggeredBy: ● pulseaudio.socket
   Main PID: 1772 (pulseaudio)
     CGroup: /user.slice/user-1000.slice/user@1000.service/pulseaudio.service
             ├─1772 /usr/bin/pulseaudio --daemonize=no
             └─2243 /usr/lib/pulse/gsettings-helper

May 11 14:32:38 3600 systemd[1597]: Starting Sound Service...
May 11 14:32:39 3600 systemd[1597]: Started Sound Service.
May 11 14:33:03 3600 pulseaudio[1772]: E: [pulseaudio] bluez5-util.c: GetManagedObjects() failed: org.freedesktop.DBus.Error.TimedOut: Failed to activate service 'org.bluez': timed out (s>
lines 1-12/12 (END)

pacmd dump
### Configuration dump generated at Mon May 11 14:36:52 2020

load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore
load-module module-augment-properties
load-module module-switch-on-port-available
load-module module-udev-detect
load-module module-alsa-card device_id="2" name="usb-Logitech_Logitech_USB_Headset-00" card_name="alsa_card.usb-Logitech_Logitech_USB_Headset-00" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes avoid_resampling=no card_properties="module-udev-detect.discovered=1"
load-module module-alsa-card device_id="0" name="pci-0000_26_00.1" card_name="alsa_card.pci-0000_26_00.1" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes avoid_resampling=no card_properties="module-udev-detect.discovered=1"
load-module module-alsa-card device_id="1" name="pci-0000_28_00.4" card_name="alsa_card.pci-0000_28_00.4" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes avoid_resampling=no card_properties="module-udev-detect.discovered=1"
load-module module-jackdbus-detect channels=2
load-module module-bluetooth-policy
load-module module-bluetooth-discover
load-module module-bluez5-discover
load-module module-dbus-protocol
load-module module-native-protocol-unix
load-module module-gsettings
load-module module-default-device-restore
load-module module-rescue-streams
load-module module-always-sink
load-module module-intended-roles
load-module module-suspend-on-idle
load-module module-console-kit
load-module module-systemd-login
load-module module-position-event-sounds
load-module module-role-cork
load-module module-filter-heuristics
load-module module-filter-apply
load-module module-x11-publish display=:0
load-module module-x11-xsmp display=:0 session_manager=local/3600:@/tmp/.ICE-unix/1704,unix/3600:/tmp/.ICE-unix/1704
load-module module-cli-protocol-unix

set-sink-volume alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo 0x76d3
set-sink-mute alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo no
suspend-sink alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo yes
set-sink-volume alsa_output.pci-0000_28_00.4.analog-stereo 0x2b84
set-sink-mute alsa_output.pci-0000_28_00.4.analog-stereo no
suspend-sink alsa_output.pci-0000_28_00.4.analog-stereo yes

set-source-volume alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo.monitor 0x10000
set-source-mute alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo.monitor no
suspend-source alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo.monitor yes
set-source-volume alsa_input.usb-Logitech_Logitech_USB_Headset-00.mono-fallback 0x10000
set-source-mute alsa_input.usb-Logitech_Logitech_USB_Headset-00.mono-fallback no
suspend-source alsa_input.usb-Logitech_Logitech_USB_Headset-00.mono-fallback yes
set-source-volume alsa_output.pci-0000_28_00.4.analog-stereo.monitor 0x10000
set-source-mute alsa_output.pci-0000_28_00.4.analog-stereo.monitor no
suspend-source alsa_output.pci-0000_28_00.4.analog-stereo.monitor yes

set-card-profile alsa_card.usb-Logitech_Logitech_USB_Headset-00 output:analog-stereo+input:mono-fallback
set-card-profile alsa_card.pci-0000_26_00.1 off
set-card-profile alsa_card.pci-0000_28_00.4 output:analog-stereo

set-default-sink alsa_output.pci-0000_28_00.4.analog-stereo
set-default-source alsa_input.usb-Logitech_Logitech_USB_Headset-00.mono-fallback

### EOF

It happened again. The HDMI audio source randomly turned on even without me turning on the audio source. It looks like this pavucontrol solution isn't working. Any other recommendations?

i thought unchecking the tick-box in KDE Audio Settings as suggested by @Fabby was the right idea
which i believe would have disabled the Pulseaudio module most to be causing problems
module-switch-on-port-available

even though the box is not checked, the module is still present in Pulseaudio

try this command to unload the module temporarily and check if audio switching stops

pacmd unload-module module-switch-on-port-available

if issue is not resolved, reboot system to get the module back again

2 Likes

The above pacmd command seems to have worked. The audio source did not activate even when I turned it on. I rebooted and the command did not hold however which I believe isn't supposed to?

Since that command worked, is there a solution moving forward that wouldn't require me to issue this command every time I turn on my computer?

Depending on how many users use your computer, you can:

  • convert that command it into a SystemD service (=all users)
  • Add that command to your KDE autostart (=1 user, happens after you login).

That's interesting about adding it to KDE autostart. I am the only user so just 1. How would I add it to autostart? I see I can select a program or choose script.

This way:

sudo nano --backup /usr/local/bin/puff_NoRandomAudioSwitching

Copy-paste:

#!/bin/bash
pacmd unload-module module-switch-on-port-available

Ctrl+X Y Enter to save

Execute:

sudo chmod a+rwx  /usr/local/bin/puff_NoRandomAudioSwitching

to allow all to read, write and execute said script.

Add /usr/local/bin/puff_NoRandomAudioSwitching to autostart.

:innocent:

P.S. Just in case you would be mistaken that the above is the solution, it's not!, therefore I've marked this one as the solution as the above is just the execution of the intelligence in that answer... :stuck_out_tongue_winking_eye: :crazy_face:

2 Likes

Forum kindly sponsored by