
Prevent automatic change of audio device – Ubuntu
If you are using HDMI or DisplayPort for audio, the devices regularly seem to switch back to in-built audio all by themselves.
This can be due to the HDMI device becoming unavailable when the monitor turns itself off, causing PulseAudio to choose a different device. This causes a problem as PulseAudio does not automatically go back to the originally selected device once the HDMI device has returned.
This is very frustrating as it means constantly having to re-selected the prefered device.
To resolve this problem it is possible to disable automative port switching.
To do this follow the instructions below:
Edit the following file:
vi /etc/pulse/default.pa
Find and comment out the following line:
load-module module-switch-on-port-available
Now restart PulseAudio
pulseaudio -k
This fix was applied on Pop_OS! however, should work with a variety of distros.
Source
https://askubuntu.com/questions/158241/automatically-change-sound-input-output-device
https://askubuntu.com/questions/228619/disable-sound-through-hdmi-permanently