mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-10 13:29:58 -05:00
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.
This commit is contained in:
parent
943275d2fd
commit
23c39bb540
3 changed files with 211 additions and 10 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
typedef struct pa_auth_cookie pa_auth_cookie;
|
||||
|
||||
pa_auth_cookie* pa_auth_cookie_get(pa_core *c, const char *cn, bool create, size_t size);
|
||||
pa_auth_cookie* pa_auth_cookie_create(pa_core *c, const void *data, size_t size);
|
||||
pa_auth_cookie* pa_auth_cookie_ref(pa_auth_cookie *c);
|
||||
void pa_auth_cookie_unref(pa_auth_cookie *c);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue