masmu / pulseaudio-dlna

A lightweight streaming server which brings DLNA / UPNP and Chromecast support to PulseAudio and Linux
GNU General Public License v3.0
1.25k stars 162 forks source link

Unable to get to it working ; running as root #325

Open aniljava opened 7 years ago

aniljava commented 7 years ago

Hello, pulseaudio, chromecast audio both are working (chrome browser works too). But i am unable to get the pulseaudio-dlna working. Stuck at :

 # pulseaudio-dlna --debug
08-28 15:24:36 pulseaudio_dlna.__main__                       INFO     Running as root. Starting daemon ...
08-28 15:24:36 pulseaudio_dlna.daemon                         INFO     Checking pulseaudio processes ...
08-28 15:24:36 pulseaudio_dlna.daemon                         INFO     Adding pulseaudio process (6719)
08-28 15:24:38 pulseaudio_dlna.daemon                         INFO     Ignoring pulseaudio process (6719)!

Brief glance at the sources and google search points?? that there might be complications related to pulseaudio or pulseaudio-dlna running as root, code from daemon.py :

    if not self._is_pulseaudio_user_process():
        self.disabled = True
        logger.info('Ignoring pulseaudio process ({pid})!'.format(
            pid=self.pid))
        return

Can any one shed some light on resolving it. Other steps tried so far:

7usr7local commented 6 years ago

@aniljava If pulseaudio is started as root (at least in daemon mode) it switches its uid. In case of debian (raspian to be exact) it switches to "pulse" in the default configuration.

I managed to run pulseaudio-dlna on a headless raspian/mpd/pulseaudio server by starting it via

su - pulse -s /bin/sh -c "pulseaudio-dlna --filter-device '<my dlna device>' -p 8800"

(Port 8080 was occupied by ympd in my case)

@masmu: Might be worth a line in the README?

cybercougar commented 4 years ago

I am running pulseaudio-dlna on puppylinux, which is actually not a multi-user distro. This means everything is executed as root. When I first ran pulseaudio-dlna, it said

Running as root. Starting daemon ...

and then

The application is shutting down, since there already seems to be a running instance.

I did some tracing and found that daemon somehow called acquire_lock() again (I don't know much about dbus and mainloop things, so I just didn't go further) and failed, which caused the already-running-instance message.

The only way I can get it working is like this, ugly but better than nothing :D

  1. Configure pulseaudio to load dbus module
  2. Run pulseaudio. Daemonize mode is ok, just ignore the warning:

"This program is not intended to be run as root (unless --system is specified)."

  1. Modify pulseaudio-dlna's main.py find if os.geteuid() == 0: in line 152 (pulseaudio-dlna verion 0.5.2) replace the 0 with -1, to avoid running daemon
  2. run pulseaudio-dlna, with proper options. In my case, pulseaudio-dlna --codec flac --filter-device='my-renderer'