+static void track_pulseaudio_on_dbus(pa_context *c, DBusBusType type, pa_dbus_wrap_connection **conn) {
+ DBusError error;
+
+ pa_assert(c);
+ pa_assert(conn);
+
+ dbus_error_init(&error);
+ if (!(*conn = pa_dbus_wrap_connection_new(c->mainloop, type, &error)) || dbus_error_is_set(&error)) {
+ pa_log_warn("Unable to contact DBUS: %s: %s", error.name, error.message);
+ goto finish;
+ }
+
+ if (!dbus_connection_add_filter(pa_dbus_wrap_connection_get(*conn), filter_cb, c, NULL)) {
+ pa_log_warn("Failed to add filter function");
+ goto finish;
+ }
+
+ if (pa_dbus_add_matches(
+ pa_dbus_wrap_connection_get(*conn), &error,
+ "type='signal',sender='" DBUS_SERVICE_DBUS "',interface='" DBUS_INTERFACE_DBUS "',member='NameOwnerChanged',arg0='org.pulseaudio',arg1=''", NULL) < 0)
+ pa_log_warn("Unable to track org.pulseaudio: %s: %s", error.name, error.message);
+
+ finish:
+ dbus_error_free(&error);
+}
+