Ubuntu – Sound playing through speaker and headphones

15.10alsaheadphonessoundspeakers

I have an Asus ROG G752VY dual booted with win 10 and Ubuntu 15.10

Everything works fine in windows. Switching to Ubuntu the speakers work fine but as soon as I plug in the headphones nothing worked.

I added

options snd-hda-intel model=asus-mode5 (I tried asus-mode1 through to 8 too)

to /etc/modprobe.d/alsa-base.conf

the headphones now work beautifully, but sound is still played through the speakers.

Running cat /proc/asound/card0/codec* | grep Codec I get Codec: Realtek ALC668

Also, the built-in microphone isn't working, though it works fine in Windows.

Any ideas?

EDIT: Auto-mute is enabled in alsamixer

EDIT 2: After looking in pavucontrol even though the headphones are plugged in, it thinks they are not plugged in. It appears to be treating the headphones as an extension of the speaker as when I change the "speaker" volume in alsamixer it changes the volume through the headphones too.

EDIT 3: Output for $ pacmd list-sinks

$ pacmd list-sinks
2 sink(s) available.
    index: 0
    name: <alsa_output.pci-0000_01_00.1.hdmi-stereo>
    driver: <module-alsa-card.c>
    flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE 
    priority: 9050
    volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max request: 0 KiB
    max rewind: 0 KiB
    monitor source: 0
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 0.00 ms; range is 0.50 .. 371.52 ms
    card: 0 <alsa_card.pci-0000_01_00.1>
    module: 6
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "HDMI 0"
        alsa.id = "HDMI 0"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "3"
        alsa.card = "1"
        alsa.card_name = "HDA NVidia"
        alsa.long_card_name = "HDA NVidia at 0xdc080000 irq 17"
        alsa.driver_name = "snd_hda_intel"
        device.bus_path = "pci-0000:01:00.1"
        sysfs.path = "/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1"
        device.bus = "pci"
        device.vendor.id = "10de"
        device.vendor.name = "NVIDIA Corporation"
        device.product.id = "0fbb"
        device.product.name = "GM204 High Definition Audio Controller"
        device.string = "hdmi:1"
        device.buffering.buffer_size = "65536"
        device.buffering.fragment_size = "32768"
        device.access_mode = "mmap+timer"
        device.profile.name = "hdmi-stereo"
        device.profile.description = "Digital Stereo (HDMI)"
        device.description = "GM204 High Definition Audio Controller Digital Stereo (HDMI)"
        alsa.mixer_name = "Nvidia GPU 71 HDMI/DP"
        alsa.components = "HDA:10de0071,10431ced,00100100"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no)
            properties:
                device.icon_name = "video-display"
    active port: <hdmi-output-0>
  * index: 8
    name: <alsa_output.pci-0000_00_1f.3.analog-stereo>
    driver: <module-alsa-card.c>
    flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: RUNNING
    suspend cause: 
    priority: 9959
    volume: front-left: 20375 /  31% / -30.44 dB,   front-right: 20375 /  31% / -30.44 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 9.82 ms
    max request: 2 KiB
    max rewind: 64 KiB
    monitor source: 11
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 1
    linked by: 2
    configured latency: 11.61 ms; range is 0.50 .. 371.52 ms
    card: 1 <alsa_card.pci-0000_00_1f.3>
    module: 7
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "ALC668 Analog"
        alsa.id = "ALC668 Analog"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "0"
        alsa.card_name = "HDA Intel PCH"
        alsa.long_card_name = "HDA Intel PCH at 0xda128000 irq 327"
        alsa.driver_name = "snd_hda_intel"
        device.bus_path = "pci-0000:00:1f.3"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "a170"
        device.product.name = "Sunrise Point-H HD Audio"
        device.form_factor = "internal"
        device.string = "front:0"
        device.buffering.buffer_size = "65536"
        device.buffering.fragment_size = "32768"
        device.access_mode = "mmap+timer"
        device.profile.name = "analog-stereo"
        device.profile.description = "Analogue Stereo"
        device.description = "Built-in Audio Analogue Stereo"
        alsa.mixer_name = "Realtek ALC668"
        alsa.components = "HDA:10ec0668,10431ced,00100003"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
            properties:
                device.icon_name = "audio-speakers"
        analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: no)
            properties:
                device.icon_name = "audio-headphones"
    active port: <analog-output-speaker>

Best Answer

Firstly, keep options snd-hda-intel model=asus-mode5 added to /etc/modprobe.d/alsa-base.conf

Disable pulseaudio's auto spawning capabilities and kill all instances

$ echo autospawn = no >> /etc/pulse/client.conf
$ killall pulseaudio

check if there is anything else using the sound card

$ sudo fuser -v /dev/snd/*

make sure you kill anything that comes up and stop it from respawning too, how to do this will depend on what the program is.

Install alsa-tools-gui

$ sudo apt-get install alsa-tools-gui
$ sudo hdajackretask

When the GUI loads, click "Show unconnected pins" and override the first unconnected pin to be a headphone jack and apply the settings. Daemonise pulseaudio puslseaudio -D and test the sound, repeat this for all unconnected ports until you find the right one.

Once you have found the one the correct jack, click "Install boot override" and restart to make sure everything works. Now edit the pulseaudio config file and remove the line added earlier to allow respawning again.

Until you reboot, volume can only modified using alsamixer rather than the usual GUI component. After rebooting, everything goes back to normal.

Related Question