[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.19-561-gf73e9c1

Colin Guthrie gitmailer-noreply at 0pointer.de
Sat Sep 18 05:12:43 PDT 2010


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  2ecd764662174bf81b90cfa057104dec103bfeec (commit)

- Log -----------------------------------------------------------------
f73e9c1 x11: Use the default screen for X11 properties.
c0e045d xcb: xcb_get_setup() can return 0, so make sure we check it before using
24014e7 xcb: Ensure the XCB connection is valid before using it.
3877811 x11: Partially convert to XCB.
-----------------------------------------------------------------------

Summary of changes:
 configure.ac                         |    2 +-
 src/modules/x11/module-x11-publish.c |   42 +++++++------
 src/pulse/client-conf-x11.c          |   30 +++++----
 src/pulsecore/x11prop.c              |  112 +++++++++++++++++++++++++---------
 src/pulsecore/x11prop.h              |    9 ++-
 src/pulsecore/x11wrap.c              |    4 +
 src/pulsecore/x11wrap.h              |    4 +
 src/utils/pax11publish.c             |   74 ++++++++++++-----------
 8 files changed, 176 insertions(+), 101 deletions(-)

-----------------------------------------------------------------------

commit 38778117f8e03f32ec5af8684a1013cc7807d66d
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Sat May 29 19:33:54 2010 +0100

    x11: Partially convert to XCB.
    
    This commit mostly converts the X11 handling to XCB. There are still
    some uses of XLib to deal with the X11 session handling modules, however all
    client-side code should now be free of XLib and thus this should fix Bug #799
    
    Note that this removes the screen-based changes by Leszek Koltunski
    in 65e80, however this will be restored in due course.

diff --git a/configure.ac b/configure.ac
index a3551f0..5d69c92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -531,7 +531,7 @@ AC_ARG_ENABLE([x11],
         [x11=auto])
 
 if test "x${x11}" != xno ; then
-    PKG_CHECK_MODULES(X11, [ x11 ice sm xtst ],
+    PKG_CHECK_MODULES(X11, [ x11-xcb ice sm xtst xcb-atom ],
         HAVE_X11=1,
         [
             HAVE_X11=0
diff --git a/src/modules/x11/module-x11-publish.c b/src/modules/x11/module-x11-publish.c
index 7ee1b6d..e811bdf 100644
--- a/src/modules/x11/module-x11-publish.c
+++ b/src/modules/x11/module-x11-publish.c
@@ -28,8 +28,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
+#include <xcb/xcb.h>
 
 #include <pulse/util.h>
 #include <pulse/xmalloc.h>
@@ -92,10 +91,10 @@ static void publish_servers(struct userdata *u, pa_strlist *l) {
         s = pa_strlist_tostring(l);
         pa_strlist_reverse(l);
 
-        pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SERVER", s);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SERVER", s);
         pa_xfree(s);
     } else
-        pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SERVER");
+        pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SERVER");
 }
 
 static pa_hook_result_t servers_changed_cb(void *hook_data, void *call_data, void *slot_data) {
@@ -105,7 +104,7 @@ static pa_hook_result_t servers_changed_cb(void *hook_data, void *call_data, voi
 
     pa_assert(u);
 
-    if (!pa_x11_get_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) {
+    if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) {
         pa_log_warn("PulseAudio information vanished from X11!");
         return PA_HOOK_OK;
     }
@@ -168,22 +167,22 @@ int pa__init(pa_module*m) {
     u->id = pa_sprintf_malloc("%lu@%s/%lu", (unsigned long) getuid(), mid, (unsigned long) getpid());
     pa_xfree(mid);
 
-    pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID", u->id);
+    pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID", u->id);
 
     if ((sid = pa_session_id())) {
-        pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SESSION_ID", sid);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SESSION_ID", sid);
         pa_xfree(sid);
     }
 
     publish_servers(u, pa_native_protocol_servers(u->protocol));
 
     if ((t = pa_modargs_get_value(ma, "source", NULL)))
-        pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SOURCE", t);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SOURCE", t);
 
     if ((t = pa_modargs_get_value(ma, "sink", NULL)))
-        pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SINK", t);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SINK", t);
 
-    pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_COOKIE",
+    pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_COOKIE",
                     pa_hexstr(pa_auth_cookie_read(u->auth_cookie, PA_NATIVE_COOKIE_LENGTH), PA_NATIVE_COOKIE_LENGTH, hx, sizeof(hx)));
 
     u->x11_client = pa_x11_client_new(u->x11_wrapper, NULL, x11_kill_cb, u);
@@ -216,16 +215,16 @@ void pa__done(pa_module*m) {
         char t[256];
 
         /* Yes, here is a race condition */
-        if (!pa_x11_get_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id))
+        if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id))
             pa_log_warn("PulseAudio information vanished from X11!");
         else {
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID");
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SERVER");
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SINK");
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SOURCE");
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_COOKIE");
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SESSION_ID");
-            XSync(pa_x11_wrapper_get_display(u->x11_wrapper), False);
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SERVER");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SINK");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SOURCE");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_COOKIE");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SESSION_ID");
+            xcb_flush(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper));
         }
 
         pa_x11_wrapper_unref(u->x11_wrapper);
diff --git a/src/pulse/client-conf-x11.c b/src/pulse/client-conf-x11.c
index 4970363..565f997 100644
--- a/src/pulse/client-conf-x11.c
+++ b/src/pulse/client-conf-x11.c
@@ -25,8 +25,7 @@
 
 #include <string.h>
 
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
+#include <xcb/xcb.h>
 
 #include <pulse/xmalloc.h>
 #include <pulse/i18n.h>
