33

I just installed Ubuntu 20.04 on my laptop which is a bit outdated:

  • CPU: Intel Core i5 CPU M 480 @ 2.67GHz
  • RAM: 4GB
  • Video card: GeForce GT 420M
  • Audio: GF108 High Definition Audio Controller NVIDIA and Audio 5 Series/3400 Series Chipset High Definition Audio HD 500GB

Overall the system is working fine, but I'm having a big issue with HDMI Audio. The display on HDMI works just perfectly, but the audio is not working at all.

I tried lots of solutions here on Ask Ubuntu, but the problem remains. Some of the solutions I tried are located in the following links:

HDMI sound not working after upgrading to 20.04

Ubuntu 18.04: Audio doesn't work unless I switch between outputs

does not detect my sound card HDMI

Also I've downloaded Ubuntu 20.04 iso again and reinstalled the system, but it doesn't work.

HDMI worked perfectly when I used Windows 10 before replacing it with Ubuntu.

When I run aplay -l I have these results:

Playback hardware Devices

When I run lspci I have these results:

Devices

In the Settings -> Sound -> Output -> Output Device I have just two options to choose from:

  • Speakers-Built-in-Audio
  • Digital Output(S/PDIF)-Built-in-Audio

On Pulseaudio > Configuration it shows: GF108 High Definition Audio Controller and Built-in Audio

And in both of them all the options with HDMI are displayed with (unplugged)(unavailable).

Finally, the sound just works in my laptop, if I connect HDMI cable it display correctly but the sound keeps on my laptop.

1
  • I'm also having this issue. Is there a bug for this? Has anyone been able to verify if it's related to the bug mentioned below? p.s. your English is fine Sep 18, 2020 at 6:21

9 Answers 9

22

After upgrading from Ubuntu 18.04 to 20.04, I noticed that pulseaudio would no longer detect HDMI audio output (plugged to an nVidia graphics card) when turning my TV on after I logged in. HDMI output is just not listed anymore in sound settings. This used to work in 18.04.

I found a workaround was to open a console and type the following command, after turning the TV on:

pulseaudio -k
3
  • this works awesome on KDE but I have manually selected the output thank you!
    – Fathy
    May 8, 2022 at 5:15
  • For me on Ubuntu 22.10 this gives: E: [pulseaudio] main.c: Failed to kill daemon: No such process
    – user643722
    Apr 25, 2023 at 17:13
  • @user643722 same here.
    – Danon
    Nov 2, 2023 at 16:49
10

This is an old question, so maybe you have already solved your problem. But in case you have not or in case others are running into this issue and not finding solutions which work for them (as was the case with me recently), here is another thing one can try.

This is mostly taken from the suggestion here, but slightly expanded/modified. It seems PulseAudio has a bug which can cause it to fail to automatically detect hdmi audio outputs ("sinks" in its language), so you can fix things by manually telling it about your hdmi device.

Step 1: Make sure PulseAudio hasn't detected your hdmi sink

You can list all sinks loaded into PulseAudio with pactl list short sinks. This should produce a list of things of the form

0   alsa_output.pci-0000_06_00.6.HiFi__hw_Generic__sink module-alsa-card.c  s16le 2ch 48000HzIDLE

If your hdmi audio does not show up in your list, then we may have found the problem, so keep reading. If you are not sure if it does or not, you can also run pactl list sinks | grep description for more human-readable descriptions of the devices detected. I think hdmi sinks will have a description of the form "blah High Definition Audio Controller" while non-hdmi sinks might have a description like "blah blah blah Speaker + Headphone".

Step 2: Make sure your computer can output audio to hdmi

Run aplay -l to get a list of hardware playback devices. For me, the output looks like

