a1fe7d977a3ff934e33b73d7c8fa6488780bb33e
[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     pa_check_for_sigpipe();
30     
31     return c;
32 };
33
34 void pa_core_free(struct pa_core *c) {
35     assert(c);
36
37     pa_module_unload_all(c);
38     assert(!c->modules);
39     
40     assert(pa_idxset_isempty(c->clients));
41     pa_idxset_free(c->clients, NULL, NULL);
42     
43     assert(pa_idxset_isempty(c->sinks));
44     pa_idxset_free(c->sinks, NULL, NULL);
45
46     assert(pa_idxset_isempty(c->sources));
47     pa_idxset_free(c->sources, NULL, NULL);
48     
49     assert(pa_idxset_isempty(c->source_outputs));
50     pa_idxset_free(c->source_outputs, NULL, NULL);
51     
52     assert(pa_idxset_isempty(c->sink_inputs));
53     pa_idxset_free(c->sink_inputs, NULL, NULL);
54
55     pa_namereg_free(c);
56     
57     free(c);    
58 };
59