More PulseAudio power goodness

[tl;dr — if you're using GNOME or a GStreamer-based player, not using the Rhythmbox crossfading backend, and want to try to save ~0.5 W of power, jump to end of the post]

Lennart pointed to another blog post about actually putting PulseAudio’s power-saving capabilities to use on your system. The latter provides a hack-ish way to increase buffering in PulseAudio to the maximum possible, reducing the number of wakeups. I’m going to talk about that a bit.

Summarising the basic idea, we want music players to decode a large chunk of data and give it to PA so that we can then fill up ALSA’s hardware buffer, sleep till it’s almost completely consumed, fill it again, sleep, repeat. More details in this post from Lennart.

The native GNOME audio/video players don’t talk to PulseAudio directly — they use GStreamer, which has a pulsesink element that actually talks to PulseAudio. We could configure things so that we send a large amount (say 2 seconds’ worth) to PulseAudio, sleep, and then wake up periodically to push out more. Now in the audio player (say Rhythmbox), the user hits next, prev, or pause. We need to effect this change immediately, even though we’ve already sent out 2 seconds of data (it would suck if you hit pause and the actual pause happened 2 seconds later, wouldn’t it?). PulseAudio already solves because it can internally “rewind” the buffer and overwrite it if required. GStreamer can and does take advantage of this by sending pause and other control messages out of band from the data.

This all works well for relatively simple GStreamer pipelines. However, if you want to do something more complicated, like Rhythmbox’ crossfading backend, things start to break. PulseAudio doesn’t offer an API to do fades, and since we don’t do rewinds in GStreamer, we need to apply effects such as fades with a latency equal to the amount of buffering we’re asking PulseAudio to do. This makes for unhappy users.

Well, all is not as bleak as it seems. There was some discussion on the PA mailing list, and the need for a proper fade API (really, a generic effects API) is clear. There have even been attempts to solve this in GStreamer.

But you want to save 0.5 W of power now! Okay, if you’re not using the Rhythmbox crossfading backend (or are okay with disabling it), this will make Rhythmbox, Banshee, pre-3.0 Totem (and really any GNOMEy player that uses gconfaudiosink, which will soon be replaced by gsettingsaudiosink, I guess), you can run this on the command line:

gconftool-2 --type string \
    --set /system/gstreamer/0.10/default/musicaudiosink \
    "pulsesink latency-time=100000 buffer-time=2000000"

On my machine, this brings down the number of wakeups per second because of alsa-sink to ~2.7 (corresponding nicely to the ~350ms of hardware buffer that I have). With Totem 3.0, this may or may not work, depending on whether your distribution gives gconfaudiosink a higher rank than pulseaudiosink.

This is clearly just a stop-gap till we can get things done the Right Way™ at the system level, so really, if things break, you get to keep the pieces. If you need to, you can undo this change by running the same command without the latency-time=… and buffer-time=… bits. That said, if something does break, do leave a comment below so I can add it to the list of things that we need to test the final solution with.

This entry was posted in Blog and tagged , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Petr
    Posted May 17, 2011 at 11:10 am | Permalink

    Oh, I hope this will not became the default unless the choice is given to low-latency applications to change this (some dynamic latency/buffer length would be the best :)

    • Arun
      Posted May 17, 2011 at 11:14 am | Permalink

      But, of course! This already works.

      gconfaudiosink has a profile property. When you set this to “music”, it looks up the musicaudiosink key I mention in my post. Only music/movie players are expected to set this value on the property. VOIP clients would generally set the profile to “chat” (although this does nothing yet, the latency-/buffer-time values could be tweaked here as well).

  2. anon
    Posted May 17, 2011 at 5:18 pm | Permalink

    Running the command on F15 gives: GLib-GIO:ERROR:gdbusconnection.c:2279:initable_init: assertion failed: (connection->initialization_error == NULL) Aborted

    • Arun
      Posted May 18, 2011 at 1:44 pm | Permalink

      Don’t know for certain, but I’m guessing gconf isn’t used in F15?

  3. Anon
    Posted July 22, 2011 at 10:04 am | Permalink

    Hello Arun, Can you please let me know what determines the value of lateny-time and buffer-time properties of pulsesink element?

    I am running PA on an embedded platform and have been setting these values randomly and I see that either the audio is too fast (buffer overwrites) or there is audio drops (buffer underruns).

    How can I know what these parameters should be set to on a given hardware?

  4. Posted September 13, 2012 at 5:08 pm | Permalink

    On my system, this doesn’t work. IIRC, Gnome3 uses gsettings/dconf instead of gconf. To change the value there, this worked for me instead:

    gsettings set org.freedesktop.gstreamer-0.10.default-elements music-audiosink "pulsesink latency-time=100000 buffer-time=2000000"

One Trackback

  • By Notes from the Prague Audio BoFs on November 5, 2011 at 12:22 am

    [...] We currently do not actually use PulseAudio’s power saving features from GStreamer for several reasons. Suggestions to over come this were mooted. While no definite agreement was reached, one suggestion [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>