Discussion:
[pulseaudio-discuss] Pulseaudio not available on D-BUS ??
Fabrice Delente
2014-05-06 14:05:50 UTC
Permalink
Hello.

This is on Gentoo Linux.

I'm trying to control Pulseaudio through D-Bus; I have read and tried
to understand their documentations. But I run into a first problem:
trying to connect to Pulseaudio, it seems it's not available on the
bus : having Pulseaudio running with start-pulseaudio-x11, I then try
in Python

$ python
import dbus
dbus.SystemBus().list_activatable_names()
dbus.Array([dbus.UTF8String('org.freedesktop.DBus'),
dbus.UTF8String('org.freedesktop.PolicyKit1'),
dbus.UTF8String('org.freedesktop.Avahi'),
dbus.UTF8String('org.bluez'),
dbus.UTF8String('org.freedesktop.ModemManager1'),
dbus.UTF8String('org.freedesktop.NetworkManager'),
dbus.UTF8String('org.freedesktop.ConsoleKit'),
dbus.UTF8String('org.freedesktop.UPower'),
dbus.UTF8String('org.freedesktop.UDisks2'),
dbus.UTF8String('org.freedesktop.UDisks'),
dbus.UTF8String('fi.epitest.hostap.WPASupplicant'),
dbus.UTF8String('org.freedesktop.RealtimeKit1'),
dbus.UTF8String('fi.w1.wpa_supplicant1'),
dbus.UTF8String('org.freedesktop.nm_dispatcher')],
signature=dbus.Signature('s'))
dbus.SessionBus().list_activatable_names()
dbus.Array([dbus.UTF8String('org.freedesktop.DBus'),
dbus.UTF8String('org.hexchat.service'),
dbus.UTF8String('org.freedesktop.Notifications'),
dbus.UTF8String('org.gnome.evince.Daemon'),
dbus.UTF8String('org.xfce.Thunar'),
dbus.UTF8String('org.gnome.GConf'),
dbus.UTF8String('org.xfce.vfs.Daemon'),
dbus.UTF8String('org.gtk.vfs.Metadata'),
dbus.UTF8String('org.a11y.Bus'),
dbus.UTF8String('org.gtk.Private.UDisks2VolumeMonitor'),
dbus.UTF8String('org.xfce.Xfconf'),
dbus.UTF8String('org.gnome.keyring.SystemPrompter'),
dbus.UTF8String('org.gnome.keyring'),
dbus.UTF8String('org.gnome.GnomeVFS.Daemon'),
dbus.UTF8String('org.gtk.vfs.Daemon'),
dbus.UTF8String('org.freedesktop.Geoclue.Providers.Localnet'),
dbus.UTF8String('org.freedesktop.secrets'),
dbus.UTF8String('org.gtk.GLib.PACRunner'),
dbus.UTF8String('org.gnome.keyring.PrivatePrompter'),
dbus.UTF8String('org.xfce.FileManager'),
dbus.UTF8String('org.freedesktop.Geoclue.Master'),
dbus.UTF8String('org.a11y.atspi.Registry')],
signature=dbus.Signature('s'))

so nothing looks like pulseaudio there...

Is it normal?

I also tried
bus = dbus.SessionBus()
dbus.Interface( bus.get_object( "org.PulseAudio", "/org/pulsepudio/core1" ), "org.PulseAudio.Core1" )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/dbus/bus.py", line 241, in get_object
follow_name_owner_changes=follow_name_owner_changes)
File "/usr/lib/python2.7/site-packages/dbus/proxies.py", line 248, in __init__
self._named_service = conn.activate_name_owner(bus_name)
File "/usr/lib/python2.7/site-packages/dbus/bus.py", line 180, in
activate_name_owner
self.start_service_by_name(bus_name)
File "/usr/lib/python2.7/site-packages/dbus/bus.py", line 278, in
start_service_by_name
'su', (bus_name, flags)))
File "/usr/lib/python2.7/site-packages/dbus/connection.py", line
651, in call_blocking
message, timeout)
dbus.exceptions.DBusException:
org.freedesktop.DBus.Error.ServiceUnknown: The name org.PulseAudio was
not provided by any .service files

I tried all kind of camel case (pulseAudio, Pulseaudio, pulseaudio,
etc.) but still no success.

Finally I looked into the pulseaudio source tar archive, but couldn't
find any .conf file that I should put in /etc/dbus-1/...

Any help welcome! Thanks.

F. Delente
Weedy
2014-05-06 15:05:33 UTC
Permalink
Post by Fabrice Delente
Hello.
This is on Gentoo Linux.
Pulse should get started by your display manager. I don't even think
it's possible to install a display manager that doesn't support pulse
with todays tree.

You enabled the pulse useflag right?
Fabrice Delente
2014-05-06 15:12:15 UTC
Permalink
Pulseaudio IS started:

$ ps ax | grep pulse
2335 ? Sl 1:11 /usr/bin/pulseaudio --start

