]> code.delx.au - pulseaudio/blob - polyp/core.c
add initial glib mainloop adapter
[pulseaudio] / polyp / core.c
1 /* $Id$ */
2
3 /***
4 This file is part of polypaudio.
5
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
10
11 polypaudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA.
20 ***/
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <stdlib.h>
27 #include <assert.h>
28 #include <stdio.h>
29
30 #include "core.h"
31 #include "module.h"
32 #include "sink.h"
33 #include "source.h"
34 #include "namereg.h"
35 #include "util.h"
36 #include "scache.h"
37 #include "autoload.h"
38 #include "xmalloc.h"
39
40 struct pa_core* pa_core_new(struct pa_mainloop_api *m) {
41 struct pa_core* c;
42 c = pa_xmalloc(sizeof(struct pa_core));
43
44 c->mainloop = m;
45 c->clients = pa_idxset_new(NULL, NULL);
46 c->sinks = pa_idxset_new(NULL, NULL);
47 c->sources = pa_idxset_new(NULL, NULL);
48 c->source_outputs = pa_idxset_new(NULL, NULL);
49 c->sink_inputs = pa_idxset_new(NULL, NULL);
50
51 c->default_source_name = c->default_sink_name = NULL;
52
53 c->modules = NULL;
54 c->namereg = NULL;
55 c->scache_idxset = NULL;
56 c->scache_hashmap = NULL;
57
58 c->autoload_hashmap = NULL;
59
60 c->default_sample_spec.format = PA_SAMPLE_S16NE;
61 c->default_sample_spec.rate = 44100;
62 c->default_sample_spec.channels = 2;
63
64 c->auto_unload_time = 20;
65 c->auto_unload_event = NULL;
66
67 pa_check_for_sigpipe();
68
69 return c;
70 };
71
72 void pa_core_free(struct pa_core *c) {
73 assert(c);
74
75 pa_module_unload_all(c);
76 assert(!c->modules);
77
78 assert(pa_idxset_isempty(c->clients));
79 pa_idxset_free(c->clients, NULL, NULL);
80
81 assert(pa_idxset_isempty(c->sinks));
82 pa_idxset_free(c->sinks, NULL, NULL);
83
84 assert(pa_idxset_isempty(c->sources));
85 pa_idxset_free(c->sources, NULL, NULL);
86
87 assert(pa_idxset_isempty(c->source_outputs));
88 pa_idxset_free(c->source_outputs, NULL, NULL);
89
90 assert(pa_idxset_isempty(c->sink_inputs));
91 pa_idxset_free(c->sink_inputs, NULL, NULL);
92
93 pa_namereg_free(c);
94 pa_scache_free(c);
95 pa_autoload_free(c);
96
97 pa_xfree(c->default_source_name);
98 pa_xfree(c->default_sink_name);
99
100 pa_xfree(c);
101 };
102