Ubuntu – Ubuntu 16.04 No Sound from Speakers, only headphones working

alsapulseaudiosound

I am at my wit's end with this problem. I know I have seen this problem a million times, but none of the solutions seem to work.

I have an ASUS laptop dual booted with Windows 8.1, I upgraded from 15.10 to 16.04 and lost use of the speakers; the soundcard perpetually thinks the headphones are plugged in, as evidenced by these screenshots.

alsamixer

pavucontrol

This is not a hardware issue because
1) the sound works on Windows 8.1
2) I can get the speakers to work by disabling the headphone jack using hdajackretask (setting override and then setting it at "Not Connected") but then cannot use the hotkeys to change the volume

I have tried reloading alsa and also purging alsa and reinstalling.

I am planning to actually delete my Windows 8 partition anyway. I saw here:
No sound from laptop speakers in Ubuntu 14.04 after booting into Windows 8.1
that Windows might be causing the problem. Will deleting the partition help the problem?

Edit: I have already disabled Hybrid Boot as suggested in that question.

Best Answer

I also had this problem when upgrading my Xubuntu 14.04 to Xubuntu 16.04 (headphones produced sound, but not the speakers). I have an HD Intel sound card with a Realtek ALC259 chip. The problem persisted when booting with various kernels from 3.13.X to 4.10.X.

However, I GOT IT FIXED, and here's how:

It's important to understand that Pulseaudio(PA) is the default sound control system for Ubuntu and most (all?) of it's variants. PA is essentially and overlay on top of the core ALSA sound system. So, for every action made in PA, there is a subsequent reaction within ALSA. For each output (aka port) defined within PA, there is a defined adjustment to the ALSA system. This adjustment is known as the "mixing path".

!!! IMPORTANT !!!

Before you continue, now is a good time to verify that this is actually your problem and there isn't some other reason why your speakers are not working. You can do so very easily by doing the following test. (If you've been fiddling with your sound system, you might want to get it back to its defaults before testing):

  1. Unplug any headphones or other sound devices EXCEPT the speakers that are NOT working.
  2. Start playing an audio file that would normally generate sound from your speakers, although isn't currently. Then,
  3. Open up your terminal and run the command:

    alsamixer
    

You should see the following:

alsamixer Due to differences between sound cards, your devices my be a little different from those in the image. In my case, and before fixing the problem, my alsamixer looked just like the image above.

  1. Unmute any devices that are currently muted (use 'm' key to toggle mute). Then raise the volume sliders up on any devices that are not at 100%.

If you can hear sound from your speakers, this fix is for you!

If you do not hear any sound, go back to "The Google" and keep searching. This will method will NOT help you.


If you successfully got sound from the above the test, what we need to do now is play with the alsamixer settings in order to determine:

  1. Which device's volume control actually controls the volume of your speakers, and
  2. Which of the devices need to be unmuted for the speakers to work. Multiple devices may need to be unmuted.

Once we know the ALSA settings by which the speakers will work, we can use this information to make the necessary changes to our PA mixer paths.

In my case, I discovered that my headphones and speakers are linked within ALSA in the following ways:

  1. My Headphone Volume is controled by the "Headphone" device.
  2. Getting sound from my headphones requires that the "Master" and "Headphone" devices be unmuted.
  3. My Speaker Volume is ALSO controlled by the "Headphone" device. (The ALSA speaker volume setting suprisingly has no effect on my speaker's volume.)
  4. Getting sound from my speakers requires that the "Master" and "Speaker" devices be unmuted.

The speaker's default mixer path within PulseAudio(PA) assumed that my speakers were independant of my headphones. Which, as demonstrated above by observation 3, was not the case. Subsequently, the default mixer path within PA for my speakers made the following problematic changes within ALSA whenever the speaker output was selected within PA:

  1. Dropped the headphone volume to 0.
  2. Set the speaker device as the volume control.

Given how I had observed ALSA's linkage of my speakers and headphones as described earlier, these changes to ALSA would prevent sound from coming out of my speakers.

So, the solution to this problem is obtained by modifying the speaker's mixer path.

The PA mixer path files are located in:

/usr/share/pulseaudio/alsa-mixer/paths/

To determine which mixer path file controls your speakers, you need to:

  1. Make sure that your speaker output is selected within PA (i.e. not your headphones). enter image description here

  2. Open a terminal and run the following command:

    pactl list | grep 'Active Port.*output.*'
    
  3. It should output something that looks like this:

    Active Port: audiotype-output-device

i.e.

enter image description here

The "active port" is the PA port currently controlling the ALSA settings. Since you already selected your speaker as the PA output, this output from the terminal command tells you that you need to edit the mixer path file audiotype-output-device.conf. In my case, the mixer path file was analog-output-speaker.conf.

Now that we have the correct mixer path file, we need to make our changes.

NOTE: Within this mixer paths folder, there is a file named 'analog-output.conf.common'. The contents of this file explain how the mixer path files are interpreted. If you wish to understand the following changes, I strongly recommend looking at this file before editing your mixer path(s)!

Each mixer path file contains numerous "Elements". Ideally, there is an element representing each ALSA device on you computer within each of the files. There are probably elements that you don't have as well. This is normal.

In my case, I needed to change the Headphone and Speaker elements within the mixer path for analog-output-speaker.conf in the following ways:

  1. Allow PA volume to adjust the headphone ALSA volume.

Original:

[Element Headphone]
switch = off
volume = off

Edited:

[Element Headphone]
switch = off
volume = merge
override-map.1 = all
override-map.2 = all-left,all-right
  1. (Optional) Set the speaker volume to off and prevent PA volume from affecting ALSA volume. (If you don't do this, your sound will still work, but the speaker settings within ALSA will bounce around unnessesarily.)

Original:

[Element Speaker]
required-any = any
switch = mute
volume = merge
override-map.1 = all
override-map.2 = all-left,all-right

Edited:

[Element Speaker]
required-any = any
switch = mute
volume = off

Then, restart PA by executing:

pulseaudio -k && pulseaudio --start

VoilĂ !

Related Question