pulseaudio no sound after su to root, no default audio device configured

5,232

Pulseaudio in Ubuntu is configured to use per-user sessions. That means that while the normal user account can happily access it, as you've experienced, it is not configured to be used by another user at the same time (such as root).

This isn't a bug; it's normal behavior given the configuration Ubuntu ships with.

"I've spent many hours researching online, testing various setups and talking to Pulseaudio devs. The bottom line of it all is that running pulseaudio in normal user mode will allow only the active session as marked by ConsoleKit to access the audio hardware."

Source: https://help.ubuntu.com/community/MultiseatX

There is some information there on how to go about configuring Pulseaudio to run as a system wide instance rather than using a per-user configuration, but this is not without its drawbacks.

From the pulseaudio man page:

--system[=BOOL] Run as system-wide instance instead of per-user. Please note that this disables certain features of PulseAudio and is generally not recommended unless the system knows no local users (e.g. is a thin client). This feature needs special configuration and a dedicated UNIX user set up. It is highly recommended to combine this with --disallow-module-loading (see below).

You'd be best to consider why it is you're trying to get root playing audio in the first place and determine there's no better way to accomplish whatever it is you're trying to do. If you must allow more than one user simultaneous access to pulseaudio, this is the route you'll want to look down.

Share:
5,232

Related videos on Youtube

xpt
Author by

xpt

Updated on September 18, 2022

Comments

  • xpt
    xpt over 1 year

    This behavior exhibits at least in Ubuntu 13.10 and Ubuntu 14.04.

    I'm playing sounds via the play command from the sox package from the command line. It works fine with me, the user who logs into X. However, when I su as root, it won't work any more:

    % play /usr/share/sounds/alsa/Front_Center.wav
    play FAIL sox: Sorry, there is no default audio device configured
    

    The very command works fine as run by me. Is this what supposed to be?

    Here is my installed sox packages (i.e., I have libsox-fmt-pulse installed):

    ii libsox-fmt-base:amd64  amd64 Minimal set of SoX format libraries
    ii libsox-fmt-mp3:amd64  amd64 SoX MP2 and MP3 format library
    ii libsox-fmt-pulse:amd64  amd64 SoX PulseAudio format I/O library
    ii libsox2:amd64  amd64 SoX library of audio effects and processing
    ii sox  amd64 Swiss army knife of sound processing