summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc-André Lureau <marc-andre.lureau@nokia.com>2009-03-20 18:39:30 +0200
committerMarc-André Lureau <marc-andre.lureau@nokia.com>2009-03-30 20:57:07 +0300
commitb4ef64d198016816568b7b1285afcffeb6fa8382 (patch)
treece203dcd5618ec779a890a1023a44803ab0598bb /src
parenteb93e2537a60db963bac84e189c52b3d83521c63 (diff)
daemon: take org.pulseaudio
Diffstat (limited to 'src')
-rw-r--r--src/daemon/main.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 47ca2673..1d543481 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -87,6 +87,9 @@
#include <pulsecore/thread.h>
#include <pulsecore/once.h>
#include <pulsecore/shm.h>
+#ifdef HAVE_DBUS
+#include <pulsecore/dbus-shared.h>
+#endif
#include "cmdline.h"
#include "cpulimit.h"
@@ -330,6 +333,31 @@ static void set_all_rlimits(const pa_daemon_conf *conf) {
}
#endif
+#ifdef HAVE_DBUS
+static void register_org_pulseaudio(pa_core *c)
+{
+ DBusError error;
+ pa_dbus_connection *conn;
+
+ dbus_error_init(&error);
+ if (!(conn = pa_dbus_bus_get(c, pa_in_system_mode() ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION, &error)) || dbus_error_is_set(&error)) {
+ pa_log_warn("Unable to contact DBUS: %s: %s", error.name, error.message);
+ goto finish_dbus;
+ }
+
+ if (dbus_bus_request_name (pa_dbus_connection_get(conn), "org.pulseaudio", 0, &error) == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
+ pa_log_debug("Got org.pulseaudio!");
+ else if (dbus_error_is_set(&error))
+ pa_log_warn("Unable to get org.pulseaudio: %s: %s", error.name, error.message);
+
+finish_dbus:
+ if (conn)
+ pa_dbus_connection_unref(conn);
+
+ dbus_error_free(&error);
+}
+#endif
+
int main(int argc, char *argv[]) {
pa_core *c = NULL;
pa_strbuf *buf = NULL;
@@ -997,6 +1025,10 @@ int main(int argc, char *argv[]) {
}
#endif
+#ifdef HAVE_DBUS
+ register_org_pulseaudio(c);
+#endif
+
pa_log_info(_("Daemon startup complete."));
retval = 0;