summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pulsecore/core-scache.c22
-rw-r--r--src/pulsecore/core-scache.h2
-rw-r--r--src/pulsecore/core.c41
-rw-r--r--src/pulsecore/core.h9
-rw-r--r--src/pulsecore/module.c20
-rw-r--r--src/pulsecore/namereg.c15
-rw-r--r--src/pulsecore/namereg.h2
-rw-r--r--src/pulsecore/shared.c26
-rw-r--r--src/pulsecore/shared.h6
9 files changed, 41 insertions, 102 deletions
diff --git a/src/pulsecore/core-scache.c b/src/pulsecore/core-scache.c
index 6d2ae932..e5489415 100644
--- a/src/pulsecore/core-scache.c
+++ b/src/pulsecore/core-scache.c
@@ -120,9 +120,6 @@ static pa_scache_entry* scache_add_item(pa_core *c, const char *name) {
e->core = c;
e->proplist = pa_proplist_new();
- if (!c->scache)
- c->scache = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
-
pa_idxset_put(c->scache, e, &e->index);
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE|PA_SUBSCRIPTION_EVENT_NEW, e->index);
@@ -287,23 +284,18 @@ int pa_scache_remove_item(pa_core *c, const char *name) {
return 0;
}
-static void free_cb(void *p, void *userdata) {
- pa_scache_entry *e = p;
- pa_assert(e);
-
- free_entry(e);
-}
+void pa_scache_free_all(pa_core *c) {
+ pa_scache_entry *e;
-void pa_scache_free(pa_core *c) {
pa_assert(c);
- if (c->scache) {
- pa_idxset_free(c->scache, free_cb, NULL);
- c->scache = NULL;
- }
+ while ((e = pa_idxset_steal_first(c->scache, NULL)))
+ free_entry(e);
- if (c->scache_auto_unload_event)
+ if (c->scache_auto_unload_event) {
c->mainloop->time_free(c->scache_auto_unload_event);
+ c->scache_auto_unload_event = NULL;
+ }
}
int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx) {
diff --git a/src/pulsecore/core-scache.h b/src/pulsecore/core-scache.h
index a75f8aca..1fe3c309 100644
--- a/src/pulsecore/core-scache.h
+++ b/src/pulsecore/core-scache.h
@@ -58,7 +58,7 @@ int pa_scache_add_directory_lazy(pa_core *c, const char *pathname);
int pa_scache_remove_item(pa_core *c, const char *name);
int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx);
int pa_scache_play_item_by_name(pa_core *c, const char *name, const char*sink_name, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx);
-void pa_scache_free(pa_core *c);
+void pa_scache_free_all(pa_core *c);
const char *pa_scache_get_name_by_id(pa_core *c, uint32_t id);
uint32_t pa_scache_get_id_by_name(pa_core *c, const char *name);
diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c
index 689fc8f8..5fd2bdfb 100644
--- a/src/pulsecore/core.c
+++ b/src/pulsecore/core.c
@@ -92,21 +92,22 @@ pa_core* pa_core_new(pa_mainloop_api *m, pa_bool_t shared, size_t shm_size) {
c->state = PA_CORE_STARTUP;
c->mainloop = m;
+
c->clients = pa_idxset_new(NULL, NULL);
+ c->cards = pa_idxset_new(NULL, NULL);
c->sinks = pa_idxset_new(NULL, NULL);
c->sources = pa_idxset_new(NULL, NULL);
- c->source_outputs = pa_idxset_new(NULL, NULL);
c->sink_inputs = pa_idxset_new(NULL, NULL);
- c->cards = pa_idxset_new(NULL, NULL);
+ c->source_outputs = pa_idxset_new(NULL, NULL);
+ c->modules = pa_idxset_new(NULL, NULL);
+ c->scache = pa_idxset_new(NULL, NULL);
+
+ c->namereg = 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);
c->default_source = NULL;
c->default_sink = NULL;
- c->modules = NULL;
- c->namereg = NULL;
- c->scache = NULL;
- c->running_as_daemon = FALSE;
-
c->default_sample_spec.format = PA_SAMPLE_S16NE;
c->default_sample_spec.rate = 44100;
c->default_sample_spec.channels = 2;
@@ -128,22 +129,20 @@ pa_core* pa_core_new(pa_mainloop_api *m, pa_bool_t shared, size_t shm_size) {
c->exit_idle_time = -1;
c->scache_idle_time = 20;
- c->flat_volumes = TRUE;
-
- c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 3;
+ c->flat_volumes = TRUE;
c->disallow_module_loading = FALSE;
c->disallow_exit = FALSE;
+ c->running_as_daemon = FALSE;
c->realtime_scheduling = FALSE;
c->realtime_priority = 5;
c->disable_remixing = FALSE;
c->disable_lfe_remixing = FALSE;
+ c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 3;
for (j = 0; j < PA_CORE_HOOK_MAX; j++)
pa_hook_init(&c->hooks[j], c);
- pa_shared_init(c);
-
pa_random(&c->cookie, sizeof(c->cookie));
#ifdef SIGPIPE
@@ -165,7 +164,13 @@ static void core_free(pa_object *o) {
c->state = PA_CORE_SHUTDOWN;
pa_module_unload_all(c);
- pa_assert(!c->modules);
+ pa_scache_free_all(c);
+
+ pa_assert(pa_idxset_isempty(c->scache));
+ pa_idxset_free(c->scache, NULL, NULL);
+
+ pa_assert(pa_idxset_isempty(c->modules));
+ pa_idxset_free(c->modules, NULL, NULL);
pa_assert(pa_idxset_isempty(c->clients));
pa_idxset_free(c->clients, NULL, NULL);
@@ -185,8 +190,12 @@ static void core_free(pa_object *o) {
pa_assert(pa_idxset_isempty(c->sink_inputs));
pa_idxset_free(c->sink_inputs, NULL, NULL);
- pa_scache_free(c);
- pa_namereg_free(c);
+ pa_assert(pa_hashmap_isempty(c->namereg));
+ pa_hashmap_free(c->namereg, NULL, NULL);
+
+ pa_assert(pa_hashmap_isempty(c->shared));
+ pa_hashmap_free(c->shared, NULL, NULL);
+
pa_subscription_free_all(c);
if (c->exit_event)
@@ -198,8 +207,6 @@ static void core_free(pa_object *o) {
pa_silence_cache_done(&c->silence_cache);
pa_mempool_free(c->mempool);
- pa_shared_cleanup(c);
-
for (j = 0; j < PA_CORE_HOOK_MAX; j++)
pa_hook_done(&c->hooks[j]);
diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index b349c6fc..2b8f819b 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -112,7 +112,7 @@ struct pa_core {
/* Some hashmaps for all sorts of entities */
pa_hashmap *namereg, *shared;
- /* The name of the default sink/source */
+ /* The default sink/source */
pa_source *default_source;
pa_sink *default_sink;
@@ -129,13 +129,12 @@ struct pa_core {
pa_mempool *mempool;
pa_silence_cache silence_cache;
- int exit_idle_time, scache_idle_time;
- pa_bool_t flat_volumes;
-
pa_time_event *exit_event;
-
pa_time_event *scache_auto_unload_event;
+ int exit_idle_time, scache_idle_time;
+
+ pa_bool_t flat_volumes:1;
pa_bool_t disallow_module_loading:1;
pa_bool_t disallow_exit:1;
pa_bool_t running_as_daemon:1;
diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c
index d470bb0b..1eb70c8e 100644
--- a/src/pulsecore/module.c
+++ b/src/pulsecore/module.c
@@ -75,7 +75,7 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
m->load_once = load_once();
- if (m->load_once && c->modules) {
+ if (m->load_once) {
pa_module *i;
uint32_t idx;
/* OK, the module only wants to be loaded once, let's make sure it is */
@@ -105,9 +105,6 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
goto fail;
}
- if (!c->modules)
- c->modules = pa_idxset_new(NULL, NULL);
-
pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0);
pa_assert(m->index != PA_IDXSET_INVALID);
@@ -200,17 +197,11 @@ void pa_module_unload_by_index(pa_core *c, uint32_t idx, pa_bool_t force) {
}
void pa_module_unload_all(pa_core *c) {
+ pa_module *m;
pa_assert(c);
- if (c->modules) {
- pa_module *m;
-
- while ((m = pa_idxset_steal_first(c->modules, NULL)))
- pa_module_free(m);
-
- pa_idxset_free(c->modules, NULL, NULL);
- c->modules = NULL;
- }
+ while ((m = pa_idxset_steal_first(c->modules, NULL)))
+ pa_module_free(m);
if (c->module_defer_unload_event) {
c->mainloop->defer_free(c->module_defer_unload_event);
@@ -226,9 +217,6 @@ static void defer_cb(pa_mainloop_api*api, pa_defer_event *e, void *userdata) {
pa_core_assert_ref(c);
api->defer_enable(e, 0);
- if (!c->modules)
- return;
-
while ((m = pa_idxset_iterate(c->modules, &state, NULL)))
if (m->unload_requested)
pa_module_unload(c, m, TRUE);
diff --git a/src/pulsecore/namereg.c b/src/pulsecore/namereg.c
index f3d5a8f8..ac456ac7 100644
--- a/src/pulsecore/namereg.c
+++ b/src/pulsecore/namereg.c
@@ -87,16 +87,6 @@ char* pa_namereg_make_valid_name(const char *name) {
return n;
}
-void pa_namereg_free(pa_core *c) {
- pa_assert(c);
-
- if (!c->namereg)
- return;
-
- pa_assert(pa_hashmap_size(c->namereg) == 0);
- pa_hashmap_free(c->namereg, NULL, NULL);
-}
-
const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t type, void *data, pa_bool_t fail) {
struct namereg_entry *e;
char *n = NULL;
@@ -118,9 +108,6 @@ const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t
return NULL;
}
- if (!c->namereg)
- c->namereg = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
-
if ((e = pa_hashmap_get(c->namereg, name)) && fail) {
pa_xfree(n);
return NULL;
@@ -210,7 +197,7 @@ void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type) {
if (*name == '@' || !name || !pa_namereg_is_valid_name(name))
return NULL;
- if (c->namereg && (e = pa_hashmap_get(c->namereg, name)))
+ if ((e = pa_hashmap_get(c->namereg, name)))
if (e->type == type)
return e->data;
diff --git a/src/pulsecore/namereg.h b/src/pulsecore/namereg.h
index b91dd52d..ff99525e 100644
--- a/src/pulsecore/namereg.h
+++ b/src/pulsecore/namereg.h
@@ -34,8 +34,6 @@ typedef enum pa_namereg_type {
PA_NAMEREG_CARD
} pa_namereg_type_t;
-void pa_namereg_free(pa_core *c);
-
const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t type, void *data, pa_bool_t fail);
void pa_namereg_unregister(pa_core *c, const char *name);
void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type);
diff --git a/src/pulsecore/shared.c b/src/pulsecore/shared.c
index d6e42dd8..9485dc33 100644
--- a/src/pulsecore/shared.c
+++ b/src/pulsecore/shared.c
@@ -99,32 +99,6 @@ int pa_shared_remove(pa_core *c, const char *name) {
return 0;
}
-void pa_shared_init(pa_core *c) {
- pa_assert(c);
-
- c->shared = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
-}
-
-void pa_shared_cleanup(pa_core *c) {
- pa_assert(c);
-
- if (!c->shared)
- return;
-
- if (!pa_hashmap_isempty(c->shared)) {
- pa_strbuf *s = pa_strbuf_new();
-
- pa_shared_dump(c, s);
- pa_log_debug("%s", pa_strbuf_tostring(s));
- pa_strbuf_free(s);
- pa_assert(pa_hashmap_isempty(c->shared));
- }
-
- pa_hashmap_free(c->shared, NULL, NULL);
- c->shared = NULL;
-
-}
-
void pa_shared_dump(pa_core *c, pa_strbuf *s) {
void *state = NULL;
pa_shared *p;
diff --git a/src/pulsecore/shared.h b/src/pulsecore/shared.h
index dd3f94e2..f6f8d3cf 100644
--- a/src/pulsecore/shared.h
+++ b/src/pulsecore/shared.h
@@ -49,12 +49,6 @@ int pa_shared_remove(pa_core *c, const char *name);
/* A combination of pa_shared_remove() and pa_shared_set() */
int pa_shared_replace(pa_core *c, const char *name, void *data);
-/* Free all memory used by the shared property system */
-void pa_shared_cleanup(pa_core *c);
-
-/* 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);