Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 266311

Summary: media-sound/pulseaudio is lacking suspend support for sys-power/pm-utils (?)
Product: Gentoo Linux Reporter: Richard Marko <rissko>
Component: Current packagesAssignee: Gentoo Linux Gnome Desktop Team <gnome>
Status: RESOLVED TEST-REQUEST    
Severity: minor CC: alexander, cbm, freedesktop-bugs, pacho, sound
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: pulseaudio suspend script
better version

Description Richard Marko 2009-04-15 22:12:58 UTC
After sucessful pm-suspend / resume cycle pulseaudio sound streams are not resumed. 

Reproducible: Always

Steps to Reproduce:
1. pulseaudio -D 
2. mplayer
3. pm-suspend
4. resume PC

Actual Results:  
mplayer is not playing. have to
pulseaudio -k
pulseaudio -D
reload all streams to get sound working. 

Expected Results:  
Sound working after resume.

This script fixes this really anoying thing as it suspends all sinks and sources before S3.
I actually don't know where it belongs (pulseaudio or pm-utils).

psyche sleep.d # pwd
/usr/lib/pm-utils/sleep.d
psyche sleep.d # cat 01PulseAudio 
#!/bin/sh

. "${PM_FUNCTIONS}"

get_pulse_users() {
    echo $(ps aux | awk '/pulseaudio -D/ {print $1}')
}

suspend_pulse() {
    for i in $(get_pulse_users); do
        echo 'suspend 1' | sudo -u $i pacmd &> /dev/null
    done
}

resume_pulse() {
    for i in $(get_pulse_users); do
        echo 'suspend 0' | sudo -u $i pacmd &> /dev/null
    done
}

case $1 in 
    hibernate|suspend) suspend_pulse ;;
    thaw|resume)       resume_pulse  ;;
    *) exit $NA ;;
esac
exit 0
psyche sleep.d #
Comment 1 Gilles Dartiguelongue (RETIRED) gentoo-dev 2009-04-17 11:54:52 UTC
I'd say pulseaudio but you can propose it to pm-utils mailing list. Also could you please attach your script instead of pasting it as a comment. Makes it easier to pick and test. Which is your pm-utils version btw ?
Comment 2 Richard Marko 2009-04-18 08:32:18 UTC
Created attachment 188776 [details]
pulseaudio suspend script
Comment 3 Richard Marko 2009-04-18 08:37:55 UTC
using sys-power/pm-utils-1.2.3-r1
Comment 4 Richard Marko 2009-04-18 08:48:14 UTC
Created attachment 188778 [details]
better version

changed get_pulse_users, not returning root now
Comment 5 Andrew Brouwers 2010-01-05 13:12:03 UTC
This is REALLY best done through pulseaudio, and not pm-utils:

http://cgit.freedesktop.org/pm-utils/tree/README.distributions

A couple projects do this already (wicd comes to mind).  This could probably be done in our pm-utils package, but probably best with pulseaudio itself.
Comment 6 Gilles Dartiguelongue (RETIRED) gentoo-dev 2010-01-24 21:50:42 UTC
reassigning to sound as this is also what I think is the best option.
Comment 7 Matěj Laitl 2011-05-26 16:31:07 UTC
I cannot reproduce it now - I have Amarok playing through pulseaudio in KDE and audio restarts playing upon suspending end resuming using pm-utils.
Comment 8 Gilles Dartiguelongue (RETIRED) gentoo-dev 2012-08-14 13:20:59 UTC
Arun, thoughts ?
Comment 9 Samuli Suominen (RETIRED) gentoo-dev 2012-08-14 17:32:09 UTC
I bet this has been solved in a way upower handles it on it's own now... This is only an educated guess.
Comment 10 Alexander Tsoy 2012-10-19 08:49:36 UTC
Ubuntu has a more complex hook:

http://bazaar.launchpad.net/~ubuntu-core-dev/pulseaudio/ubuntu.2a/view/head:/debian/01PulseAudio
Comment 11 Arun Raghavan (RETIRED) gentoo-dev 2012-10-19 12:32:55 UTC
I don't know where upower (or whatver) stores these hooks, but on GNOME, I don't face this problem.
Comment 12 Pacho Ramos gentoo-dev 2014-02-16 21:06:55 UTC
I cannot reproduce this problems for a long time, please try with a newer release like 4.99.4
Comment 13 Samuli Suominen (RETIRED) gentoo-dev 2014-02-17 06:14:43 UTC
(In reply to Pacho Ramos from comment #12)
> I cannot reproduce this problems for a long time, please try with a newer
> release like 4.99.4

Let me guess. You have sys-power/upower built with USE="systemd"? Then it won't use pm-utils, and obviously you won't hit the problem.

But since I don't use pulseaudio myself and I can't test this, I'm leaving this closed, since I can't be 100% sure this wasn't fixed in some other way in later pulseaudio releases that I don't off-hand understand.
Comment 14 Pacho Ramos gentoo-dev 2014-02-17 07:09:31 UTC
But I remember it was still working ok when I was using consolekit/openRC (that months that I was using it with Gnome 3.8 when we were trying to make them play together)