Whenever I resume my Ubuntu 17.04 from sleep the HDMI audio output is disabled, and audio has defaulted to the SP-DIF output. I always have to run pavucontrol or go into sound settings to re-select HDMI as the audio output. As this is a Home Theatre PC running Kodi this is a pain in the neck, as it can't be done using the IR remote. Is there any way that I can resolve this, either by disabling the SP-DIF output altogether or automatically selecting the HDMI audio device whenever resuming from sleep?
There is a complicated way of accomplishing this with
systemd service and suspend/resume hooks.
An easier way is to check this:
$ cat /etc/pulse/default.pa | grep switch-on-port-available load-module module-switch-on-port-available
If the second line doesn't begin with a
# (commented out) then edit the file and insert a
# in the beginning.
Now all output will be controlled to what you manually set it to and stay there until you change it.