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);
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) {
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);
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;
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
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);
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)
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]);
/* 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;
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;
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 */
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);
}
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);
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);
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;
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;
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;
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);
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;
/* 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);