Ubuntu – sound problem (Ubuntu 18.04): no sound after suspend

18.04soundsuspend

I have a sound problem (running Ubuntu 18.04 on an Acer Swift 1). After booting, the sound works perfectly fine at first (both via speakers and headphones). But if I suspend and then come back later, the sound is automatically set to headphones (although they are not plugged in) and in the settings there is no other option available. However, if I actually plug in my headphones, there is no sound either.
Sometimes it helps to shut the display and reopen it while the sound is "playing" but that doesn‘t always work.
I already sent it in to Acer but they said it‘s not their problem because I‘m using Ubuntu…
Any ideas about what‘s the problem and how to fix it?

(And sorry, if the explanation is a bit long-winded, I‘m not that used to English IT-lingo. Hope the problem‘s still clear though. Otherwise just ask ;-)).

edit #1:

  1. Pulse Audio shows both speakers and headphones as output devices, but it also says that I have headphones plugged in (which I have not) and that the speakers are unavailable…

  2. I tried this suggestion (https://askubuntu.com/a/78179/307184), but as soon as I select the simultaneous output option, there is no sound (neither via speakers nor headphones).

edit #2:

Apparently somebody else experienced the same problem (No sound after suspend). So upon suggestion here's my system setup information:

sudo lspci -v gives:

00:0e.0 Audio device: Intel Corporation Device 3198 (rev 03) (prog-if 80)
    Subsystem: Acer Incorporated [ALI] Device 126a
    Flags: bus master, fast devsel, latency 0, IRQ 134
    Memory at a1114000 (64-bit, non-prefetchable) [size=16K]
    Memory at a1000000 (64-bit, non-prefetchable) [size=1M]
    Capabilities: [50] Power Management version 3
    Capabilities: [80] Vendor Specific Information: Len=14 <?>
    Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
    Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel, snd_soc_skl

after waking up from suspend it says (there‘s only one number different in the third line, don‘t know what that means):

00:0e.0 Audio device: Intel Corporation Device 3198 (rev 03) (prog-if 80)
    Subsystem: Acer Incorporated [ALI] Device 126a
    Flags: bus master, fast devsel, latency 0, IRQ 25
    Memory at a1114000 (64-bit, non-prefetchable) [size=16K]
    Memory at a1000000 (64-bit, non-prefetchable) [size=1M]
    Capabilities: [50] Power Management version 3
    Capabilities: [80] Vendor Specific Information: Len=14 <?>
    Capabilities: [60] MSI: Enable- Count=1/1 Maskable- 64bit+
    Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel, snd_soc_skl

aplay -l gives (same after booting and waking up from suspend):

**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 0: PCH [HDA Intel PCH], Gerät 0: ALC256 Analog [ALC256 Analog]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
Karte 0: PCH [HDA Intel PCH], Gerät 3: HDMI 0 [HDMI 0]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
Karte 0: PCH [HDA Intel PCH], Gerät 7: HDMI 1 [HDMI 1]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
Karte 0: PCH [HDA Intel PCH], Gerät 8: HDMI 2 [HDMI 2]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
Karte 0: PCH [HDA Intel PCH], Gerät 9: HDMI 3 [HDMI 3]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
Karte 0: PCH [HDA Intel PCH], Gerät 10: HDMI 4 [HDMI 4]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0

pactl list short sinks gives (also same after booting and waking up from suspend):

0   alsa_output.pci-0000_00_0e.0.analog-stereo  module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED
1   combined    module-combine-sink.c   s16le 2ch 44100Hz   SUSPENDED

Best Answer

Edit: July 18, 2019

Question has been revised with new information:

after waking up from suspend it says (there‘s only one number different in the third line, don‘t know what that means):

The third line has changed from IRQ 134 to IRQ 25.

IRQ stands for Interrupt Request. It's basically a telephone number where the device calls the CPU (Central Processing Unit) to have work done. Because the telephone number has changed between suspend and resume the sound card can't call the CPU to get work done.


Here's a script I used a few years ago /lib/systemd/system-sleep/sound:

#!/bin/sh

# NAME: sound
# PATH: /lib/systemd/system-sleep
# CALL: Called from SystemD automatically

# DESC: PulseAudo 8 sets sound to laptop when going to sleep.
#       This script sets sound back to TV.

# DATE: Sep 23 2016. Modified: Oct 28, 2018.

# NOTE: Test psmouse for askubuntu.com "Touchpad not working after suspending laptop"

# Aug 5, 2018  -    Turn off executition bit. As per AU turn off automatic switching:
# https://askubuntu.com/questions/1061414/how-to-disable-pulseaudio-automatic-device-switch/1061578#1061578
#                   Turn execution bit back on as there is no sound at all.
case $1/$2 in
  pre/*)
    echo "$0: Going to $2..."
    # Place your pre suspend commands here, or `exit 0` if no pre suspend action required
    #    modprobe -r psmouse
    sleep 1
    ;;
  post/*)
    echo "$0: Waking up from $2..."
    # Place your post suspend (resume) commands here, or `exit 0` if no post suspend action required
    sleep 2
    # modprobe psmouse
    export PULSE_RUNTIME_PATH="/run/user/1000/pulse/"
    sudo -u UserName -E pacmd set-card-profile 0 output:hdmi-stereo
    ;;
esac

Note my new system doesn't need to use this script anymore. Not sure if it will work in your case but it might.

Related Question