]>
code.delx.au - pulseaudio/blob - src/pulse/client-conf-x11.c
2 This file is part of PulseAudio.
4 Copyright 2004-2006 Lennart Poettering
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2.1 of the License,
9 or (at your option) any later version.
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-13071
29 #include <X11/Xatom.h>
31 #include <pulse/xmalloc.h>
32 #include <pulse/i18n.h>
34 #include <pulsecore/x11prop.h>
35 #include <pulsecore/log.h>
36 #include <pulsecore/core-util.h>
37 #include <pulsecore/macro.h>
39 #include "client-conf-x11.h"
41 int pa_client_conf_from_x11(pa_client_conf
*c
, const char *dname
) {
48 if (!dname
&& !(dname
= getenv("DISPLAY")))
54 if (!(d
= XOpenDisplay(dname
))) {
55 pa_log(_("XOpenDisplay() failed"));
59 if (pa_x11_get_prop(d
, "PULSE_SERVER", t
, sizeof(t
))) {
60 pa_xfree(c
->default_server
);
61 c
->default_server
= pa_xstrdup(t
);
64 if (pa_x11_get_prop(d
, "PULSE_SINK", t
, sizeof(t
))) {
65 pa_xfree(c
->default_sink
);
66 c
->default_sink
= pa_xstrdup(t
);
69 if (pa_x11_get_prop(d
, "PULSE_SOURCE", t
, sizeof(t
))) {
70 pa_xfree(c
->default_source
);
71 c
->default_source
= pa_xstrdup(t
);
74 if (pa_x11_get_prop(d
, "PULSE_COOKIE", t
, sizeof(t
))) {
75 uint8_t cookie
[PA_NATIVE_COOKIE_LENGTH
];
77 if (pa_parsehex(t
, cookie
, sizeof(cookie
)) != sizeof(cookie
)) {
78 pa_log(_("Failed to parse cookie data"));
82 pa_assert(sizeof(cookie
) == sizeof(c
->cookie
));
83 memcpy(c
->cookie
, cookie
, sizeof(cookie
));
85 c
->cookie_valid
= TRUE
;
87 pa_xfree(c
->cookie_file
);
88 c
->cookie_file
= NULL
;