I have the dbus and pulseaudio USE flags enabled in /etc/portage/make.conf, yes.
Weedy
2014-05-06 15:15:28 UTC
Permalink
Post by Fabrice Delente
$ ps ax | grep pulse
2335 ? Sl 1:11 /usr/bin/pulseaudio --start
I have the dbus and pulseaudio USE flags enabled in /etc/portage/make.conf, yes.
consolekit and policykit USE flags?

Or systemd and whatever systemd uses.
Fabrice Delente
2014-05-06 15:21:04 UTC
Permalink
I don't have systemd.

'equery uses consolekit' or 'polkit' shows that they don't use
neither the 'pulseaudio' nor 'dbus' flags.

I tried to compile pulseaudio by hand, outside of portage (without
installing of course), and 'make -n install' shows that it would
install a file in /etc/dbus-1/system.d if it was compiled as a system
daemon, which isn't the case.
Weedy
2014-05-06 15:23:09 UTC
Permalink
Post by Fabrice Delente
I don't have systemd.
'equery uses consolekit' or 'polkit' shows that they don't use
neither the 'pulseaudio' nor 'dbus' flags.
I tried to compile pulseaudio by hand, outside of portage (without
installing of course), and 'make -n install' shows that it would
install a file in /etc/dbus-1/system.d if it was compiled as a system
daemon, which isn't the case.
* Contents of media-sound/pulseaudio-4.0-r2:
/etc
/etc/bash_completion.d
/etc/bash_completion.d/pulseaudio-bash-completion.sh
/etc/dbus-1
/etc/dbus-1/system.d
/etc/dbus-1/system.d/pulseaudio-system.conf
Fabrice Delente
2014-05-06 15:25:05 UTC
Permalink
I have pulse 5.0-r1... maybe that's the reason, and the ebuild has a
bug? I'll report it on bugzilla then.
Weedy
2014-05-06 15:25:51 UTC
Permalink
Post by Fabrice Delente
I have pulse 5.0-r1... maybe that's the reason, and the ebuild has a
bug? I'll report it on bugzilla then.
~ # grep -A4 DBus /etc/pulse/default.pa
### Load DBus protocol
.ifexists module-dbus-protocol.so
load-module module-dbus-protocol
.endif

In user mode pulse is supposed to connect to dbus by itself.
As far as I understand.
Fabrice Delente
2014-05-06 15:27:45 UTC
Permalink
Yes, I have that too, and pactl shows that the module is loaded... I
don't get it.
Tanu Kaskinen
2014-05-06 15:36:22 UTC
Permalink
Post by Fabrice Delente
Hello.
This is on Gentoo Linux.
I'm trying to control Pulseaudio through D-Bus; I have read and tried
trying to connect to Pulseaudio, it seems it's not available on the
bus : having Pulseaudio running with start-pulseaudio-x11, I then try
in Python
$ python
import dbus
dbus.SystemBus().list_activatable_names()
dbus.Array([dbus.UTF8String('org.freedesktop.DBus'),
dbus.UTF8String('org.freedesktop.PolicyKit1'),
dbus.UTF8String('org.freedesktop.Avahi'),
dbus.UTF8String('org.bluez'),
dbus.UTF8String('org.freedesktop.ModemManager1'),
dbus.UTF8String('org.freedesktop.NetworkManager'),
dbus.UTF8String('org.freedesktop.ConsoleKit'),
dbus.UTF8String('org.freedesktop.UPower'),
dbus.UTF8String('org.freedesktop.UDisks2'),
dbus.UTF8String('org.freedesktop.UDisks'),
dbus.UTF8String('fi.epitest.hostap.WPASupplicant'),
dbus.UTF8String('org.freedesktop.RealtimeKit1'),
dbus.UTF8String('fi.w1.wpa_supplicant1'),
dbus.UTF8String('org.freedesktop.nm_dispatcher')],
signature=dbus.Signature('s'))
dbus.SessionBus().list_activatable_names()
dbus.Array([dbus.UTF8String('org.freedesktop.DBus'),
dbus.UTF8String('org.hexchat.service'),
dbus.UTF8String('org.freedesktop.Notifications'),
dbus.UTF8String('org.gnome.evince.Daemon'),
dbus.UTF8String('org.xfce.Thunar'),
dbus.UTF8String('org.gnome.GConf'),
dbus.UTF8String('org.xfce.vfs.Daemon'),
dbus.UTF8String('org.gtk.vfs.Metadata'),
dbus.UTF8String('org.a11y.Bus'),
dbus.UTF8String('org.gtk.Private.UDisks2VolumeMonitor'),
dbus.UTF8String('org.xfce.Xfconf'),
dbus.UTF8String('org.gnome.keyring.SystemPrompter'),
dbus.UTF8String('org.gnome.keyring'),
dbus.UTF8String('org.gnome.GnomeVFS.Daemon'),
dbus.UTF8String('org.gtk.vfs.Daemon'),
dbus.UTF8String('org.freedesktop.Geoclue.Providers.Localnet'),
dbus.UTF8String('org.freedesktop.secrets'),
dbus.UTF8String('org.gtk.GLib.PACRunner'),
dbus.UTF8String('org.gnome.keyring.PrivatePrompter'),
dbus.UTF8String('org.xfce.FileManager'),
dbus.UTF8String('org.freedesktop.Geoclue.Master'),
dbus.UTF8String('org.a11y.atspi.Registry')],
signature=dbus.Signature('s'))
so nothing looks like pulseaudio there...
Is it normal?
Yes, it's normal. PulseAudio doesn't support D-Bus activation.

