[pulseaudio-discuss] [PATCH 2/2] context: add cookie loaders + setter
Alexander Couzens
lynxis at fe80.eu
Tue Aug 13 02:41:10 PDT 2013
I'm not sure if these 3 seperate calls for cookie loading are better than creating a pa_context_get_conf() call and
operating on it.
Signed-off-by: Alexander Couzens <lynxis at fe80.eu>
---
src/pulse/context.c | 15 +++++++++++++++
src/pulse/context.h | 9 +++++++++
2 files changed, 24 insertions(+)
diff --git a/src/pulse/context.c b/src/pulse/context.c
index 1ba2672..654284e 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -1448,3 +1448,18 @@ size_t pa_context_get_tile_size(pa_context *c, const pa_sample_spec *ss) {
mbs = PA_ROUND_DOWN(pa_mempool_block_size_max(c->mempool), fs);
return PA_MAX(mbs, fs);
}
+
+int pa_context_set_cookie(pa_context *c, uint8_t *cookie, size_t cookie_size) {
+ if(cookie_size != PA_NATIVE_COOKIE_LENGTH)
+ return -PA_ERR_INVALID;
+ memcpy(c->conf->cookie, cookie, cookie_size);
+ return 0;
+}
+
+int pa_context_load_cookie_from_hex(pa_context *c, const char *cookie_as_hex) {
+ return pa_client_conf_load_cookie_from_hex(c->conf, cookie_as_hex);
+}
+
+int pa_context_load_cookie_file(pa_context *c, const char *cookie_file_path) {
+ return pa_client_conf_load_cookie_from_file(c->conf, cookie_file_path);
+}
diff --git a/src/pulse/context.h b/src/pulse/context.h
index 6e615f6..20fa1ff 100644
--- a/src/pulse/context.h
+++ b/src/pulse/context.h
@@ -280,6 +280,15 @@ void pa_context_rttime_restart(pa_context *c, pa_time_event *e, pa_usec_t usec);
* pa_stream_get_sample_spec(ss)); \since 0.9.20 */
size_t pa_context_get_tile_size(pa_context *c, const pa_sample_spec *ss);
+/** Set the authentication cookie */
+int pa_context_set_cookie(pa_context *c, uint8_t *cookie, size_t cookie_size);
+
+/** Load the authentication cookie from a hexdecimal string */
+int pa_context_load_cookie_from_hex(pa_context *c, const char *cookie);
+
+/** Load the authentication cookie from a file */
+int pa_context_load_cookie_file(pa_context *c, const char *cookie_file_path);
+
PA_C_DECL_END
#endif
--
1.8.3.4
More information about the pulseaudio-discuss
mailing list