HDMI Sound Output and Video Issues

With 18.04 I can get video and sound. However, I need to manually change the sound settings. There seems to be no default for when HDMI is inserted. Is this normal for HDMI. It would be great if sound automatically went to HDMI when HDMI is inserted?

Also, I have only tried on one TV so far, but I do occasionally get a scrolling line from bottom to top on the videos that does not exist on the laptop screen. Is this a hardware or software incompatibility. Any suggestions to troubleshoot?

When you open System -> Preferences -> Hardware -> Sound there you should be able to select the audio hardware under hardware.

Mickey :relaxed:

I know how to manually change the audio settings. My point was, when I plug in the HDMI, sound does not automatically go to HDMI. And once configured to HDMI, when I unplug HDMI, the sound does not go to the PC. Is this normal?

Need to set HDMI as default device in Pulseaudio
Not fallback as seen in gui controls
Audio streams will try to connect to HDMI first, but use other device if HDMI not available

use command
pactl list sinks | grep Name:
to find name for HDMI audio device in Pulseaudio

use this name with command to set HDMI as default playback device
pacmd set-default-sink <name>

To check if default set to correct name
cat ~/.config/pulse/*default-sink

Any audio stream started after HDMI connected will use default
An audio stream playing on another device when HDMI plugged in will need to be manually redirected to HDMI in pavuucontrol -t 1 playback settings.
changes for each audio stream type are saved and usually only need setting once

So I first changed my default to HDMI via the Sound Settings GUI, rebooted and tried playing something on the PC. No audio. I checked and the default remained HDMI. Before I attempt the changes via command line, I want to ensure I can return to my current settings in case something goes wrong.

With PC speakers default set by GUI:

$ pactl list sinks | grep Name: 
	Name: alsa_output.pci-0000_00_1f.3.analog-stereo

$ cat ~/.config/pulse/*default-sink
auto_null

With HDMI audio default set by GUI:

pactl list sinks | grep Name: 
	Name: alsa_output.pci-0000_00_1f.3.hdmi-stereo

$ cat ~/.config/pulse/*default-sink
auto_null

Based on the above output, my understanding is I would enter

pacmd set-default-sink alsa_output.pci-0000_00_1f.3.hdmi-stereo

to set HDMI as default

And to return to PC speakers as default I would enter

pacmd set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo

Does this seem correct?

I assumed wrong that Analog audio and HDMI would be a different audio devices rather than sub-device on same device

Try this to add new Pulseaudio module temporarily
pactl load-module module-switch-on-connect
that should handle automatic switching to HDMI and back

If it doesn’t work right for your needs, reloading Pulseaudio will remove it
can use command pulseaudio -k && pulseaudio --start
but log out or restart pc will also reload Pulseaudio

if you are happy with how that works, it can be added to Pulseaudio permanently
sudo nano /etc/pulse/default.pa
must use sudo to save changes, but can change nano for name of another text editor if preferred
Add this line to end of file
load-module module-switch-on-connect
Save changes and close text editor
reload Pulsaudio (see earlier)

There is another way to do this by changing card profile in Pulseaudio,
but is more complicated setting up udev rule to do it automatically

I tried but no joy.

$ pactl load-module module-switch-on-connect
Failure: Module initialization failed
$

pulseaudio --dump-modules will confirm all available modules

pactl list short modules will list all loaded modules

not clear if that module is not available,
or already loaded and not capable of switching profile on single device

$ pulseaudio --dump-modules 
module-allow-passthrough                When a passthrough stream is requested, route all the other streams to a dummy device
module-alsa-card                        ALSA Card
module-alsa-sink                        ALSA Sink
module-alsa-source                      ALSA Source
module-always-sink                      Always keeps at least one sink loaded even if it's a null one
module-augment-properties               Augment the property sets of streams with additional static information
module-bluetooth-discover               Detect available Bluetooth daemon and load the corresponding discovery module
module-bluetooth-policy                 Policy module to make using bluetooth devices out-of-the-box easier
module-bluez5-device                    BlueZ 5 Bluetooth audio sink and source
module-bluez5-discover                  Detect available BlueZ 5 Bluetooth audio devices and load BlueZ 5 Bluetooth audio drivers
module-card-restore                     Automatically restore profile of cards
module-cli                              Command line interface
module-cli-protocol-tcp                 Command line interface protocol (TCP sockets)
module-cli-protocol-unix                Command line interface protocol (UNIX sockets)
module-combine                          Compatibility module (module-combine rename)
module-combine-sink                     Combine multiple sinks to one
module-console-kit                      Create a client for each ConsoleKit session of this user
module-dbus-protocol                    D-Bus interface
module-default-device-restore           Automatically restore the default sink and source
module-detect                           Detect available audio hardware and load matching drivers
module-device-manager                   Keep track of devices (and their descriptions) both past and present and prioritise by role
module-device-restore                   Automatically restore the volume/mute state of devices
module-echo-cancel                      Echo Cancellation
module-esound-sink                      ESOUND Sink
module-filter-apply                     Load filter sinks automatically when needed
module-filter-heuristics                Detect when various filters are desirable
module-http-protocol-tcp                HTTP (TCP sockets)
module-http-protocol-unix               HTTP (UNIX sockets)
module-intended-roles                   Automatically set device of streams based on intended roles of devices
module-ladspa-sink                      Virtual LADSPA sink
module-loopback                         Loopback from source to sink
module-match                            Playback stream expression matching module
module-mmkbd-evdev                      Multimedia keyboard support via Linux evdev
module-native-protocol-fd               Native protocol autospawn helper
module-native-protocol-tcp              Native protocol (TCP sockets)
module-native-protocol-unix             Native protocol (UNIX sockets)
module-null-sink                        Clocked NULL sink
module-null-source                      Clocked NULL source
module-oss                              OSS Sink/Source
module-pipe-sink                        UNIX pipe sink
module-pipe-source                      UNIX pipe source
module-position-event-sounds            Position event sounds between L and R depending on the position on screen of the widget triggering them.
module-remap-sink                       Virtual channel remapping sink
module-remap-source                     Virtual channel remapping source
module-rescue-streams                   When a sink/source is removed, try to move its streams to the default sink/source
module-role-cork                        Mute & cork streams with certain roles while others exist
module-role-ducking                     Apply a ducking effect based on streams roles
module-rtp-recv                         Receive data from a network via RTP/SAP/SDP
module-rtp-send                         Read data from source and send it to the network via RTP/SAP/SDP
module-rygel-media-server               UPnP MediaServer Plugin for Rygel
module-simple-protocol-tcp              Simple protocol (TCP sockets)
module-simple-protocol-unix             Simple protocol (UNIX sockets)
module-sine                             Sine wave generator
module-sine-source                      Sine wave generator source
module-snappy-policy                    Ubuntu Snappy policy management
module-stream-restore                   Automatically restore the volume/mute/device state of streams
module-suspend-on-idle                  When a sink/source is idle for too long, suspend it
module-switch-on-connect                When a sink/source is added, switch to it or conditionally switch to it
module-switch-on-port-available         n/a
module-systemd-login                    Create a client for each login session of this user
module-tunnel-sink                      Tunnel module for sinks
module-tunnel-sink-new                  Create a network sink which connects via a stream to a remote PulseAudio server
module-tunnel-source                    Tunnel module for sources
module-tunnel-source-new                Create a network source which connects via a stream to a remote PulseAudio server
module-udev-detect                      Detect available audio hardware and load matching drivers
module-virtual-sink                     Virtual sink
module-virtual-source                   Virtual source
module-virtual-surround-sink            Virtual surround sink
module-volume-restore                   Compatibility module
module-x11-bell                         X11 bell interceptor
module-x11-cork-request                 Synthesize X11 media key events when cork/uncork is requested
module-x11-publish                      X11 credential publisher
module-x11-xsmp                         X11 session management

$

$ pactl list short modules 
0	module-device-restore		
1	module-stream-restore		
2	module-card-restore		
3	module-augment-properties		
4	module-switch-on-port-available		
5	module-switch-on-connect		
6	module-udev-detect		
7	module-alsa-card	device_id="0" name="pci-0000_00_1f.3" card_name="alsa_card.pci-0000_00_1f.3" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1"	
8	module-bluetooth-policy		
9	module-bluetooth-discover		
10	module-bluez5-discover		
11	module-native-protocol-unix		
12	module-default-device-restore		
13	module-rescue-streams		
14	module-always-sink		
15	module-intended-roles		
16	module-suspend-on-idle		
17	module-console-kit		
18	module-systemd-login		
19	module-position-event-sounds		
20	module-role-cork		
21	module-filter-heuristics		
22	module-filter-apply		
23	module-x11-publish	display=:0	
24	module-x11-bell	display=:0 sample=bell.ogg	
25	module-x11-cork-request	display=:0	
26	module-x11-xsmp	display=:0 session_manager=local/name:@/tmp/.ICE-unix/1254,unix/name:/tmp/.ICE-unix/1254	
$