remove global exported variables:
[profile/ivi/pulseaudio.git] / src / core.c
1 #include <stdlib.h>
2 #include <assert.h>
3 #include <stdio.h>
4
5 #include "core.h"
6 #include "module.h"
7 #include "sink.h"
8 #include "source.h"
9 #include "namereg.h"
10 #include "util.h"
11
12 struct pa_core* pa_core_new(struct pa_mainloop_api *m) {
13     struct pa_core* c;
14     c = malloc(sizeof(struct pa_core));
15     assert(c);
16
17     c->mainloop = m;
18     c->clients = pa_idxset_new(NULL, NULL);
19     c->sinks = pa_idxset_new(NULL, NULL);
20     c->sources = pa_idxset_new(NULL, NULL);
21     c->source_outputs = pa_idxset_new(NULL, NULL);
22     c->sink_inputs = pa_idxset_new(NULL, NULL);
23
24     c->default_source_index = c->default_sink_index = PA_IDXSET_INVALID;
25
26     c->modules = NULL;
27     c->namereg = NULL;
28
29     c->default_sample_spec.format = PA_SAMPLE_S16NE;
30     c->default_sample_spec.rate = 44100;
31     c->default_sample_spec.channels = 2;
32     
33     pa_check_for_sigpipe();
34     
35     return c;
36 };
37
38 void pa_core_free(struct pa_core *c) {
39     assert(c);
40
41     pa_module_unload_all(c);
42     assert(!c->modules);
43     
44     assert(pa_idxset_isempty(c->clients));
45     pa_idxset_free(c->clients, NULL, NULL);
46     
47     assert(pa_idxset_isempty(c->sinks));
48     pa_idxset_free(c->sinks, NULL, NULL);
49
50     assert(pa_idxset_isempty(c->sources));
51     pa_idxset_free(c->sources, NULL, NULL);
52     
53     assert(pa_idxset_isempty(c->source_outputs));
54     pa_idxset_free(c->source_outputs, NULL, NULL);
55     
56     assert(pa_idxset_isempty(c->sink_inputs));
57     pa_idxset_free(c->sink_inputs, NULL, NULL);
58
59     pa_namereg_free(c);
60     
61     free(c);    
62 };
63