summaryrefslogtreecommitdiff
path: root/src/pulsecore/auth-cookie.c
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2013-07-11 13:57:41 +0200
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>2013-09-13 16:44:15 +0300
commit23c39bb54041a8774b5184802fc7764376bf0565 (patch)
tree2517b41b13e5fd1b7a212f1e36af9f245cb0e7d6 /src/pulsecore/auth-cookie.c
parent943275d2fd8f060633194126a8b3bb4fecbb8a19 (diff)
downloadpulseaudio-23c39bb54041a8774b5184802fc7764376bf0565.tar.gz
module-tunnel: automatically find the PulseAudio server
Make the PulseAudio tunnel behave the same way as a client when it comes to figuring out how to connect to the current PulseAudio daemon. This can be useful if you start a second PulseAudio instance for e.g. network access.
Diffstat (limited to 'src/pulsecore/auth-cookie.c')
-rw-r--r--src/pulsecore/auth-cookie.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/pulsecore/auth-cookie.c b/src/pulsecore/auth-cookie.c
index c5e5d7c6a..a3d9ca478 100644
--- a/src/pulsecore/auth-cookie.c
+++ b/src/pulsecore/auth-cookie.c
@@ -77,6 +77,39 @@ pa_auth_cookie* pa_auth_cookie_get(pa_core *core, const char *cn, bool create, s
return c;
}
+pa_auth_cookie *pa_auth_cookie_create(pa_core *core, const void *data, size_t size) {
+ pa_auth_cookie *c;
+ char *t;
+
+ pa_assert(core);
+ pa_assert(data);
+ pa_assert(size > 0);
+
+ t = pa_xstrdup("auth-cookie");
+
+ if ((c = pa_shared_get(core, t))) {
+
+ pa_xfree(t);
+
+ if (c->size != size)
+ return NULL;
+
+ return pa_auth_cookie_ref(c);
+ }
+
+ c = pa_xmalloc(PA_ALIGN(sizeof(pa_auth_cookie)) + size);
+ PA_REFCNT_INIT(c);
+ c->core = core;
+ c->name = t;
+ c->size = size;
+
+ pa_assert_se(pa_shared_set(core, t, c) >= 0);
+
+ memcpy((uint8_t *) c + PA_ALIGN(sizeof(pa_auth_cookie)), data, size);
+
+ return c;
+}
+
pa_auth_cookie* pa_auth_cookie_ref(pa_auth_cookie *c) {
pa_assert(c);
pa_assert(PA_REFCNT_VALUE(c) >= 1);