Branch data Line data Source code
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.1 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 : : #include <pulsecore/cpu.h>
28 : :
29 : : typedef struct pa_core pa_core;
30 : :
31 : : /* This is a bitmask that encodes the cause why a sink/source is
32 : : * suspended. */
33 : : typedef enum pa_suspend_cause {
34 : : PA_SUSPEND_USER = 1, /* Exposed to the user via some protocol */
35 : : PA_SUSPEND_APPLICATION = 2, /* Used by the device reservation logic */
36 : : PA_SUSPEND_IDLE = 4, /* Used by module-suspend-on-idle */
37 : : PA_SUSPEND_SESSION = 8, /* Used by module-hal for mark inactive sessions */
38 : : PA_SUSPEND_PASSTHROUGH = 16, /* Used to suspend monitor sources when the sink is in passthrough mode */
39 : : PA_SUSPEND_ALL = 0xFFFF /* Magic cause that can be used to resume forcibly */
40 : : } pa_suspend_cause_t;
41 : :
42 : : #include <pulsecore/idxset.h>
43 : : #include <pulsecore/hashmap.h>
44 : : #include <pulsecore/memblock.h>
45 : : #include <pulsecore/resampler.h>
46 : : #include <pulsecore/llist.h>
47 : : #include <pulsecore/hook-list.h>
48 : : #include <pulsecore/asyncmsgq.h>
49 : : #include <pulsecore/sample-util.h>
50 : : #include <pulsecore/sink.h>
51 : : #include <pulsecore/source.h>
52 : : #include <pulsecore/core-subscribe.h>
53 : : #include <pulsecore/msgobject.h>
54 : :
55 : : typedef enum pa_server_type {
56 : : PA_SERVER_TYPE_UNSET,
57 : : PA_SERVER_TYPE_USER,
58 : : PA_SERVER_TYPE_SYSTEM,
59 : : PA_SERVER_TYPE_NONE
60 : : } pa_server_type_t;
61 : :
62 : : typedef enum pa_core_state {
63 : : PA_CORE_STARTUP,
64 : : PA_CORE_RUNNING,
65 : : PA_CORE_SHUTDOWN
66 : : } pa_core_state_t;
67 : :
68 : : typedef enum pa_core_hook {
69 : : PA_CORE_HOOK_SINK_NEW,
70 : : PA_CORE_HOOK_SINK_FIXATE,
71 : : PA_CORE_HOOK_SINK_PUT,
72 : : PA_CORE_HOOK_SINK_UNLINK,
73 : : PA_CORE_HOOK_SINK_UNLINK_POST,
74 : : PA_CORE_HOOK_SINK_STATE_CHANGED,
75 : : PA_CORE_HOOK_SINK_PROPLIST_CHANGED,
76 : : PA_CORE_HOOK_SINK_PORT_CHANGED,
77 : : PA_CORE_HOOK_SOURCE_NEW,
78 : : PA_CORE_HOOK_SOURCE_FIXATE,
79 : : PA_CORE_HOOK_SOURCE_PUT,
80 : : PA_CORE_HOOK_SOURCE_UNLINK,
81 : : PA_CORE_HOOK_SOURCE_UNLINK_POST,
82 : : PA_CORE_HOOK_SOURCE_STATE_CHANGED,
83 : : PA_CORE_HOOK_SOURCE_PROPLIST_CHANGED,
84 : : PA_CORE_HOOK_SOURCE_PORT_CHANGED,
85 : : PA_CORE_HOOK_SINK_INPUT_NEW,
86 : : PA_CORE_HOOK_SINK_INPUT_FIXATE,
87 : : PA_CORE_HOOK_SINK_INPUT_PUT,
88 : : PA_CORE_HOOK_SINK_INPUT_UNLINK,
89 : : PA_CORE_HOOK_SINK_INPUT_UNLINK_POST,
90 : : PA_CORE_HOOK_SINK_INPUT_MOVE_START,
91 : : PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH,
92 : : PA_CORE_HOOK_SINK_INPUT_MOVE_FAIL,
93 : : PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED,
94 : : PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED,
95 : : PA_CORE_HOOK_SINK_INPUT_SEND_EVENT,
96 : : PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
97 : : PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE,
98 : : PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
99 : : PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK,
100 : : PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST,
101 : : PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_START,
102 : : PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FINISH,
103 : : PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FAIL,
104 : : PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED,
105 : : PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED,
106 : : PA_CORE_HOOK_SOURCE_OUTPUT_SEND_EVENT,
107 : : PA_CORE_HOOK_CLIENT_NEW,
108 : : PA_CORE_HOOK_CLIENT_PUT,
109 : : PA_CORE_HOOK_CLIENT_UNLINK,
110 : : PA_CORE_HOOK_CLIENT_PROPLIST_CHANGED,
111 : : PA_CORE_HOOK_CLIENT_SEND_EVENT,
112 : : PA_CORE_HOOK_CARD_NEW,
113 : : PA_CORE_HOOK_CARD_PUT,
114 : : PA_CORE_HOOK_CARD_UNLINK,
115 : : PA_CORE_HOOK_CARD_PROFILE_CHANGED,
116 : : PA_CORE_HOOK_PORT_AVAILABLE_CHANGED,
117 : : PA_CORE_HOOK_MAX
118 : : } pa_core_hook_t;
119 : :
120 : : /* The core structure of PulseAudio. Every PulseAudio daemon contains
121 : : * exactly one of these. It is used for storing kind of global
122 : : * variables for the daemon. */
123 : :
124 : : struct pa_core {
125 : : pa_msgobject parent;
126 : :
127 : : pa_core_state_t state;
128 : :
129 : : /* A random value which may be used to identify this instance of
130 : : * PulseAudio. Not cryptographically secure in any way. */
131 : : uint32_t cookie;
132 : :
133 : : pa_mainloop_api *mainloop;
134 : :
135 : : /* idxset of all kinds of entities */
136 : : pa_idxset *clients, *cards, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache;
137 : :
138 : : /* Some hashmaps for all sorts of entities */
139 : : pa_hashmap *namereg, *shared;
140 : :
141 : : /* The default sink/source */
142 : : pa_source *default_source;
143 : : pa_sink *default_sink;
144 : :
145 : : pa_channel_map default_channel_map;
146 : : pa_sample_spec default_sample_spec;
147 : : uint32_t alternate_sample_rate;
148 : : unsigned default_n_fragments, default_fragment_size_msec;
149 : : unsigned deferred_volume_safety_margin_usec;
150 : : int deferred_volume_extra_delay_usec;
151 : :
152 : : pa_defer_event *module_defer_unload_event;
153 : :
154 : : pa_defer_event *subscription_defer_event;
155 : : PA_LLIST_HEAD(pa_subscription, subscriptions);
156 : : PA_LLIST_HEAD(pa_subscription_event, subscription_event_queue);
157 : : pa_subscription_event *subscription_event_last;
158 : :
159 : : pa_mempool *mempool;
160 : : pa_silence_cache silence_cache;
161 : :
162 : : pa_time_event *exit_event;
163 : : pa_time_event *scache_auto_unload_event;
164 : :
165 : : int exit_idle_time, scache_idle_time;
166 : :
167 : : pa_bool_t flat_volumes:1;
168 : : pa_bool_t disallow_module_loading:1;
169 : : pa_bool_t disallow_exit:1;
170 : : pa_bool_t running_as_daemon:1;
171 : : pa_bool_t realtime_scheduling:1;
172 : : pa_bool_t disable_remixing:1;
173 : : pa_bool_t disable_lfe_remixing:1;
174 : : pa_bool_t deferred_volume:1;
175 : :
176 : : pa_resample_method_t resample_method;
177 : : int realtime_priority;
178 : :
179 : : pa_server_type_t server_type;
180 : : pa_cpu_info cpu_info;
181 : :
182 : : /* hooks */
183 : : pa_hook hooks[PA_CORE_HOOK_MAX];
184 : : };
185 : :
186 [ # # ][ # # ]: 0 : PA_DECLARE_PUBLIC_CLASS(pa_core);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
187 : : #define PA_CORE(o) pa_core_cast(o)
188 : :
189 : : enum {
190 : : PA_CORE_MESSAGE_UNLOAD_MODULE,
191 : : PA_CORE_MESSAGE_MAX
192 : : };
193 : :
194 : : pa_core* pa_core_new(pa_mainloop_api *m, pa_bool_t shared, size_t shm_size);
195 : :
196 : : /* Check whether no one is connected to this core */
197 : : void pa_core_check_idle(pa_core *c);
198 : :
199 : : int pa_core_exit(pa_core *c, pa_bool_t force, int retval);
200 : :
201 : : void pa_core_maybe_vacuum(pa_core *c);
202 : :
203 : : /* wrapper for c->mainloop->time_*() RT time events */
204 : : pa_time_event* pa_core_rttime_new(pa_core *c, pa_usec_t usec, pa_time_event_cb_t cb, void *userdata);
205 : : void pa_core_rttime_restart(pa_core *c, pa_time_event *e, pa_usec_t usec);
206 : :
207 : : #endif
|