7
7
PulseAudio is free software; you can redistribute it and/or modify
8
8
it under the terms of the GNU Lesser General Public License as published
9
by the Free Software Foundation; either version 2 of the License,
9
by the Free Software Foundation; either version 2.1 of the License,
10
10
or (at your option) any later version.
12
12
PulseAudio is distributed in the hope that it will be useful, but
37
37
#include <pulsecore/namereg.h>
38
38
#include <pulsecore/core-util.h>
39
39
#include <pulsecore/core-scache.h>
40
#include <pulsecore/autoload.h>
41
40
#include <pulsecore/core-subscribe.h>
42
41
#include <pulsecore/shared.h>
43
42
#include <pulsecore/random.h>
91
90
c->parent.parent.free = core_free;
92
91
c->parent.process_msg = core_process_msg;
93
c->state = PA_CORE_STARTUP;
95
96
c->clients = pa_idxset_new(NULL, NULL);
97
c->cards = pa_idxset_new(NULL, NULL);
96
98
c->sinks = pa_idxset_new(NULL, NULL);
97
99
c->sources = pa_idxset_new(NULL, NULL);
100
c->sink_inputs = pa_idxset_new(NULL, NULL);
98
101
c->source_outputs = pa_idxset_new(NULL, NULL);
99
c->sink_inputs = pa_idxset_new(NULL, NULL);
101
c->default_source_name = c->default_sink_name = NULL;
106
c->autoload_idxset = NULL;
107
c->autoload_hashmap = NULL;
108
c->running_as_daemon = FALSE;
102
c->modules = pa_idxset_new(NULL, NULL);
103
c->scache = pa_idxset_new(NULL, NULL);
105
c->namereg = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
106
c->shared = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
108
c->default_source = NULL;
109
c->default_sink = NULL;
110
111
c->default_sample_spec.format = PA_SAMPLE_S16NE;
111
112
c->default_sample_spec.rate = 44100;
112
113
c->default_sample_spec.channels = 2;
114
pa_channel_map_init_extend(&c->default_channel_map, c->default_sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
113
115
c->default_n_fragments = 4;
114
116
c->default_fragment_size_msec = 25;
116
c->module_auto_unload_event = NULL;
117
118
c->module_defer_unload_event = NULL;
118
119
c->scache_auto_unload_event = NULL;
128
129
c->exit_event = NULL;
130
131
c->exit_idle_time = -1;
131
c->module_idle_time = 20;
132
132
c->scache_idle_time = 20;
134
c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 3;
134
c->flat_volumes = TRUE;
136
135
c->disallow_module_loading = FALSE;
137
136
c->disallow_exit = FALSE;
137
c->running_as_daemon = FALSE;
138
138
c->realtime_scheduling = FALSE;
139
139
c->realtime_priority = 5;
140
140
c->disable_remixing = FALSE;
141
141
c->disable_lfe_remixing = FALSE;
142
c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 3;
143
144
for (j = 0; j < PA_CORE_HOOK_MAX; j++)
144
145
pa_hook_init(&c->hooks[j], c);
148
147
pa_random(&c->cookie, sizeof(c->cookie));
165
c->state = PA_CORE_SHUTDOWN;
164
167
pa_module_unload_all(c);
165
pa_assert(!c->modules);
168
pa_scache_free_all(c);
170
pa_assert(pa_idxset_isempty(c->scache));
171
pa_idxset_free(c->scache, NULL, NULL);
173
pa_assert(pa_idxset_isempty(c->modules));
174
pa_idxset_free(c->modules, NULL, NULL);
167
176
pa_assert(pa_idxset_isempty(c->clients));
168
177
pa_idxset_free(c->clients, NULL, NULL);
179
pa_assert(pa_idxset_isempty(c->cards));
180
pa_idxset_free(c->cards, NULL, NULL);
170
182
pa_assert(pa_idxset_isempty(c->sinks));
171
183
pa_idxset_free(c->sinks, NULL, NULL);
179
191
pa_assert(pa_idxset_isempty(c->sink_inputs));
180
192
pa_idxset_free(c->sink_inputs, NULL, NULL);
194
pa_assert(pa_hashmap_isempty(c->namereg));
195
pa_hashmap_free(c->namereg, NULL, NULL);
197
pa_assert(pa_hashmap_isempty(c->shared));
198
pa_hashmap_free(c->shared, NULL, NULL);
185
200
pa_subscription_free_all(c);
187
202
if (c->exit_event)
188
203
c->mainloop->time_free(c->exit_event);
190
pa_xfree(c->default_source_name);
191
pa_xfree(c->default_sink_name);
205
pa_assert(!c->default_source);
206
pa_assert(!c->default_sink);
193
208
pa_silence_cache_done(&c->silence_cache);
194
209
pa_mempool_free(c->mempool);
196
pa_shared_cleanup(c);
198
211
for (j = 0; j < PA_CORE_HOOK_MAX; j++)
199
212
pa_hook_done(&c->hooks[j]);
237
250
c->mainloop->quit(c->mainloop, retval);
254
void pa_core_maybe_vacuum(pa_core *c) {
257
if (!pa_idxset_isempty(c->sink_inputs) ||
258
!pa_idxset_isempty(c->source_outputs))
261
pa_log_debug("Hmm, no streams around, trying to vacuum.");
262
pa_mempool_vacuum(c->mempool);