**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 11: HDMI 5 [HDMI 5]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 0: ALC245 Analog [ALC245 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

In particular, there are many sorts of hdmi devices available. We want to find the one that actually corresponds to the hdmi port you have a cable plugged in to.

The first thing to do is to run alsamixer to make sure your hdmi device isn't muted. You should see a screen like the one below.

enter image description here

Use F6 to select the correct sound card. If you see MM in any of the slots, that means it's muted. Select it and press M to unmute. Hit Esc when you're done.

Really, you probably should only need to unmute one of these slots (the one actually associated with your hdmi port which is probably the first one), but it doesn't hurt to unmute them all.

With that taken care of, we can now test your audio. Run

speaker-test --channels 2 --test wav --device hw:[card],[device]

where [card],[device] refers to the numbers from the output of aplay -l, e.g. I'd first use hw:0,3. You'll do this for every hdmi hardware device listed previously until one of them actually produces an audible sound.

Step 3: Add HDMI sink to PulseAudio and make sure it works (can skip if you want)

Now that you have identified and card and device number associated to your hdmi port, simply run

pactl load-module module-alsa-sink device=hw:[card],[device]

You should now be able to go to your sound settings and see a new selectable output device (Mine's called TU116 High Definition Audio Controller). Select it and see if your hdmi audio works now. If not, I can't help you. But if it does, congrats.

Step 4: Make this change (almost) permanent

At the moment, if you restart your computer, you'd have to rerun this load_module command in order for hdmi to work again. To make things a little better, edit `/etc/pulse/default.pa' (as root), and near the end of the file, add the line

load-module module-alsa-sink device=hw:[card],[device]

After this (especially if you skipped step 3), you might want to run

rm -r ~/.config/pulse
killall pulseaudio
pulseaudio --start

to restart PulseAudio.

Lastly, a few hiccups/remarks

  • For me, even after doing this, I still need to run killall pulseaudio; pulseaudio --start after rebooting my computer in order for PulseAudio to load in the hdmi sink. I don't know how to fix this.
  • For me, the hdmi device is still listed as an option in Ubuntu's sound settings even when my cable isn't plugged in. I don't know how to fix this.
  • The link from the beginning of this answer mentions a script for automatically switching to hdmi audio when a cable is plugged in. I don't know enough about linux to follow what's going on in that script, so I haven't tried this myself.

Edit: A Bash Script that Carries out this Answer

In response to the last bullet point above, I recently wrote a bash script that will automatically carry out the steps described here. You can find it on github. Compared to the script in the referenced link, the one I wrote (tries to) make fewer assumptions about the machine it is being run on; in particular, it does not assume PulseAudio has already (manually) been configured to detect your hdmi cable. If this has not happened, it runs the process described above, and then switches your audio to hdmi.

This script can be configured to run whenever your hdmi cable is plugged in or out by using udev. To do this, in the folder /etc/udev/rules.d, add a file with the following line

KERNEL=="card*", SUBSYSTEM=="drm", ACTION=="change", RUN+="[path-to-script]"

(on my machine, I saved the script in /usr/local/bin/hdmi.sh). After creating this file, run udevadm control --reload-rules. Once you've done this, you should just be able to plug in an hdmi cable and have things work. When you unplug the cable, audio should switch back to your computer.

New hiccups/remarks

  • You may need to restart your computer once after adding this udev rule for the first time before the change can take effect.
  • If the udev rule is being iffy, you can always manually run the script. This is a bit more reliable if a bit more effort.
  • For me, if I plug and unplug my hdmi cable like 5 times in a row without restarting, then the audio becomes extremely distorted. I have no idea what causes this.
  • The script really is just carrying out the above process. In particular, at some point is runs speaker-test to figure out which card/device to load in PulseAudio. Thus, when run, you'll likely hear an audible "Left/Right" (or whatever sound speaker-test defaults to).
  • In the script, there's a ENABLE_DESKTOP_NOTIFICATIONS variable. Set this to 1 if you want notifications whenever it runs.
2
  • Thanks @Niven! this load-module command worked for me!
    – fccoelho
    Sep 5, 2022 at 18:45
  • Im using a NVIDIA card as my sole audio output, I set the default sink with pactl set-default-sink alsa_output.hw_0_3
    – fedemengo
    May 28, 2023 at 8:11
9

I am using Mint 20.1 with Xfce, and this solved it for me:

  • Open the audio mixer (it's called pavucontrol here)
  • Switch to the Configuration tab (rightmost tab),
  • There is a dropdown for selecting the profile for the builtin audio device.
  • Here I could select a HDMI profile, just be careful to pick one that is not marked as not available.
  • After that, audio through HDMI worked just fine.

I realize this is not quite Ubuntu, but close enough that I thought something like this should be possible on Ubuntu also.

3
  • I am testing this and will report back on my results using Ubuntu 18.04
    – Jack
    Apr 2, 2021 at 13:14
  • Ok, this helps, yet doesn't completely solve the issue for me. If my machine goes to sleep, it still forgets about HDMI output. Once I open pavucontrol, HDMI is back.
    – Jack
    Apr 2, 2021 at 23:50
  • pavucontrol saved me. I found the volume was not muted, but very low. Jun 8, 2021 at 16:55
6

I see at least three possible reasons:

  1. your sound devices may be muted by default - run alsamixer and make sure all sound devices are unmuted. I assume you've done that since it's mentioned in one of the links you posted.
  2. You may have to set a default 'sink' for sound output. Here is one post that helped me in the past with Xfce. One thing you can try is play sound to designated output eg aplay -D plughw:0,1 /usr/share/sounds/alsa/Noise.wav - try all possible combinations based on the output of aplay -l eg 1,3 or 1,7 etc
  3. Linux kernel issue. On a recent installation of Arch Linux I found out that HDMI audio was not working due to a regression in the Linux kernel. The bug is documented here: Bug 207223 - linux-5.6.x breaks NVidia HDMI audio. The fix was either to revert to a kernel <= 5.6 (version 2020-04-01), or use an LTS Kernel (which I did) and that solved the issue for me. Check the output of uname -r to verify your kernel version.

Additional steps you can do:

  • You mentioned using a laptop, so I take that it that disabling the onboard sound card on your motherboard is not an option for you (presumably you will not always be using an external HDMI display). This may not solve your issue but would remove one unnecessary device on a desktop PC (it could be the default device at present).
  • Something else: since you have an NVIDIA device you can choose between the proprietary driver from Nvidia or the open-source version (nouveau) and there is also Optimus, that I am not familiar with. Verify which one you are using. If all attempts fail you could try the other driver. But from experience nouveau should be perfectly capable unless maybe you have very recent hardware that is not yet Linux-supported.

I also recommend the Arch Linux wiki: Advanced Linux Sound Architecture. It helped me a lot debug my sound issues back in the day.

3
  • Anonymous, thanks for you attention I tried all of your steps one by one, but it still didn't work. I'll try to reinstall the system again but if it does not work, I'll look for other solution, maybe choosing another system or keep using it without the sound on HDMI.
    – Lucas
    Jul 3, 2020 at 22:24
  • I found the correct card,device that plays sound, now how do I make that my default sound output? I cannot select it in options.
    – xinthose
    Sep 26, 2021 at 19:55
  • I don't have enough reputation to comment, but I just wanted to add that Kate's answer is still relevant, worked on Ubuntu 22.04 / GNOME / X11. The latest kernel as of 2023-03-04 (5.19.0-35-generic) appears to have a similar bug, and running with the previous available kernel version (5.19.0-32-generic) restored the HDMI audio output. Mar 4, 2023 at 15:07
1

This is resolved by the app, pavucontrol 5.0, which enables users to choose and lock the output device. Unfortunately, the app is distro specfic, so Ubunutu users must wait for Canonical to add the app to the repositories.

0

This help me sudo alsa force-reload

I think, it is something on the pavucontrol config wrong.

0

It probably depends on HDMI device (had exactly the same problem with 2 laptops, the previous solutions didn't work). What worked to me:

  • disable laptop's built-in sound in the pulse audio control screen
  • somehow, monitor's sound gets enabled automatically

OS: Ubuntu 22 HDMI device: Samsung Smart monitor with speakers

-1

If pulseaudio shows sounds are outputting but there is still no audio, updating the Kernel to the latest version will install the latest drivers.

This worked for me.

-1

Just do upgrade to latest kernel:

sudo apt-get update

sudo apt-get dist-upgrade

and then go to Settings/Sound and chose the HDMI option which was probably missing due to some regression

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .