Ubuntu 18.04 LTS No Sound Fix

Introduction

I recently built a PC and it worked fine on Windows 10. However, when I switch to Ubuntu 18.04.1 LTS, I immediately found that there is no sound from my Bose speaker plugged into the line-out port on the motherboard, while there is sound if I plugged my headphone into the front panel of the computer. This is probably because the motherboard Gigabyte Aorus Master and its audio chip Realtek ALC1220 are relatively new compared to Ubuntu 18.04.1 LTS. While upgrading to Ubuntu 18.04.2 LTS might solve the problem, since Ubuntu 18.04.2 LTS uses the latest Kernel 4.18 while Ubuntu 18.04.1 LTS uses Kernel 4.15, I have to stick to Ubuntu 18.04.1 LTS because NVIDIA CUDA 10 has not officially supported Kernel 4.18 so far, and I could not use keyboard or mouse to login to the OS in Ubuntu GUI if I installed CUDA 10 (CUDA 10 + NVIDIA Driver 410.79) on Ubuntu 18.04.2 LTS.

Having no sound is extremely annoying and I decided to troubleshoot it. After trying almost all the suggested fix strategies found from Google, which took me about 24 hours, I finally figure out the perfect solution to this problem.

Suggested Solutions

Play With AlsaMixer and PulseAudio

AlsaMixer and PulseAudio, especially AlsaMixer, are the major workhorse to fix or troubleshoot sound problems. They have a lot of buttons to click, such as mute or unmute something, switch sound cards, adjusting volumes, etc. Sometimes they did bring back the sound temporarily. If playing with AlsaMixer and PulseAudio could not even bring back the sound temporarily, try to put the computer to sleep and wake it up. I know this sounds weird, but someone suggested it and it did work for me. However, in my case, after reboot or log out, the sound will be gone again. Someone suggested to save the AlsaMixer profile by playing with the sudo alsactl store and sudo alsactl restore. They worked temporarily, but after reboot the sound will still be gone. The sound was gone because the AlsaMixer settings you just set was gone. Plugging headphones into the front panel followed by removing it will also deactivate your AlsaMixer settings.

After playing with AlsaMixer and PulseAudio for a very very long time, I finally realize that all these weird phenomena shared something in common, that is the “headphone” in AlsaMixer will always be reset to “mm” (muted) and the volume is 0, after reboot or headphone plugging. I later found that amixer -q set Headphone 100 unmute could bring back the sound temporarily. But I have to do it manually every time after reboot or headphone plugging. It should be noted that setting this command as a system service might not help because you want your system to switch between front panel headphone and line-out speaker automatically. After reboot the sound might be back but headphone plugging might deactivate it again.

PulseAudio and AlsaMixer

AlsaMixer and PulseAudio Conflicts

Someone suggested that AlsaMixer and PulseAudio actually conflict with each other. But you cannot delete any of them since they are all required by Ubuntu, and they work closely to each other (At least PulseAudio relies on AlsaMixer).

PulseAudio “official” website suggested that “PulseAudio usually overwrites the ALSA settings”. I guess PulseAudio will be called to run after reboot and whenever a headphone is plugged in. Therefore, the AlsaMixer settings was erased, wiped, or replaced by the settings generated by PulseAudio.

They suggested to add the following code in .xinitrc or .bash_profile or any other autostart file to work around. In Ubuntu 18.04.1 LTS, I used .profile autostart file. But it did not work.

1
2
3
4
5
6
7
restore_alsa() {
while [ -z "$(pidof pulseaudio)" ]; do
sleep 0.5
done
alsactl -f /var/lib/alsa/asound.state restore
}
restore_alsa &

Someone suggested editing the /etc/pulse/default.pa by commenting out load-module module-device-restore. But it did not work either.

Successful Solution

I finally came up with a solution that was inspired by this thread. Basically, because PulseAudio had problems in recognizing the connected audio device, we have to manually let it know by editing the /usr/share/pulseaudio/alsa-mixer/paths/analog-output-lineout.conf file. By editing the file in a brute-force way, I found that changing the following settings

1
2
3
[Element Desktop Speaker]
switch = off
volume = off

to

1
2
3
[Element Desktop Speaker]
switch = on
volume = on

solved the problem. In addition to this, you would also need to set the AlsaMixer. But this time, the settings will not be removed after reboot. Headphone plugging will deactivate the Bose speaker and headphone unplugging will bring back the Bose speaker sound.

I guess this solution works because every time PulseAudio runs it uses this file to generate settings for analog-output-lineout profile which overwrites the settings we set in AlsaMixer. However, because this time we asked PulseAudio specifically that we have plugged the audio device into the computer and the volume must be on, the sound from the speaker will not be gone.

Remarks

I am very glad the sound is back and now I can work on Ubuntu happily, although troubleshooting all of these does not make sense to me.

Updates

2/26/2019

I found that if I reboot from Windows 10 and go into Ubuntu 18.04 LTS, there will be no sound at all. Shutting down the computer and boot to Ubuntu 18.04 LTS, or sleep and restart the no-sound Ubuntu 18.04 LTS solves this problem. Many people are reflecting similar issues, but the bug seems only to be fixed in a latest version of Kernel.

Author

Lei Mao

Posted on

02-24-2019

Updated on

02-24-2019

Licensed under


Comments