@@ -39,7 +38,7 @@
 #include "client-conf-x11.h"
 
 int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
-    Display *d = NULL;
+    xcb_connection_t *xcb = NULL;
     int ret = -1;
     char t[1024];
 
@@ -51,18 +50,18 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
     if (*dname == 0)
         goto finish;
 
-    if (!(d = XOpenDisplay(dname))) {
-        pa_log(_("XOpenDisplay() failed"));
+    if (!(xcb = xcb_connect(dname, NULL))) {
+        pa_log(_("xcb_connect() failed"));
         goto finish;
     }
 
-    if (pa_x11_get_prop(d, "PULSE_SERVER", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, "PULSE_SERVER", t, sizeof(t))) {
         pa_bool_t disable_autospawn = TRUE;
 
         pa_xfree(c->default_server);
         c->default_server = pa_xstrdup(t);
 
-        if (pa_x11_get_prop(d, "PULSE_SESSION_ID", t, sizeof(t))) {
+        if (pa_x11_get_prop(xcb, "PULSE_SESSION_ID", t, sizeof(t))) {
             char *id;
 
             if ((id = pa_session_id())) {
@@ -76,17 +75,17 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
             c->autospawn = FALSE;
     }
 
-    if (pa_x11_get_prop(d, "PULSE_SINK", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, "PULSE_SINK", t, sizeof(t))) {
         pa_xfree(c->default_sink);
         c->default_sink = pa_xstrdup(t);
     }
 
-    if (pa_x11_get_prop(d, "PULSE_SOURCE", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, "PULSE_SOURCE", t, sizeof(t))) {
         pa_xfree(c->default_source);
         c->default_source = pa_xstrdup(t);
     }
 
-    if (pa_x11_get_prop(d, "PULSE_COOKIE", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, "PULSE_COOKIE", t, sizeof(t))) {
         uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
 
         if (pa_parsehex(t, cookie, sizeof(cookie)) != sizeof(cookie)) {
@@ -106,8 +105,8 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
     ret = 0;
 
 finish:
-    if (d)
-        XCloseDisplay(d);
+    if (xcb)
+        xcb_disconnect(xcb);
 
     return ret;
 
diff --git a/src/pulsecore/x11prop.c b/src/pulsecore/x11prop.c
index dc8ec29..cc5987a 100644
--- a/src/pulsecore/x11prop.c
+++ b/src/pulsecore/x11prop.c
@@ -25,53 +25,58 @@
 
 #include <string.h>
 
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-
 #include "x11prop.h"
 
-void pa_x11_set_prop(Display *d, const char *name, const char *data) {
-    Atom a = XInternAtom(d, name, False);
-    XChangeProperty(d, DefaultRootWindow(d), a, XA_STRING, 8, PropModeReplace, (const unsigned char*) data, (int) (strlen(data)+1));
+#include <xcb/xproto.h>
+#include <xcb/xcb_atom.h>
+
+#define PA_XCB_FORMAT 8
+
+void pa_x11_set_prop(xcb_connection_t *xcb, const char *name, const char *data) {
+    xcb_screen_t *screen;
+    xcb_atom_t a = xcb_atom_get(xcb, name);
+    screen = xcb_setup_roots_iterator(xcb_get_setup(xcb)).data;
+    xcb_change_property(xcb, XCB_PROP_MODE_REPLACE, screen->root, a, STRING, PA_XCB_FORMAT, (int) strlen(data), (const void*) data);
 }
 
-void pa_x11_del_prop(Display *d, const char *name) {
-    Atom a = XInternAtom(d, name, False);
-    XDeleteProperty(d, DefaultRootWindow(d), a);
+void pa_x11_del_prop(xcb_connection_t *xcb, const char *name) {
+    xcb_screen_t *screen;
+    xcb_atom_t a = xcb_atom_get(xcb, name);
+    screen = xcb_setup_roots_iterator(xcb_get_setup(xcb)).data;
+    xcb_delete_property(xcb, screen->root, a);
 }
 
-char* pa_x11_get_prop(Display *d, const char *name, char *p, size_t l) {
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long nbytes_after;
-    unsigned char *prop = NULL;
+char* pa_x11_get_prop(xcb_connection_t *xcb, const char *name, char *p, size_t l) {
     char *ret = NULL;
-    int window_ret;
+    int len;
+    xcb_get_property_cookie_t req;
+    xcb_get_property_reply_t* prop = NULL;
+    xcb_screen_t *screen;
+    xcb_atom_t a = xcb_atom_get(xcb, name);
+    screen = xcb_setup_roots_iterator(xcb_get_setup(xcb)).data;
 
-    Atom a = XInternAtom(d, name, False);
+    req = xcb_get_property(xcb, 0, screen->root, a, STRING, 0, (uint32_t)(l-1));
+    prop = xcb_get_property_reply(xcb, req, NULL);
 
-    window_ret = XGetWindowProperty(d, DefaultRootWindow(d), a, 0, (long) ((l+2)/4), False, XA_STRING, &actual_type, &actual_format, &nitems, &nbytes_after, &prop);
+    if (!prop)
+        goto finish;
 
-    if (window_ret != Success || actual_type != XA_STRING) {
-        if (DefaultScreen(d) != 0) {
-            window_ret = XGetWindowProperty(d, RootWindow(d, 0), a, 0, (long) ((l+2)/4), False, XA_STRING, &actual_type, &actual_format, &nitems, &nbytes_after, &prop);
+    if (PA_XCB_FORMAT != prop->format)
+        goto finish;
 
-            if (window_ret != Success || actual_type != XA_STRING)
-                goto finish;
-        } else
-            goto finish;
-    }
+    len = xcb_get_property_value_length(prop);
+    if (len < 1 || len >= (int)l)
+        goto finish;
 
-    memcpy(p, prop, nitems);
-    p[nitems] = 0;
+    memcpy(p, xcb_get_property_value(prop), len);
+    p[len] = 0;
 
     ret = p;
 
 finish:
 
     if (prop)
-        XFree(prop);
+        free(prop);
 
     return ret;
 }
diff --git a/src/pulsecore/x11prop.h b/src/pulsecore/x11prop.h
index dc67526..7492261 100644
--- a/src/pulsecore/x11prop.h
+++ b/src/pulsecore/x11prop.h
@@ -5,6 +5,7 @@
   This file is part of PulseAudio.
 
   Copyright 2004-2006 Lennart Poettering
+  Copyright 2010 Colin Guthrie
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
@@ -24,10 +25,10 @@
 
 #include <sys/types.h>
 
-#include <X11/Xlib.h>
+#include <xcb/xcb.h>
 
-void pa_x11_set_prop(Display *d, const char *name, const char *data);
-void pa_x11_del_prop(Display *d, const char *name);
-char* pa_x11_get_prop(Display *d, const char *name, char *p, size_t l);
+void pa_x11_set_prop(xcb_connection_t *xcb, const char *name, const char *data);
+void pa_x11_del_prop(xcb_connection_t *xcb, const char *name);
+char* pa_x11_get_prop(xcb_connection_t *xcb, const char *name, char *p, size_t l);
 
 #endif
diff --git a/src/pulsecore/x11wrap.c b/src/pulsecore/x11wrap.c
index 1960a12..454507a 100644
--- a/src/pulsecore/x11wrap.c
+++ b/src/pulsecore/x11wrap.c
@@ -259,6 +259,10 @@ Display *pa_x11_wrapper_get_display(pa_x11_wrapper *w) {
     return w->display;
 }
 
+xcb_connection_t *pa_x11_wrapper_get_xcb_connection(pa_x11_wrapper *w) {
+    return XGetXCBConnection(pa_x11_wrapper_get_display(w));
+}
+
 void pa_x11_wrapper_kill(pa_x11_wrapper *w) {
     pa_x11_client *c, *n;
 
diff --git a/src/pulsecore/x11wrap.h b/src/pulsecore/x11wrap.h
index b57541f..fc2e01f 100644
--- a/src/pulsecore/x11wrap.h
+++ b/src/pulsecore/x11wrap.h
@@ -23,6 +23,7 @@
 ***/
 
 #include <X11/Xlib.h>
+#include <X11/Xlib-xcb.h>
 
 #include <pulsecore/core.h>
 
@@ -46,6 +47,9 @@ void pa_x11_wrapper_unref(pa_x11_wrapper* w);
 /* Return the X11 display object for this connection */
 Display *pa_x11_wrapper_get_display(pa_x11_wrapper *w);
 
+/* Return the XCB connection object for this connection */
+xcb_connection_t *pa_x11_wrapper_get_xcb_connection(pa_x11_wrapper *w);
+
 /* Kill the connection to the X11 display */
 void pa_x11_wrapper_kill(pa_x11_wrapper *w);
 
diff --git a/src/utils/pax11publish.c b/src/utils/pax11publish.c
index a9eb329..111bee2 100644
--- a/src/utils/pax11publish.c
+++ b/src/utils/pax11publish.c
@@ -29,8 +29,7 @@
 #include <assert.h>
 #include <locale.h>
 
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
+#include <xcb/xcb.h>
 
 #include <pulse/util.h>
 #include <pulse/i18n.h>
@@ -46,7 +45,7 @@
 int main(int argc, char *argv[]) {
     const char *dname = NULL, *sink = NULL, *source = NULL, *server = NULL, *cookie_file = PA_NATIVE_COOKIE_FILE;
     int c, ret = 1;
-    Display *d = NULL;
+    xcb_connection_t *xcb = NULL;
     enum { DUMP, EXPORT, IMPORT, REMOVE } mode = DUMP;
 
     setlocale(LC_ALL, "");
@@ -96,21 +95,21 @@ int main(int argc, char *argv[]) {
         }
     }
 
-    if (!(d = XOpenDisplay(dname))) {
-        pa_log(_("XOpenDisplay() failed"));
+    if (!(xcb = xcb_connect(dname, NULL))) {
+        pa_log(_("xcb_connect() failed"));
         goto finish;
     }
 
     switch (mode) {
         case DUMP: {
             char t[1024];
-            if (pa_x11_get_prop(d, "PULSE_SERVER", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SERVER", t, sizeof(t)))
                 printf(_("Server: %s\n"), t);
-            if (pa_x11_get_prop(d, "PULSE_SOURCE", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SOURCE", t, sizeof(t)))
                 printf(_("Source: %s\n"), t);
-            if (pa_x11_get_prop(d, "PULSE_SINK", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SINK", t, sizeof(t)))
                 printf(_("Sink: %s\n"), t);
-            if (pa_x11_get_prop(d, "PULSE_COOKIE", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_COOKIE", t, sizeof(t)))
                 printf(_("Cookie: %s\n"), t);
 
             break;
@@ -118,14 +117,14 @@ int main(int argc, char *argv[]) {
 
         case IMPORT: {
             char t[1024];
-            if (pa_x11_get_prop(d, "PULSE_SERVER", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SERVER", t, sizeof(t)))
                 printf("PULSE_SERVER='%s'\nexport PULSE_SERVER\n", t);
-            if (pa_x11_get_prop(d, "PULSE_SOURCE", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SOURCE", t, sizeof(t)))
                 printf("PULSE_SOURCE='%s'\nexport PULSE_SOURCE\n", t);
-            if (pa_x11_get_prop(d, "PULSE_SINK", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SINK", t, sizeof(t)))
                 printf("PULSE_SINK='%s'\nexport PULSE_SINK\n", t);
 
-            if (pa_x11_get_prop(d, "PULSE_COOKIE", t, sizeof(t))) {
+            if (pa_x11_get_prop(xcb, "PULSE_COOKIE", t, sizeof(t))) {
                 uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
                 size_t l;
                 if ((l = pa_parsehex(t, cookie, sizeof(cookie))) != sizeof(cookie)) {
@@ -158,16 +157,16 @@ int main(int argc, char *argv[]) {
                 goto finish;
             }
 
-            pa_x11_del_prop(d, "PULSE_SERVER");
-            pa_x11_del_prop(d, "PULSE_SINK");
-            pa_x11_del_prop(d, "PULSE_SOURCE");
-            pa_x11_del_prop(d, "PULSE_ID");
-            pa_x11_del_prop(d, "PULSE_COOKIE");
+            pa_x11_del_prop(xcb, "PULSE_SERVER");
+            pa_x11_del_prop(xcb, "PULSE_SINK");
+            pa_x11_del_prop(xcb, "PULSE_SOURCE");
+            pa_x11_del_prop(xcb, "PULSE_ID");
+            pa_x11_del_prop(xcb, "PULSE_COOKIE");
 
             if (server)
-                pa_x11_set_prop(d, "PULSE_SERVER", server);
+                pa_x11_set_prop(xcb, "PULSE_SERVER", server);
             else if (conf->default_server)
-                pa_x11_set_prop(d, "PULSE_SERVER", conf->default_server);
+                pa_x11_set_prop(xcb, "PULSE_SERVER", conf->default_server);
             else {
                 char hn[256];
                 if (!pa_get_fqdn(hn, sizeof(hn))) {
@@ -175,18 +174,18 @@ int main(int argc, char *argv[]) {
                     goto finish;
                 }
 
-                pa_x11_set_prop(d, "PULSE_SERVER", hn);
+                pa_x11_set_prop(xcb, "PULSE_SERVER", hn);
             }
 
             if (sink)
-                pa_x11_set_prop(d, "PULSE_SINK", sink);
+                pa_x11_set_prop(xcb, "PULSE_SINK", sink);
             else if (conf->default_sink)
-                pa_x11_set_prop(d, "PULSE_SINK", conf->default_sink);
+                pa_x11_set_prop(xcb, "PULSE_SINK", conf->default_sink);
 
             if (source)
-                pa_x11_set_prop(d, "PULSE_SOURCE", source);
+                pa_x11_set_prop(xcb, "PULSE_SOURCE", source);
             if (conf->default_source)
-                pa_x11_set_prop(d, "PULSE_SOURCE", conf->default_source);
+                pa_x11_set_prop(xcb, "PULSE_SOURCE", conf->default_source);
 
             pa_client_conf_free(conf);
 
@@ -195,16 +194,16 @@ int main(int argc, char *argv[]) {
                 goto finish;
             }
 
-            pa_x11_set_prop(d, "PULSE_COOKIE", pa_hexstr(cookie, sizeof(cookie), hx, sizeof(hx)));
+            pa_x11_set_prop(xcb, "PULSE_COOKIE", pa_hexstr(cookie, sizeof(cookie), hx, sizeof(hx)));
             break;
         }
 
         case REMOVE:
-            pa_x11_del_prop(d, "PULSE_SERVER");
-            pa_x11_del_prop(d, "PULSE_SINK");
-            pa_x11_del_prop(d, "PULSE_SOURCE");
-            pa_x11_del_prop(d, "PULSE_ID");
-            pa_x11_del_prop(d, "PULSE_COOKIE");
+            pa_x11_del_prop(xcb, "PULSE_SERVER");
+            pa_x11_del_prop(xcb, "PULSE_SINK");
+            pa_x11_del_prop(xcb, "PULSE_SOURCE");
+            pa_x11_del_prop(xcb, "PULSE_ID");
+            pa_x11_del_prop(xcb, "PULSE_COOKIE");
             break;
 
         default:
@@ -216,9 +215,9 @@ int main(int argc, char *argv[]) {
 
 finish:
 
-    if (d) {
-        XSync(d, False);
-        XCloseDisplay(d);
+    if (xcb) {
+        xcb_flush(xcb);
+        xcb_disconnect(xcb);
     }
 
     return ret;

commit 24014e779c889caf43bf9e9c29d645e505127743
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Sat Sep 18 10:35:38 2010 +0100

    xcb: Ensure the XCB connection is valid before using it.

diff --git a/src/pulse/client-conf-x11.c b/src/pulse/client-conf-x11.c
index 565f997..0348a2f 100644
--- a/src/pulse/client-conf-x11.c
+++ b/src/pulse/client-conf-x11.c
@@ -55,6 +55,11 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
         goto finish;
     }
 
+    if (xcb_connection_has_error(xcb)) {
+        pa_log(_("xcb_connection_has_error() returned true"));
+        goto finish;
+    }
+
     if (pa_x11_get_prop(xcb, "PULSE_SERVER", t, sizeof(t))) {
         pa_bool_t disable_autospawn = TRUE;
 
diff --git a/src/utils/pax11publish.c b/src/utils/pax11publish.c
index 111bee2..62b798c 100644
--- a/src/utils/pax11publish.c
+++ b/src/utils/pax11publish.c
@@ -100,6 +100,11 @@ int main(int argc, char *argv[]) {
         goto finish;
     }
 
+    if (xcb_connection_has_error(xcb)) {
+        pa_log(_("xcb_connection_has_error() returned true"));
+        goto finish;
+    }
+
     switch (mode) {
         case DUMP: {
             char t[1024];

commit c0e045d003b52c5edf8dbee10ff1545435bce297
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Sat Sep 18 10:37:11 2010 +0100

    xcb: xcb_get_setup() can return 0, so make sure we check it before using

diff --git a/src/pulsecore/x11prop.c b/src/pulsecore/x11prop.c
index cc5987a..4f2fec0 100644
--- a/src/pulsecore/x11prop.c
+++ b/src/pulsecore/x11prop.c
@@ -27,6 +27,8 @@
 
 #include "x11prop.h"
 
+#include <pulsecore/macro.h>
+
 #include <xcb/xproto.h>
 #include <xcb/xcb_atom.h>
 
@@ -34,16 +36,33 @@
 
 void pa_x11_set_prop(xcb_connection_t *xcb, const char *name, const char *data) {
     xcb_screen_t *screen;
-    xcb_atom_t a = xcb_atom_get(xcb, name);
-    screen = xcb_setup_roots_iterator(xcb_get_setup(xcb)).data;
-    xcb_change_property(xcb, XCB_PROP_MODE_REPLACE, screen->root, a, STRING, PA_XCB_FORMAT, (int) strlen(data), (const void*) data);
+    const xcb_setup_t *s;
+    xcb_atom_t a;
+
+    pa_assert(xcb);
+    pa_assert(name);
+    pa_assert(data);
+
+    if ((s = xcb_get_setup(xcb))) {
+        a = xcb_atom_get(xcb, name);
+        screen = xcb_setup_roots_iterator(s).data;
+        xcb_change_property(xcb, XCB_PROP_MODE_REPLACE, screen->root, a, STRING, PA_XCB_FORMAT, (int) strlen(data), (const void*) data);
+    }
 }
 
 void pa_x11_del_prop(xcb_connection_t *xcb, const char *name) {
     xcb_screen_t *screen;
-    xcb_atom_t a = xcb_atom_get(xcb, name);
-    screen = xcb_setup_roots_iterator(xcb_get_setup(xcb)).data;
-    xcb_delete_property(xcb, screen->root, a);
+    const xcb_setup_t *s;
+    xcb_atom_t a;
+
+    pa_assert(xcb);
+    pa_assert(name);
+
+    if ((s = xcb_get_setup(xcb))) {
+        a = xcb_atom_get(xcb, name);
+        screen = xcb_setup_roots_iterator(s).data;
+        xcb_delete_property(xcb, screen->root, a);
+    }
 }
 
 char* pa_x11_get_prop(xcb_connection_t *xcb, const char *name, char *p, size_t l) {
@@ -52,26 +71,35 @@ char* pa_x11_get_prop(xcb_connection_t *xcb, const char *name, char *p, size_t l
     xcb_get_property_cookie_t req;
     xcb_get_property_reply_t* prop = NULL;
     xcb_screen_t *screen;
-    xcb_atom_t a = xcb_atom_get(xcb, name);
-    screen = xcb_setup_roots_iterator(xcb_get_setup(xcb)).data;
+    const xcb_setup_t *s;
+    xcb_atom_t a;
+
+    pa_assert(xcb);
+    pa_assert(name);
+    pa_assert(p);
+
+    if ((s = xcb_get_setup(xcb))) {
+        a = xcb_atom_get(xcb, name);
+        screen = xcb_setup_roots_iterator(s).data;
 
-    req = xcb_get_property(xcb, 0, screen->root, a, STRING, 0, (uint32_t)(l-1));
-    prop = xcb_get_property_reply(xcb, req, NULL);
+        req = xcb_get_property(xcb, 0, screen->root, a, STRING, 0, (uint32_t)(l-1));
+        prop = xcb_get_property_reply(xcb, req, NULL);
 
-    if (!prop)
-        goto finish;
+        if (!prop)
+            goto finish;
 
-    if (PA_XCB_FORMAT != prop->format)
-        goto finish;
+        if (PA_XCB_FORMAT != prop->format)
+            goto finish;
 
-    len = xcb_get_property_value_length(prop);
-    if (len < 1 || len >= (int)l)
-        goto finish;
+        len = xcb_get_property_value_length(prop);
+        if (len < 1 || len >= (int)l)
+            goto finish;
 
-    memcpy(p, xcb_get_property_value(prop), len);
-    p[len] = 0;
+        memcpy(p, xcb_get_property_value(prop), len);
+        p[len] = 0;
 
-    ret = p;
+        ret = p;
+    }
 
 finish:
 

commit f73e9c19f7fd4f7aaecd06a283b125078d8ad884
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Sat Sep 18 11:12:56 2010 +0100

    x11: Use the default screen for X11 properties.
    
    This commit restores the functionality originally included in 65e807
    by Leszek Koltunski.

diff --git a/src/modules/x11/module-x11-publish.c b/src/modules/x11/module-x11-publish.c
index e811bdf..6544e07 100644
--- a/src/modules/x11/module-x11-publish.c
+++ b/src/modules/x11/module-x11-publish.c
@@ -84,6 +84,8 @@ struct userdata {
 
 static void publish_servers(struct userdata *u, pa_strlist *l) {
 
+    int screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper));
+
     if (l) {
         char *s;
 
@@ -91,20 +93,22 @@ static void publish_servers(struct userdata *u, pa_strlist *l) {
         s = pa_strlist_tostring(l);
         pa_strlist_reverse(l);
 
-        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SERVER", s);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SERVER", s);
         pa_xfree(s);
     } else
-        pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SERVER");
+        pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SERVER");
 }
 
 static pa_hook_result_t servers_changed_cb(void *hook_data, void *call_data, void *slot_data) {
     pa_strlist *servers = call_data;
     struct userdata *u = slot_data;
     char t[256];
+    int screen;
 
     pa_assert(u);
 
-    if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) {
+    screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper));
+    if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) {
         pa_log_warn("PulseAudio information vanished from X11!");
         return PA_HOOK_OK;
     }
@@ -138,6 +142,7 @@ int pa__init(pa_module*m) {
     char *mid, *sid;
     char hx[PA_NATIVE_COOKIE_LENGTH*2+1];
     const char *t;
+    int screen;
 
     pa_assert(m);
 
@@ -163,26 +168,27 @@ int pa__init(pa_module*m) {
     if (!(u->x11_wrapper = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL))))
         goto fail;
 
+    screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper));
     mid = pa_machine_id();
     u->id = pa_sprintf_malloc("%lu@%s/%lu", (unsigned long) getuid(), mid, (unsigned long) getpid());
     pa_xfree(mid);
 
-    pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID", u->id);
+    pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", u->id);
 
     if ((sid = pa_session_id())) {
-        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SESSION_ID", sid);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SESSION_ID", sid);
         pa_xfree(sid);
     }
 
     publish_servers(u, pa_native_protocol_servers(u->protocol));
 
     if ((t = pa_modargs_get_value(ma, "source", NULL)))
-        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SOURCE", t);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SOURCE", t);
 
     if ((t = pa_modargs_get_value(ma, "sink", NULL)))
-        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SINK", t);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SINK", t);
 
-    pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_COOKIE",
+    pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_COOKIE",
                     pa_hexstr(pa_auth_cookie_read(u->auth_cookie, PA_NATIVE_COOKIE_LENGTH), PA_NATIVE_COOKIE_LENGTH, hx, sizeof(hx)));
 
     u->x11_client = pa_x11_client_new(u->x11_wrapper, NULL, x11_kill_cb, u);
@@ -213,17 +219,18 @@ void pa__done(pa_module*m) {
 
     if (u->x11_wrapper) {
         char t[256];
+        int screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper));
 
         /* Yes, here is a race condition */
-        if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id))
+        if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id))
             pa_log_warn("PulseAudio information vanished from X11!");
         else {
-            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID");
-            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SERVER");
-            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SINK");
-            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SOURCE");
-            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_COOKIE");
-            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SESSION_ID");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SERVER");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SINK");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SOURCE");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_COOKIE");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SESSION_ID");
             xcb_flush(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper));
         }
 
diff --git a/src/pulse/client-conf-x11.c b/src/pulse/client-conf-x11.c
index 0348a2f..76b1b7b 100644
--- a/src/pulse/client-conf-x11.c
+++ b/src/pulse/client-conf-x11.c
@@ -39,7 +39,7 @@
 
 int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
     xcb_connection_t *xcb = NULL;
-    int ret = -1;
+    int ret = -1, screen = 0;
     char t[1024];
 
     pa_assert(c);
@@ -60,13 +60,13 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
         goto finish;
     }
 
-    if (pa_x11_get_prop(xcb, "PULSE_SERVER", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, screen, "PULSE_SERVER", t, sizeof(t))) {
         pa_bool_t disable_autospawn = TRUE;
 
         pa_xfree(c->default_server);
         c->default_server = pa_xstrdup(t);
 
-        if (pa_x11_get_prop(xcb, "PULSE_SESSION_ID", t, sizeof(t))) {
+        if (pa_x11_get_prop(xcb, screen, "PULSE_SESSION_ID", t, sizeof(t))) {
             char *id;
 
             if ((id = pa_session_id())) {
@@ -80,17 +80,17 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
             c->autospawn = FALSE;
     }
 
-    if (pa_x11_get_prop(xcb, "PULSE_SINK", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, screen, "PULSE_SINK", t, sizeof(t))) {
         pa_xfree(c->default_sink);
         c->default_sink = pa_xstrdup(t);
     }
 
-    if (pa_x11_get_prop(xcb, "PULSE_SOURCE", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, screen, "PULSE_SOURCE", t, sizeof(t))) {
         pa_xfree(c->default_source);
         c->default_source = pa_xstrdup(t);
     }
 
-    if (pa_x11_get_prop(xcb, "PULSE_COOKIE", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, screen, "PULSE_COOKIE", t, sizeof(t))) {
         uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
 
         if (pa_parsehex(t, cookie, sizeof(cookie)) != sizeof(cookie)) {
diff --git a/src/pulsecore/x11prop.c b/src/pulsecore/x11prop.c
index 4f2fec0..4cb21da 100644
--- a/src/pulsecore/x11prop.c
+++ b/src/pulsecore/x11prop.c
@@ -34,55 +34,74 @@
 
 #define PA_XCB_FORMAT 8
 
-void pa_x11_set_prop(xcb_connection_t *xcb, const char *name, const char *data) {
-    xcb_screen_t *screen;
+static xcb_screen_t *screen_of_display(xcb_connection_t *xcb, int screen)
+{
     const xcb_setup_t *s;
+    xcb_screen_iterator_t iter;
+
+    if ((s = xcb_get_setup(xcb))) {
+        iter = xcb_setup_roots_iterator(s);
+        for (; iter.rem; --screen, xcb_screen_next(&iter))
+            if (0 == screen)
+                return iter.data;
+    }
+    return NULL;
+}
+
+void pa_x11_set_prop(xcb_connection_t *xcb, int screen, const char *name, const char *data) {
+    xcb_screen_t *xs;
     xcb_atom_t a;
 
     pa_assert(xcb);
     pa_assert(name);
     pa_assert(data);
 
-    if ((s = xcb_get_setup(xcb))) {
+    if ((xs = screen_of_display(xcb, screen))) {
         a = xcb_atom_get(xcb, name);
-        screen = xcb_setup_roots_iterator(s).data;
-        xcb_change_property(xcb, XCB_PROP_MODE_REPLACE, screen->root, a, STRING, PA_XCB_FORMAT, (int) strlen(data), (const void*) data);
+        xcb_change_property(xcb, XCB_PROP_MODE_REPLACE, xs->root, a, STRING, PA_XCB_FORMAT, (int) strlen(data), (const void*) data);
     }
 }
 
-void pa_x11_del_prop(xcb_connection_t *xcb, const char *name) {
-    xcb_screen_t *screen;
-    const xcb_setup_t *s;
+void pa_x11_del_prop(xcb_connection_t *xcb, int screen, const char *name) {
+    xcb_screen_t *xs;
     xcb_atom_t a;
 
     pa_assert(xcb);
     pa_assert(name);
 
-    if ((s = xcb_get_setup(xcb))) {
+    if ((xs = screen_of_display(xcb, screen))) {
         a = xcb_atom_get(xcb, name);
-        screen = xcb_setup_roots_iterator(s).data;
-        xcb_delete_property(xcb, screen->root, a);
+        xcb_delete_property(xcb, xs->root, a);
     }
 }
 
-char* pa_x11_get_prop(xcb_connection_t *xcb, const char *name, char *p, size_t l) {
+char* pa_x11_get_prop(xcb_connection_t *xcb, int screen, const char *name, char *p, size_t l) {
     char *ret = NULL;
     int len;
     xcb_get_property_cookie_t req;
     xcb_get_property_reply_t* prop = NULL;
-    xcb_screen_t *screen;
-    const xcb_setup_t *s;
+    xcb_screen_t *xs;
     xcb_atom_t a;
 
     pa_assert(xcb);
     pa_assert(name);
     pa_assert(p);
 
-    if ((s = xcb_get_setup(xcb))) {
+
+    xs = screen_of_display(xcb, screen);
+    /*
+     * Also try and get the settings from the first screen.
+     * This allows for e.g. a Media Center to run on screen 1 (e.g. HDMI) and have
+     * different defaults (e.g. prefer the HDMI sink) than the primary screen 0
+     * which uses the Internal Audio sink.
+     */
+    if (!xs && 0 != screen)
+        xs = screen_of_display(xcb, 0);
+
+    if (xs) {
         a = xcb_atom_get(xcb, name);
-        screen = xcb_setup_roots_iterator(s).data;
 
-        req = xcb_get_property(xcb, 0, screen->root, a, STRING, 0, (uint32_t)(l-1));
+        req = xcb_get_property(xcb, 0, xs->root, a, STRING, 0, (uint32_t)(l-1));
         prop = xcb_get_property_reply(xcb, req, NULL);
 
         if (!prop)
diff --git a/src/pulsecore/x11prop.h b/src/pulsecore/x11prop.h
index 7492261..5a12114 100644
--- a/src/pulsecore/x11prop.h
+++ b/src/pulsecore/x11prop.h
@@ -27,8 +27,8 @@
 
 #include <xcb/xcb.h>
 
-void pa_x11_set_prop(xcb_connection_t *xcb, const char *name, const char *data);
-void pa_x11_del_prop(xcb_connection_t *xcb, const char *name);
-char* pa_x11_get_prop(xcb_connection_t *xcb, const char *name, char *p, size_t l);
+void pa_x11_set_prop(xcb_connection_t *xcb, int screen, const char *name, const char *data);
+void pa_x11_del_prop(xcb_connection_t *xcb, int screen, const char *name);
+char* pa_x11_get_prop(xcb_connection_t *xcb, int screen, const char *name, char *p, size_t l);
 
 #endif
diff --git a/src/utils/pax11publish.c b/src/utils/pax11publish.c
index 62b798c..e155888 100644
--- a/src/utils/pax11publish.c
+++ b/src/utils/pax11publish.c
@@ -44,7 +44,7 @@
 
 int main(int argc, char *argv[]) {
     const char *dname = NULL, *sink = NULL, *source = NULL, *server = NULL, *cookie_file = PA_NATIVE_COOKIE_FILE;
-    int c, ret = 1;
+    int c, ret = 1, screen = 0;
     xcb_connection_t *xcb = NULL;
     enum { DUMP, EXPORT, IMPORT, REMOVE } mode = DUMP;
 
@@ -95,7 +95,7 @@ int main(int argc, char *argv[]) {
         }
     }
 
-    if (!(xcb = xcb_connect(dname, NULL))) {
+    if (!(xcb = xcb_connect(dname, &screen))) {
         pa_log(_("xcb_connect() failed"));
         goto finish;
     }
@@ -108,13 +108,13 @@ int main(int argc, char *argv[]) {
     switch (mode) {
         case DUMP: {
             char t[1024];
-            if (pa_x11_get_prop(xcb, "PULSE_SERVER", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, screen, "PULSE_SERVER", t, sizeof(t)))
                 printf(_("Server: %s\n"), t);
-            if (pa_x11_get_prop(xcb, "PULSE_SOURCE", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, screen, "PULSE_SOURCE", t, sizeof(t)))
                 printf(_("Source: %s\n"), t);
-            if (pa_x11_get_prop(xcb, "PULSE_SINK", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, screen, "PULSE_SINK", t, sizeof(t)))
                 printf(_("Sink: %s\n"), t);
-            if (pa_x11_get_prop(xcb, "PULSE_COOKIE", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, screen, "PULSE_COOKIE", t, sizeof(t)))
                 printf(_("Cookie: %s\n"), t);
 
             break;
@@ -122,14 +122,14 @@ int main(int argc, char *argv[]) {
 
         case IMPORT: {
             char t[1024];
-            if (pa_x11_get_prop(xcb, "PULSE_SERVER", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, screen, "PULSE_SERVER", t, sizeof(t)))
                 printf("PULSE_SERVER='%s'\nexport PULSE_SERVER\n", t);
-            if (pa_x11_get_prop(xcb, "PULSE_SOURCE", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, screen, "PULSE_SOURCE", t, sizeof(t)))
                 printf("PULSE_SOURCE='%s'\nexport PULSE_SOURCE\n", t);
-            if (pa_x11_get_prop(xcb, "PULSE_SINK", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, screen, "PULSE_SINK", t, sizeof(t)))
                 printf("PULSE_SINK='%s'\nexport PULSE_SINK\n", t);
 
-            if (pa_x11_get_prop(xcb, "PULSE_COOKIE", t, sizeof(t))) {
+            if (pa_x11_get_prop(xcb, screen, "PULSE_COOKIE", t, sizeof(t))) {
                 uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
                 size_t l;
                 if ((l = pa_parsehex(t, cookie, sizeof(cookie))) != sizeof(cookie)) {
@@ -162,16 +162,16 @@ int main(int argc, char *argv[]) {
                 goto finish;
             }
 
-            pa_x11_del_prop(xcb, "PULSE_SERVER");
-            pa_x11_del_prop(xcb, "PULSE_SINK");
-            pa_x11_del_prop(xcb, "PULSE_SOURCE");
-            pa_x11_del_prop(xcb, "PULSE_ID");
-            pa_x11_del_prop(xcb, "PULSE_COOKIE");
+            pa_x11_del_prop(xcb, screen, "PULSE_SERVER");
+            pa_x11_del_prop(xcb, screen, "PULSE_SINK");
+            pa_x11_del_prop(xcb, screen, "PULSE_SOURCE");
+            pa_x11_del_prop(xcb, screen, "PULSE_ID");
+            pa_x11_del_prop(xcb, screen, "PULSE_COOKIE");
 
             if (server)
-                pa_x11_set_prop(xcb, "PULSE_SERVER", server);
+                pa_x11_set_prop(xcb, screen, "PULSE_SERVER", server);
             else if (conf->default_server)
-                pa_x11_set_prop(xcb, "PULSE_SERVER", conf->default_server);
+                pa_x11_set_prop(xcb, screen, "PULSE_SERVER", conf->default_server);
             else {
                 char hn[256];
                 if (!pa_get_fqdn(hn, sizeof(hn))) {
@@ -179,18 +179,18 @@ int main(int argc, char *argv[]) {
                     goto finish;
                 }
 
-                pa_x11_set_prop(xcb, "PULSE_SERVER", hn);
+                pa_x11_set_prop(xcb, screen, "PULSE_SERVER", hn);
             }
 
             if (sink)
-                pa_x11_set_prop(xcb, "PULSE_SINK", sink);
+                pa_x11_set_prop(xcb, screen, "PULSE_SINK", sink);
             else if (conf->default_sink)
-                pa_x11_set_prop(xcb, "PULSE_SINK", conf->default_sink);
+                pa_x11_set_prop(xcb, screen, "PULSE_SINK", conf->default_sink);
 
             if (source)
-                pa_x11_set_prop(xcb, "PULSE_SOURCE", source);
+                pa_x11_set_prop(xcb, screen, "PULSE_SOURCE", source);
             if (conf->default_source)
-                pa_x11_set_prop(xcb, "PULSE_SOURCE", conf->default_source);
+                pa_x11_set_prop(xcb, screen, "PULSE_SOURCE", conf->default_source);
 
             pa_client_conf_free(conf);
 
@@ -199,16 +199,16 @@ int main(int argc, char *argv[]) {
                 goto finish;
             }
 
-            pa_x11_set_prop(xcb, "PULSE_COOKIE", pa_hexstr(cookie, sizeof(cookie), hx, sizeof(hx)));
+            pa_x11_set_prop(xcb, screen, "PULSE_COOKIE", pa_hexstr(cookie, sizeof(cookie), hx, sizeof(hx)));
             break;
         }
 
         case REMOVE:
-            pa_x11_del_prop(xcb, "PULSE_SERVER");
-            pa_x11_del_prop(xcb, "PULSE_SINK");
-            pa_x11_del_prop(xcb, "PULSE_SOURCE");
-            pa_x11_del_prop(xcb, "PULSE_ID");
-            pa_x11_del_prop(xcb, "PULSE_COOKIE");
+            pa_x11_del_prop(xcb, screen, "PULSE_SERVER");
+            pa_x11_del_prop(xcb, screen, "PULSE_SINK");
+            pa_x11_del_prop(xcb, screen, "PULSE_SOURCE");
+            pa_x11_del_prop(xcb, screen, "PULSE_ID");
+            pa_x11_del_prop(xcb, screen, "PULSE_COOKIE");
             break;
 
         default:

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list