Qball's Weblog

Reduce MPD power consumption

Tags General 

Saving power when using MPD.

On your laptop battery power is everything? but playing music means a lot too.
Playing music can easily decrease your battery life significant. For example on my netbook it cost me 22% battery, this is the difference between almost 9.5 hours of battery life time and just 7.5 hours.

So what can we do? (this guide is based on debian testing)

  1. Avoid dmix. DMIX causes re-sampling and worse it (for me) causes the soundcard to use small internal buffers.
    In mpd make an output like:
	type "alsa"
	name "my alsa"
	device "hw:0,0"

This stops MPD from using dmix.

  1. Force 16 bit.
    When decoding mp3′s the result is send to your soundcard (if it accepts this format, most modern soundcards do) in S32_LE (32 bit).
    Using 32bit is pointless, most laptop soundcards have so much distortion and noise they cannot reproduce output with details described in more then the first 13-14bits.
    Forcing 16 bits, allows you to store twice the amount of samples in the soundcard buffers, so less wake ups to refill it.
	type "alsa"
	name "my alsa"
	device "hw:0,0"
	format "44100:16:2"
  1. Increase buffer/period time.
    The larger the buffers, the less wakeups are needed to refill them.
    My card supports a period_size of 8192 samples and a buffer_size of 16384 samples. This means we need to refill the buffer 5.3 times a second. (before step one it was refilled more then 82 times a second, so this reduces the wake ups of the card a 15 fold).
    You can check f.e. powertop to see how often the soundcards interrups the system.

In MPD you can set buffer_time and period_time. The default for buffer_time is large enough (0.5 seconds), however period_time is small (around 512 samples) so we increase this. So lets set this at 200ms. (MPD will find the largest closest supported value).

audio_output {
     type        "alsa"
     name        "My ALSA Device"
     device      "hw:0,0"
     format      "44100:16:2"
     period_time "200000"

Doing all these steps dropped the number of wakeups from hda_intel to +- 5.3 a second. MPD dropped to 13 wakeups a second. This resulted in a powerdrop from 12W to 10.6W (during writing this), resulting in giving me more then an extra hour of battery life time.

(for me blacklisting uvcvideo and usb_storage (webcam + cardreader) saves me around 0.6W. (even when they are unused)).