pulseaudio == disaster ??

David A. De Graaf dad at datix.us
Fri Nov 16 20:49:03 UTC 2007


On Wed, Nov 14, 2007 at 08:39:04AM -0500, Kelly Miller wrote:
> On Nov 13, 2007 2:56 PM, David A. De Graaf <dad at datix.us> wrote:
> 
>                I got PulseAudio to start automatically on XFCE4 using
> Autostarted Applications.  It really isn't that hard.

It's hard for me.  Please tell us how.  But first read below.

> 
> First of all, I've noticed that using --system ALWAYS throws the "Error
> opening PCM device" error, so don't use it.  I had the same error you're
> getting, and fixed it by using module hal-detect to get the system to find
> the ALSA objects.  I'll post my config file here when I get home and can
> look at it.

Please, do.  Please be precise how you use module hal-detect.

> 
> The PCM device is listed in ALSA; it's usually hw:0 by default.  Again, use
> module hal-detect and the system will find the entries for you.

I haven't found it yet.



I can report modest progress - more a workaround than a solution.

First, my operating environment -
I use the default init level of 3 and manually run startxfce4, or startx
(rarely).  I rely on aplay to audibly mark certain events - by commands
in, eg, rc.local, in various crontabs, to note arrival of mail, etc.

Second, to restate my expectations - 
1)  Sound should work during bootup, before anyone has logged in.
2)  Sound should work at init level 3, before and after running either
startx or startxfce4 to run X.
3)  Sound should work inside xfce or gnome, for any user.
4)  Sound should work in a console screen, whether or not X is also
running, or for a cron job, by any user.

After much experimentation here's what I've found:

For the new sound system to work, the pulseaudio daemon must be
started.  Gnome starts it by some unknown method - ps shows it
running - and sound works inside gnome for the user who ran 'startx'.
Like most everything in gnome, I cannot deduce how it is started.
Thorough grepping shows the word 'gnomeaudio' is nowhere to be found in
any gnome-related file in my home directory, so the command that
starts it remains elusive.

When gnome isn't used, pulseaudio must be started some other way.
'pulseaudio --help' - the only available documentation - suggests the
proper command is:
    pulseaudio -D --system --log-level=syslog
however, as Kelly Miller has pointed out, the --system option
guarantees that startup will fail. 

This is a fundamental flaw.

The only command that succeeds is
    pulseaudio -D --log-level=syslog
and only if run by root.  

If I run it as user 'dad', it fails with the characteristic error:
    Error opening PCM device hw:0: No such device

This, too, is a major flaw with the pulseaudio system.

(The same error occurs when root uses the --system option.)

The startup can be accomplished in /etc/rc.d/rc.local, which is run as
root, but only if the x11 lines in /etc/pulse/default.pa are deactivated.
But then only root can make sounds, and only in the console.  No sound
is available to a non-root user, nor to any user in X.

Another possible place to put the startup command is in xfce's
autostart service but, of course, this fails because it's run as
'dad', not root.

The only successful way to start the daemon that I've found is to run the
command manually in a xterm that's been su'ed to root (or to use sudo).
Then both root and all other users can generate sound.  Oddly, this
ability propagates backward to a console owned by root, but not to one
owned by an ordinary user.
crontab's of root, but not of non-root, can produce sounds with aplay.

Since the file permissions of pulseaudio include the SUID bit, eg
  -rwsr-xr-x 1 root root 49776 2007-10-30 21:03 /usr/bin/pulseaudio
there should be no difference between running the command as root,
or as a non-privileged user.

But there is!
When a non-root user runs it, pulseaudio consistently fails with the
error:
   Error opening PCM device hw:0: No such device

I strongly suspect a non-root user can't access this special device,
and also that --system fails, because of some conflict with the arcane
permissions created by the udev system, but the rules there are all but
impenetrable (to me).

It is also likely that pulseaudio gives up it's SUID privilege, and
does it too soon - before all needed files are opened.

Any advice how to overcome these problems is most welcome.

I reiterate - pulseaudio is not ready for prime time.

-- 
	David A. De Graaf    DATIX, Inc.    Hendersonville, NC
	dad at datix.us         www.datix.us




More information about the fedora-list mailing list