9

When it goes to sleep, sound working, when it wakes from sleep the sound doesn't work. So I go into gnome settings > sound and the output device has been reset to 'dummy output'. Instead of HDMI output [nvidia card driver 430.50].

Simply changing the output device in settings, back to HDMI, does not fix things.

Issuing the command pulseaudio -k does fix things. The dummy output option disappears and the HDMI option is restored. This is played out, entirely reproducible, every time the machine wakes.

Perhaps related... For a week, I had to use some external speakers via the line-out, immediately before this all started. Although all I did was plug them in, and everything worked automagically. They've since been returned.

Alternatively, one is tempted to blame it on something in the ubuntu 19.10 update? Although that might be unfair, the timing does fit.

Anyways, the question is, what is the permanent fix so that I do not have to issue a kill order on pulseaudio on every wake?

John Mee
  • 1,053

6 Answers6

4

It be caused by a new kernel introduced in 19.10 like this case:

If not then you can use this script /etc/systemd/system-sleep/reloadpulse:

#!/bin/sh

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

# DESC: PulseAudo 8 sets sound to dummy ouput when going to sleep.
#       This script kills and reloads pulse audio.

# DATE: November 25, 2019.

# NOTE: Written for ask ubuntu question:
#       https://askubuntu.com/questions/1191649/why-no-sound-on-wake-dummy-output-takes-over-pulseaudio-k-the-fix

case $1/$2 in
  pre/*)
    echo "$0: Going to $2..."
    ;;
  post/*)
    echo "$0: Waking up from $2..."
    pulseaudio -k
    ;;
esac

Mark the script executable with chmod a+x /etc/systemd/system-sleep/reloadpulse

After updates deactivate it with chmod a-x /etc/systemd/system-sleep/reloadpulse

Then if the update didn't fix the problem make it executable again.

You need to reboot for changes to take effect.

4

I have a similar problem with Ubuntu 20.04.

This command solved the problem: pulseaudio --start

Kevin Bowen
  • 20,055
  • 57
  • 82
  • 84
bhu
  • 41
  • 1
1

I tried the solution by @WinEunuuchs2Unix but it didn't work with my Ubuntu 20.04.2 on a Lenovo Ideapad Y910. This is what I had to do to make it work with my setup:

Add a file (let's call it "pulseaudio-fix") to the directory /usr/lib/systemd/system-sleep and give it execution permission:

chmod a+x pulseaudio-fix

Include the following content in the file:

#!/bin/sh

case $1 in post) su user-name -c " killall pulseeffects; killall pulseaudio; sleep 1; DISPLAY=:0 /usr/bin/pulseeffects --gapplication-service &" ;; esac

Where "user-name" is the name of your user account. In my case commands wouldn't run under the system account. Additionally, killing pulseaudio would mess with pulseeffects, so it needed to be killed before pulseaudio and restarted after it autostarts. If you don't need pulseeffects, just delete the two lines from the code above.

This made the random "dummy output" after sleep problem go away for good in my case.

1

Do both pulseaudio --kill then pulseaudio --start

https://askubuntu.com/a/1242527/52975 put me on the right track. But for me I need to run pulseaudio --kill first before --start:

pulseaudio --kill
pulseaudio --start

Also you may need to restart some applications that were previously running, e.g. VLC won't pick up the new pulseadio automatically otherwise and remains silent.

The kill + start is also mentioned at this bug report: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1963767 which you must now go and upvote.

Tested on Ubuntu 22.04.1, Lenovo ThinkPad P51.

0

Disable the pulseaudio module module-rescue-streams by sudo editing the file /etc/pulse/default.pa and commenting it out.

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
# I commented this out to stop it defaulting to a 'dummy output' after sleep/suspend [JM:november 2019]
# load-module module-rescue-streams

I'm guessing that there has been a change in the wake sequence such that, now, this runs before all the sound sinks are restored. Consequently, it decides all the 'dead' sinks need to be "rescued" to a new default/dummy sink. They all subsequently wake up, but they've already been rerouted to the dummy.

I'm also guessing that this could break some ability to unplug and replug speakers/headphones as and whenever you like, but I haven't discovered that for myself yet.

John Mee
  • 1,053
0

This method works for me. You can try:

pulseaudio -k && sudo alsa force-reload

I adapted this answer from this youtube video.

Nmath
  • 12,664