]> code.delx.au - pulseaudio/blob - src/pulsecore/core.h
fb4490f2fc0a5386484ce5e948c770e69add4f80
[pulseaudio] / src / pulsecore / core.h
1 #ifndef foocorehfoo
2 #define foocorehfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2004-2006 Lennart Poettering
8
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2 of the License,
12 or (at your option) any later version.
13
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
24
25 #include <pulse/mainloop-api.h>
26 #include <pulse/sample.h>
27
28 #include <pulsecore/idxset.h>
29 #include <pulsecore/hashmap.h>
30 #include <pulsecore/memblock.h>
31 #include <pulsecore/resampler.h>
32 #include <pulsecore/queue.h>
33 #include <pulsecore/llist.h>
34 #include <pulsecore/hook-list.h>
35 #include <pulsecore/asyncmsgq.h>
36 #include <pulsecore/sample-util.h>
37
38 typedef struct pa_core pa_core;
39
40 #include <pulsecore/core-subscribe.h>
41 #include <pulsecore/sink-input.h>
42 #include <pulsecore/msgobject.h>
43
44 typedef enum pa_core_hook {
45 PA_CORE_HOOK_SINK_NEW,
46 PA_CORE_HOOK_SINK_FIXATE,
47 PA_CORE_HOOK_SINK_PUT,
48 PA_CORE_HOOK_SINK_UNLINK,
49 PA_CORE_HOOK_SINK_UNLINK_POST,
50 PA_CORE_HOOK_SINK_STATE_CHANGED,
51 PA_CORE_HOOK_SINK_PROPLIST_CHANGED,
52 PA_CORE_HOOK_SOURCE_NEW,
53 PA_CORE_HOOK_SOURCE_FIXATE,
54 PA_CORE_HOOK_SOURCE_PUT,
55 PA_CORE_HOOK_SOURCE_UNLINK,
56 PA_CORE_HOOK_SOURCE_UNLINK_POST,
57 PA_CORE_HOOK_SOURCE_STATE_CHANGED,
58 PA_CORE_HOOK_SOURCE_PROPLIST_CHANGED,
59 PA_CORE_HOOK_SINK_INPUT_NEW,
60 PA_CORE_HOOK_SINK_INPUT_FIXATE,
61 PA_CORE_HOOK_SINK_INPUT_PUT,
62 PA_CORE_HOOK_SINK_INPUT_UNLINK,
63 PA_CORE_HOOK_SINK_INPUT_UNLINK_POST,
64 PA_CORE_HOOK_SINK_INPUT_MOVE,
65 PA_CORE_HOOK_SINK_INPUT_MOVE_POST,
66 PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED,
67 PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED,
68 PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
69 PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE,
70 PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
71 PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK,
72 PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST,
73 PA_CORE_HOOK_SOURCE_OUTPUT_MOVE,
74 PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_POST,
75 PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED,
76 PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED,
77 PA_CORE_HOOK_MAX
78 } pa_core_hook_t;
79
80 /* The core structure of PulseAudio. Every PulseAudio daemon contains
81 * exactly one of these. It is used for storing kind of global
82 * variables for the daemon. */
83
84 struct pa_core {
85 pa_msgobject parent;
86
87 /* A random value which may be used to identify this instance of
88 * PulseAudio. Not cryptographically secure in any way. */
89 uint32_t cookie;
90
91 pa_mainloop_api *mainloop;
92
93 /* idxset of all kinds of entities */
94 pa_idxset *clients, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache, *autoload_idxset;
95
96 /* Some hashmaps for all sorts of entities */
97 pa_hashmap *namereg, *autoload_hashmap, *shared;
98
99 /* The name of the default sink/source */
100 char *default_source_name, *default_sink_name;
101
102 pa_sample_spec default_sample_spec;
103 unsigned default_n_fragments, default_fragment_size_msec;
104
105 pa_time_event *module_auto_unload_event;
106 pa_defer_event *module_defer_unload_event;
107
108 pa_defer_event *subscription_defer_event;
109 PA_LLIST_HEAD(pa_subscription, subscriptions);
110 PA_LLIST_HEAD(pa_subscription_event, subscription_event_queue);
111 pa_subscription_event *subscription_event_last;
112
113 pa_mempool *mempool;
114 pa_silence_cache silence_cache;
115
116 int exit_idle_time, module_idle_time, scache_idle_time;
117
118 pa_time_event *exit_event;
119
120 pa_time_event *scache_auto_unload_event;
121
122 pa_bool_t disallow_module_loading:1;
123 pa_bool_t disallow_exit:1;
124 pa_bool_t running_as_daemon:1;
125 pa_bool_t realtime_scheduling:1;
126 pa_bool_t disable_remixing:1;
127 pa_bool_t disable_lfe_remixing:1;
128
129 pa_resample_method_t resample_method;
130 int realtime_priority;
131
132 /* hooks */
133 pa_hook hooks[PA_CORE_HOOK_MAX];
134 };
135
136 PA_DECLARE_CLASS(pa_core);
137 #define PA_CORE(o) pa_core_cast(o)
138
139 enum {
140 PA_CORE_MESSAGE_UNLOAD_MODULE,
141 PA_CORE_MESSAGE_MAX
142 };
143
144 pa_core* pa_core_new(pa_mainloop_api *m, int shared);
145
146 /* Check whether noone is connected to this core */
147 void pa_core_check_idle(pa_core *c);
148
149 int pa_core_exit(pa_core *c, pa_bool_t force, int retval);
150
151 #endif