pconn->connection = conn;
pconn->dispatch_event = c->mainloop->defer_new(c->mainloop, dispatch_cb, conn);
- pa_property_set(c, name, pconn);
+ pa_shared_set(c, name, pconn);
return pconn;
}
}
/* already disconnected, just free */
- pa_property_remove(c->core, c->property_name);
+ pa_shared_remove(c->core, c->property_name);
c->core->mainloop->defer_free(c->dispatch_event);
dbus_connection_unref(c->connection);
pa_xfree(c);
pa_assert(type == DBUS_BUS_SYSTEM || type == DBUS_BUS_SESSION || type == DBUS_BUS_STARTER);
- if ((pconn = pa_property_get(c, prop_name[type])))
+ if ((pconn = pa_shared_get(c, prop_name[type])))
return pa_dbus_connection_ref(pconn);
if (!(conn = dbus_bus_get_private(type, error)))
if (!(u->x11_wrapper = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL))))
goto fail;
- if (!(l = pa_property_get(m->core, PA_NATIVE_SERVER_PROPERTY_NAME)))
+ if (!(l = pa_shared_get(m->core, PA_NATIVE_SERVER_PROPERTY_NAME)))
goto fail;
l = pa_strlist_reverse(l);
pa_assert(data);
pa_assert(len > 0);
- if (!(a = pa_property_get(c, name)))
+ if (!(a = pa_shared_get(c, name)))
return -1;
pa_assert(a->length == len);
pa_assert(c);
pa_assert(name);
- if (pa_property_get(c, name))
+ if (pa_shared_get(c, name))
return -1;
a = pa_xmalloc(PA_ALIGN(sizeof(struct authkey_data)) + len);
a->length = len;
memcpy((uint8_t*) a + PA_ALIGN(sizeof(struct authkey_data)), data, len);
- pa_property_set(c, name, a);
+ pa_shared_set(c, name, a);
return 0;
}
pa_assert(c);
pa_assert(name);
- a = pa_property_get(c, name);
+ a = pa_shared_get(c, name);
pa_assert(a);
pa_assert(PA_REFCNT_VALUE(a) >= 1);
PA_REFCNT_INC(a);
pa_assert(c);
pa_assert(name);
- a = pa_property_get(c, name);
+ a = pa_shared_get(c, name);
pa_assert(a);
pa_assert(PA_REFCNT_VALUE(a) >= 1);
if (PA_REFCNT_DEC(a) <= 0) {
- pa_property_remove(c, name);
+ pa_shared_remove(c, name);
pa_xfree(a);
}
}
-
-
static int pa_cli_command_autoload_add(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
static int pa_cli_command_autoload_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
-static int pa_cli_command_list_props(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
+static int pa_cli_command_list_shared_props(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
static int pa_cli_command_move_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
static int pa_cli_command_move_source_output(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
static int pa_cli_command_vacuum(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
{ "remove-autoload-sink", pa_cli_command_autoload_remove, NULL /*"Remove autoload entry for a sink (args: name)"*/, 2},
{ "remove-autoload-source", pa_cli_command_autoload_remove, NULL /*"Remove autoload entry for a source (args: name)"*/, 2},
{ "dump", pa_cli_command_dump, "Dump daemon configuration", 1},
- { "list-props", pa_cli_command_list_props, NULL, 1},
+ { "shared", pa_cli_command_list_shared_props, NULL, 1},
{ "move-sink-input", pa_cli_command_move_sink_input, "Move sink input to another sink (args: index, sink)", 3},
{ "move-source-output", pa_cli_command_move_source_output, "Move source output to another source (args: index, source)", 3},
{ "vacuum", pa_cli_command_vacuum, NULL, 1},
return 0;
}
-static int pa_cli_command_list_props(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
+static int pa_cli_command_list_shared_props(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
pa_core_assert_ref(c);
pa_assert(t);
pa_assert(buf);
pa_assert(fail);
- pa_property_dump(c, buf);
+ pa_shared_dump(c, buf);
return 0;
}
for (j = 0; j < PA_CORE_HOOK_MAX; j++)
pa_hook_init(&c->hooks[j], c);
- pa_property_init(c);
+ pa_shared_init(c);
pa_random(&c->cookie, sizeof(c->cookie));
pa_silence_cache_done(&c->silence_cache);
pa_mempool_free(c->mempool);
- pa_property_cleanup(c);
+ pa_shared_cleanup(c);
for (j = 0; j < PA_CORE_HOOK_MAX; j++)
pa_hook_free(&c->hooks[j]);
pa_idxset *clients, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache, *autoload_idxset;
/* Some hashmaps for all sorts of entities */
- pa_hashmap *namereg, *autoload_hashmap, *properties;
+ pa_hashmap *namereg, *autoload_hashmap, *shared;
/* The name of the default sink/source */
char *default_source_name, *default_sink_name;
#include "props.h"
-typedef struct pa_property {
- char *name; /* Points to memory allocated by the property subsystem */
+typedef struct pa_shared {
+ char *name; /* Points to memory allocated by the shared property system */
void *data; /* Points to memory maintained by the caller */
-} pa_property;
+} pa_shared;
-/* Allocate a new property object */
-static pa_property* property_new(const char *name, void *data) {
- pa_property* p;
+/* Allocate a new shared property object */
+static pa_shared* shared_new(const char *name, void *data) {
+ pa_shared* p;
pa_assert(name);
pa_assert(data);
- p = pa_xnew(pa_property, 1);
+ p = pa_xnew(pa_shared, 1);
p->name = pa_xstrdup(name);
p->data = data;
return p;
}
-/* Free a property object */
-static void property_free(pa_property *p) {
+/* Free a shared property object */
+static void shared_free(pa_shared *p) {
pa_assert(p);
pa_xfree(p->name);
pa_xfree(p);
}
-void* pa_property_get(pa_core *c, const char *name) {
- pa_property *p;
+void* pa_shared_get(pa_core *c, const char *name) {
+ pa_shared *p;
pa_assert(c);
pa_assert(name);
- pa_assert(c->properties);
+ pa_assert(c->shared);
- if (!(p = pa_hashmap_get(c->properties, name)))
+ if (!(p = pa_hashmap_get(c->shared, name)))
return NULL;
return p->data;
}
-int pa_property_set(pa_core *c, const char *name, void *data) {
- pa_property *p;
+int pa_shared_set(pa_core *c, const char *name, void *data) {
+ pa_shared *p;
pa_assert(c);
pa_assert(name);
pa_assert(data);
- pa_assert(c->properties);
+ pa_assert(c->shared);
- if (pa_hashmap_get(c->properties, name))
+ if (pa_hashmap_get(c->shared, name))
return -1;
- p = property_new(name, data);
- pa_hashmap_put(c->properties, p->name, p);
+ p = shared_new(name, data);
+ pa_hashmap_put(c->shared, p->name, p);
return 0;
}
-int pa_property_remove(pa_core *c, const char *name) {
- pa_property *p;
+int pa_shared_remove(pa_core *c, const char *name) {
+ pa_shared *p;
pa_assert(c);
pa_assert(name);
- pa_assert(c->properties);
+ pa_assert(c->shared);
- if (!(p = pa_hashmap_remove(c->properties, name)))
+ if (!(p = pa_hashmap_remove(c->shared, name)))
return -1;
- property_free(p);
+ shared_free(p);
return 0;
}
-void pa_property_init(pa_core *c) {
+void pa_shared_init(pa_core *c) {
pa_assert(c);
- c->properties = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
+ c->shared = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
}
-void pa_property_cleanup(pa_core *c) {
+void pa_shared_cleanup(pa_core *c) {
pa_assert(c);
- if (!c->properties)
+ if (!c->shared)
return;
- pa_assert(!pa_hashmap_size(c->properties));
+ pa_assert(pa_hashmap_isempty(c->shared));
- pa_hashmap_free(c->properties, NULL, NULL);
- c->properties = NULL;
+ pa_hashmap_free(c->shared, NULL, NULL);
+ c->shared = NULL;
}
-void pa_property_dump(pa_core *c, pa_strbuf *s) {
+void pa_shared_dump(pa_core *c, pa_strbuf *s) {
void *state = NULL;
- pa_property *p;
+ pa_shared *p;
pa_assert(c);
pa_assert(s);
- while ((p = pa_hashmap_iterate(c->properties, &state, NULL)))
+ while ((p = pa_hashmap_iterate(c->shared, &state, NULL)))
pa_strbuf_printf(s, "[%s] -> [%p]\n", p->name, p->data);
}
-int pa_property_replace(pa_core *c, const char *name, void *data) {
+int pa_shared_replace(pa_core *c, const char *name, void *data) {
pa_assert(c);
pa_assert(name);
- pa_property_remove(c, name);
- return pa_property_set(c, name, data);
+ pa_shared_remove(c, name);
+ return pa_shared_set(c, name, data);
}
-#ifndef foopropshfoo
-#define foopropshfoo
+#ifndef foosharedshfoo
+#define foosharedshfoo
/***
This file is part of PulseAudio.
#include <pulsecore/core.h>
#include <pulsecore/strbuf.h>
-/* The property subsystem is to be used to share data between
+/* The shared property subsystem is to be used to share data between
* modules. Consider them to be kind of "global" variables for a
* core. Why not use the hashmap functions directly? The hashmap
* functions copy neither the key nor value, while this property
* system copies the key. Users of this system have to think about
* reference counting themselves. */
-/* Return a pointer to the value of the specified property. */
-void* pa_property_get(pa_core *c, const char *name);
+/* Note: please don't confuse this with the proplist framework in
+ * pulse/proplist.[ch]! */
-/* Set the property 'name' to 'data'. This function fails in case a
- * property by this name already exists. The property data is not
- * copied or reference counted. This is the caller's job. */
-int pa_property_set(pa_core *c, const char *name, void *data);
+/* Return a pointer to the value of the specified shared property. */
+void* pa_shared_get(pa_core *c, const char *name);
-/* Remove the specified property. Return non-zero on failure */
-int pa_property_remove(pa_core *c, const char *name);
+/* Set the shared property 'name' to 'data'. This function fails in
+ * case a property by this name already exists. The property data is
+ * not copied or reference counted. This is the caller's job. */
+int pa_shared_set(pa_core *c, const char *name, void *data);
-/* A combination of pa_property_remove() and pa_property_set() */
-int pa_property_replace(pa_core *c, const char *name, void *data);
+/* Remove the specified shared property. Return non-zero on failure */
+int pa_shared_remove(pa_core *c, const char *name);
-/* Free all memory used by the property system */
-void pa_property_cleanup(pa_core *c);
+/* A combination of pa_shared_remove() and pa_shared_set() */
+int pa_shared_replace(pa_core *c, const char *name, void *data);
-/* Initialize the properties subsystem */
-void pa_property_init(pa_core *c);
+/* Free all memory used by the shared property system */
+void pa_shared_cleanup(pa_core *c);
-/* Dump the current set of properties */
-void pa_property_dump(pa_core *c, pa_strbuf *s);
+/* Initialize the shared property system */
+void pa_shared_init(pa_core *c);
+
+/* Dump the current set of shared properties */
+void pa_shared_dump(pa_core *c, pa_strbuf *s);
#endif
if (pa_socket_server_get_address(p->server, t, sizeof(t))) {
pa_strlist *l;
- l = pa_property_get(core, PA_NATIVE_SERVER_PROPERTY_NAME);
+ l = pa_shared_get(core, PA_NATIVE_SERVER_PROPERTY_NAME);
l = pa_strlist_prepend(l, t);
- pa_property_replace(core, PA_NATIVE_SERVER_PROPERTY_NAME, l);
+ pa_shared_replace(core, PA_NATIVE_SERVER_PROPERTY_NAME, l);
}
return p;
if (pa_socket_server_get_address(p->server, t, sizeof(t))) {
pa_strlist *l;
- l = pa_property_get(p->core, PA_NATIVE_SERVER_PROPERTY_NAME);
+ l = pa_shared_get(p->core, PA_NATIVE_SERVER_PROPERTY_NAME);
l = pa_strlist_remove(l, t);
if (l)
- pa_property_replace(p->core, PA_NATIVE_SERVER_PROPERTY_NAME, l);
+ pa_shared_replace(p->core, PA_NATIVE_SERVER_PROPERTY_NAME, l);
else
- pa_property_remove(p->core, PA_NATIVE_SERVER_PROPERTY_NAME);
+ pa_shared_remove(p->core, PA_NATIVE_SERVER_PROPERTY_NAME);
}
pa_socket_server_unref(p->server);
XAddConnectionWatch(d, x11_watch, (XPointer) w);
- pa_assert_se(pa_property_set(c, w->property_name, w) >= 0);
+ pa_assert_se(pa_shared_set(c, w->property_name, w) >= 0);
return w;
}
static void x11_wrapper_free(pa_x11_wrapper*w) {
pa_assert(w);
- pa_assert_se(pa_property_remove(w->core, w->property_name) >= 0);
+ pa_assert_se(pa_shared_remove(w->core, w->property_name) >= 0);
pa_assert(!w->clients);
pa_core_assert_ref(c);
pa_snprintf(t, sizeof(t), "x11-wrapper%s%s", name ? "-" : "", name ? name : "");
- if ((w = pa_property_get(c, t)))
+ if ((w = pa_shared_get(c, t)))
return pa_x11_wrapper_ref(w);
return x11_wrapper_new(c, name, t);