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