Also, have you read [1]? The control interface, which I assume you are
trying to use, is not exposed in any bus. Instead, you make a direct
peer-to-peer connection.

Also, module-dbus-protocol is nowadays commented out in default.pa,
because it tends to crash the server.

[1] http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/DBus/
--
Tanu
Fabrice Delente
2014-05-06 15:38:35 UTC
Permalink
Yes, I have read [1] and a bunch of d-bus tutorials but I find them
very hard to understand. I'll try again...

Thanks to you two.
Fabrice Delente
2014-05-06 16:21:05 UTC
Permalink
I found this in the doc
(http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/DBus/ConnectingToServer/)

------------------------------------------------------
When a client wants to connect to a server, it reads the
$PULSE_DBUS_SERVER environment variable, which contains a server
address or a list of addresses, as specified in the D-Bus
Specification, section Server Addresses. The client should be able to
use the string directly as the address parameter of the underlying
D-Bus library's connect function.

If $PULSE_DBUS_SERVER is not set, the client reads the Address
property (part of the org.PulseAudio.ServerLookup1 interface) of
object /org/pulseaudio/server_lookup1. The destination of the call is
org.PulseAudio1.
------------------------------------------------------

I don't have PULSE_DBUS_SERVER set in my environment, and I can't read
anything on the bus, so I'm stuck... I tried the python code given on
the wiki page, but I get

dbus.exceptions.DBusException:
org.freedesktop.DBus.Error.ServiceUnknown: The name org.PulseAudio1
was not provided by any .service files

so the documentation is either out of date, or my system is broken
(though all my audio goes through pulseaudio without problem...)
Tanu Kaskinen
2014-05-06 17:26:48 UTC
Permalink
Post by Fabrice Delente
I found this in the doc
(http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/DBus/ConnectingToServer/)
------------------------------------------------------
When a client wants to connect to a server, it reads the
$PULSE_DBUS_SERVER environment variable, which contains a server
address or a list of addresses, as specified in the D-Bus
Specification, section Server Addresses. The client should be able to
use the string directly as the address parameter of the underlying
D-Bus library's connect function.
If $PULSE_DBUS_SERVER is not set, the client reads the Address
property (part of the org.PulseAudio.ServerLookup1 interface) of
object /org/pulseaudio/server_lookup1. The destination of the call is
org.PulseAudio1.
------------------------------------------------------
I don't have PULSE_DBUS_SERVER set in my environment, and I can't read
anything on the bus, so I'm stuck... I tried the python code given on
the wiki page, but I get
org.freedesktop.DBus.Error.ServiceUnknown: The name org.PulseAudio1
was not provided by any .service files
so the documentation is either out of date, or my system is broken
(though all my audio goes through pulseaudio without problem...)
Weird. When pulseaudio is compiled with d-bus support and it's being run
in the per-user mode, it should take the org.PulseAudio1 bus name on the
session bus (regardless of whether module-dbus-protocol is loaded or
not), but the error sounds like the session bus has no service with name
org.PulseAudio1. The example code works on my machine just fine.
--
Tanu
Fabrice Delente
2014-05-06 17:27:38 UTC
Permalink
:^( Alas for me pulseaudio works perfectly but there is no
org.PulseAudio1 on the session bus...
Fabrice Delente
2014-05-06 17:30:08 UTC
Permalink
I tried killing pulseaudio and restarting it, to see if it registered
on the bus, but nothing... I have NetworkManager, UDisks, etc. but not
pulseaudio...
Tanu Kaskinen
2014-05-06 17:37:38 UTC
Permalink
Post by Fabrice Delente
I tried killing pulseaudio and restarting it, to see if it registered
on the bus, but nothing... I have NetworkManager, UDisks, etc. but not
pulseaudio...
There should be an error or warning message in the log if registering
the name fails. If you run pulseaudio with "pulseaudio -vvv" (very very
verbose), there should also be a couple of debug messages on successful
name registration:

D: [pulseaudio] main.c: Got org.PulseAudio1!
D: [pulseaudio] main.c: Got org.pulseaudio.Server!
--
Tanu
Fabrice Delente
2014-05-06 17:47:28 UTC
Permalink
Ok sorry to have made you lose your time, it's working now... I don't
know if it's whether I started pulseaudio directly instead of using
start-pulseaudio-x11... However, I had checked that pulseaudio ran
(with ps ax | grep pulse) and even in that case the python code that
is on the page I refered to didn't work... Having started with
pulseaudio -vvv the same code worked, I don't know why...

Thanks again for your help and sorry for the trouble!

Loading...