I've installed Debian 8.6 on an old Mac laptop (PowerBook G4) as a living-room music player. This machine sits on a shelf and does exactly one thing: play music using mpd. So I want it to do that one thing well. ;-)

(This laptop is from 2005: it has a 1.5 GHz G4 processor and 768 MB of RAM. Plenty of horsepower for playing music, but not much else!)

And it mostly works ... except a couple of times an hour, the music stutters for maybe half a second. I strongly suspect that the process providing audio data (mpd) is unable to keep its output buffer full, so something (ALSA? the hardware?) plays that little snippet of audio in a tight loop until mpd gets back to feeding audio.

I further suspect that the problem is CPU starvation: something is blocking mpd from running for a large fraction of a second. My evidence for this comes from running "atop" during audio playback to capture a snapshot of the system state every second. When I review those snapshots, I don't see any spike in memory use or I/O, but I do see a spike in CPU usage: pulseaudio shoots up to 40-60% of CPU usage. That fits well with my "large fraction of a second" observation: if pulseaudio is consuming the entire CPU for 400 ms, that would probably show as 40% use during a 1 s interval, and if it starves mpd of CPU for 400 ms, that could account for the stuttering.

So that makes me wonder: why do I need pulseaudio to play music on this thing? I want this laptop to do one thing, play music, and I don't want any other process than mpd to use the audio hardware. So I would like mpd to simply use ALSA directly, without going through pulseaudio. And I can't figure out how.

Even more annoying, I can't even get ALSA utilities (aplay) to play audio without going through pulseaudio! It appears that any process that plays audio ends up causing pulseaudio to run. It further appears that systemd is involved in this conspiracy, since there is never more than one pulseaudio per user, and its parent PID is always 1 (/sbin/init, which is systemd).

Right now, I'm not entirely sure if this is an ALSA question, a pulseaudio question, a Debian question, or a systemd question. I'm fairly sure it's not an mpd question, since I can't even get aplay to play without going through pulseaudio.

So: how I do I disable pulseaudio on Debian 8.6, if that is indeed the source of my audio stuttering problem?

  • Forgot to mention: Linux does not support this Mac's builtin audio hardware, but I'm using a USB audio device. – Greg Ward Nov 4 '16 at 1:31

Ah-ha! I think I figured it out. It's not enough to explicitly use the right ALSA device name, and it's not enough to uninstall pulseaudio. I had to do both of those things. Specifically:

  1. sudo apt remove pulseaudio
  2. reboot to make sure no pulseaudio processes running
  3. run aplay -L and randomly try promising-looking device names until something works: it turns out that "default:CARD=Audio" is the right device name to use. That works with both aplay and mpd.

The relevant snippet of /etc/mpd.conf:

audio_output {
  type      "alsa"
  name      "ALSA default"
  device    "default:CARD=Audio"
  • And to explain the why: Pulseaudio opens all ALSA outputs and inputs, and because ALSA is not designed to share devices, no other applications can open them directly. So to access ALSA directly, you either need to suspend Pulseaudio (pasuspender) or stop it (removing it makes sure it won't start again, but is not strictly necessary). – dirkt Nov 6 '16 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.