]> code.delx.au - pulseaudio/blob - src/pulsecore/core.h
allow sending meta/policy events to clients
[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 typedef struct pa_core pa_core;
29
30 #include <pulsecore/idxset.h>
31 #include <pulsecore/hashmap.h>
32 #include <pulsecore/memblock.h>
33 #include <pulsecore/resampler.h>
34 #include <pulsecore/queue.h>
35 #include <pulsecore/llist.h>
36 #include <pulsecore/hook-list.h>
37 #include <pulsecore/asyncmsgq.h>
38 #include <pulsecore/sample-util.h>
39 #include <pulsecore/sink.h>
40 #include <pulsecore/source.h>
41 #include <pulsecore/core-subscribe.h>
42 #include <pulsecore/sink-input.h>
43 #include <pulsecore/msgobject.h>
44
45 typedef enum pa_core_state {
46 PA_CORE_STARTUP,
47 PA_CORE_RUNNING,
48 PA_CORE_SHUTDOWN
49 } pa_core_state_t;
50
51 typedef enum pa_core_hook {
52 PA_CORE_HOOK_SINK_NEW,
53 PA_CORE_HOOK_SINK_FIXATE,
54 PA_CORE_HOOK_SINK_PUT,
55 PA_CORE_HOOK_SINK_UNLINK,
56 PA_CORE_HOOK_SINK_UNLINK_POST,
57 PA_CORE_HOOK_SINK_STATE_CHANGED,
58 PA_CORE_HOOK_SINK_PROPLIST_CHANGED,
59 PA_CORE_HOOK_SOURCE_NEW,
60 PA_CORE_HOOK_SOURCE_FIXATE,
61 PA_CORE_HOOK_SOURCE_PUT,
62 PA_CORE_HOOK_SOURCE_UNLINK,
63 PA_CORE_HOOK_SOURCE_UNLINK_POST,
64 PA_CORE_HOOK_SOURCE_STATE_CHANGED,
65 PA_CORE_HOOK_SOURCE_PROPLIST_CHANGED,
66 PA_CORE_HOOK_SINK_INPUT_NEW,
67 PA_CORE_HOOK_SINK_INPUT_FIXATE,
68 PA_CORE_HOOK_SINK_INPUT_PUT,
69 PA_CORE_HOOK_SINK_INPUT_UNLINK,
70 PA_CORE_HOOK_SINK_INPUT_UNLINK_POST,
71 PA_CORE_HOOK_SINK_INPUT_MOVE_START,
72 PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH,
73 PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED,
74 PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED,
75 PA_CORE_HOOK_SINK_INPUT_SET_VOLUME,
76 PA_CORE_HOOK_SINK_INPUT_SEND_EVENT,
77 PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
78 PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE,
79 PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
80 PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK,
81 PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST,
82 PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_START,
83 PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FINISH,
84 PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED,
85 PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED,
86 PA_CORE_HOOK_SOURCE_OUTPUT_SEND_EVENT,
87 PA_CORE_HOOK_CLIENT_NEW,
88 PA_CORE_HOOK_CLIENT_PUT,
89 PA_CORE_HOOK_CLIENT_UNLINK,
90 PA_CORE_HOOK_CLIENT_PROPLIST_CHANGED,
91 PA_CORE_HOOK_CLIENT_SEND_EVENT,
92 PA_CORE_HOOK_CARD_NEW,
93 PA_CORE_HOOK_CARD_PUT,
94 PA_CORE_HOOK_CARD_UNLINK,
95 PA_CORE_HOOK_MAX
96 } pa_core_hook_t;
97
98 /* The core structure of PulseAudio. Every PulseAudio daemon contains
99 * exactly one of these. It is used for storing kind of global
100 * variables for the daemon. */
101
102 struct pa_core {
103 pa_msgobject parent;
104
105 pa_core_state_t state;
106
107 /* A random value which may be used to identify this instance of
108 * PulseAudio. Not cryptographically secure in any way. */
109 uint32_t cookie;
110
111 pa_mainloop_api *mainloop;
112
113 /* idxset of all kinds of entities */
114 pa_idxset *clients, *cards, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache;
115
116 /* Some hashmaps for all sorts of entities */
117 pa_hashmap *namereg, *shared;
118
119 /* The default sink/source */
120 pa_source *default_source;
121 pa_sink *default_sink;
122
123 pa_sample_spec default_sample_spec;
124 unsigned default_n_fragments, default_fragment_size_msec;
125
126 pa_defer_event *module_defer_unload_event;
127
128 pa_defer_event *subscription_defer_event;
129 PA_LLIST_HEAD(pa_subscription, subscriptions);
130 PA_LLIST_HEAD(pa_subscription_event, subscription_event_queue);
131 pa_subscription_event *subscription_event_last;
132
133 pa_mempool *mempool;
134 pa_silence_cache silence_cache;
135
136 pa_time_event *exit_event;
137 pa_time_event *scache_auto_unload_event;
138
139 int exit_idle_time, scache_idle_time;
140
141 pa_bool_t flat_volumes:1;
142 pa_bool_t disallow_module_loading:1;
143 pa_bool_t disallow_exit:1;
144 pa_bool_t running_as_daemon:1;
145 pa_bool_t realtime_scheduling:1;
146 pa_bool_t disable_remixing:1;
147 pa_bool_t disable_lfe_remixing:1;
148
149 pa_resample_method_t resample_method;
150 int realtime_priority;
151
152 /* hooks */
153 pa_hook hooks[PA_CORE_HOOK_MAX];
154 };
155
156 PA_DECLARE_CLASS(pa_core);
157 #define PA_CORE(o) pa_core_cast(o)
158
159 enum {
160 PA_CORE_MESSAGE_UNLOAD_MODULE,
161 PA_CORE_MESSAGE_MAX
162 };
163
164 pa_core* pa_core_new(pa_mainloop_api *m, pa_bool_t shared, size_t shm_size);
165
166 /* Check whether noone is connected to this core */
167 void pa_core_check_idle(pa_core *c);
168
169 int pa_core_exit(pa_core *c, pa_bool_t force, int retval);
170
171 #endif