5 This file is part of PulseAudio.
7 Copyright 2004-2006 Lennart Poettering
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.
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.
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
25 #include <pulse/mainloop-api.h>
26 #include <pulse/sample.h>
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>
38 typedef struct pa_core pa_core;
40 #include <pulsecore/core-subscribe.h>
41 #include <pulsecore/sink-input.h>
42 #include <pulsecore/msgobject.h>
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_SINK_SET_VOLUME,
53 PA_CORE_HOOK_SOURCE_NEW,
54 PA_CORE_HOOK_SOURCE_FIXATE,
55 PA_CORE_HOOK_SOURCE_PUT,
56 PA_CORE_HOOK_SOURCE_UNLINK,
57 PA_CORE_HOOK_SOURCE_UNLINK_POST,
58 PA_CORE_HOOK_SOURCE_STATE_CHANGED,
59 PA_CORE_HOOK_SOURCE_PROPLIST_CHANGED,
60 PA_CORE_HOOK_SINK_INPUT_NEW,
61 PA_CORE_HOOK_SINK_INPUT_FIXATE,
62 PA_CORE_HOOK_SINK_INPUT_PUT,
63 PA_CORE_HOOK_SINK_INPUT_UNLINK,
64 PA_CORE_HOOK_SINK_INPUT_UNLINK_POST,
65 PA_CORE_HOOK_SINK_INPUT_MOVE,
66 PA_CORE_HOOK_SINK_INPUT_MOVE_POST,
67 PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED,
68 PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED,
69 PA_CORE_HOOK_SINK_INPUT_SET_VOLUME,
70 PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
71 PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE,
72 PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
73 PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK,
74 PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST,
75 PA_CORE_HOOK_SOURCE_OUTPUT_MOVE,
76 PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_POST,
77 PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED,
78 PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED,
79 PA_CORE_HOOK_CLIENT_NEW,
80 PA_CORE_HOOK_CLIENT_PUT,
81 PA_CORE_HOOK_CLIENT_UNLINK,
82 PA_CORE_HOOK_CARD_NEW,
83 PA_CORE_HOOK_CARD_PUT,
84 PA_CORE_HOOK_CARD_UNLINK,
88 /* The core structure of PulseAudio. Every PulseAudio daemon contains
89 * exactly one of these. It is used for storing kind of global
90 * variables for the daemon. */
95 /* A random value which may be used to identify this instance of
96 * PulseAudio. Not cryptographically secure in any way. */
99 pa_mainloop_api *mainloop;
101 /* idxset of all kinds of entities */
102 pa_idxset *clients, *cards, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache;
104 /* Some hashmaps for all sorts of entities */
105 pa_hashmap *namereg, *shared;
107 /* The name of the default sink/source */
108 char *default_source_name, *default_sink_name;
110 pa_sample_spec default_sample_spec;
111 unsigned default_n_fragments, default_fragment_size_msec;
113 pa_defer_event *module_defer_unload_event;
115 pa_defer_event *subscription_defer_event;
116 PA_LLIST_HEAD(pa_subscription, subscriptions);
117 PA_LLIST_HEAD(pa_subscription_event, subscription_event_queue);
118 pa_subscription_event *subscription_event_last;
121 pa_silence_cache silence_cache;
123 int exit_idle_time, scache_idle_time;
125 pa_time_event *exit_event;
127 pa_time_event *scache_auto_unload_event;
129 pa_bool_t disallow_module_loading:1;
130 pa_bool_t disallow_exit:1;
131 pa_bool_t running_as_daemon:1;
132 pa_bool_t realtime_scheduling:1;
133 pa_bool_t disable_remixing:1;
134 pa_bool_t disable_lfe_remixing:1;
136 pa_resample_method_t resample_method;
137 int realtime_priority;
140 pa_hook hooks[PA_CORE_HOOK_MAX];
143 PA_DECLARE_CLASS(pa_core);
144 #define PA_CORE(o) pa_core_cast(o)
147 PA_CORE_MESSAGE_UNLOAD_MODULE,
151 pa_core* pa_core_new(pa_mainloop_api *m, pa_bool_t shared, size_t shm_size);
153 /* Check whether noone is connected to this core */
154 void pa_core_check_idle(pa_core *c);
156 int pa_core_exit(pa_core *c, pa_bool_t force, int retval);