1 | //roard.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2012 |
---|
5 | * |
---|
6 | * This file is part of roard a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * RoarAudio is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
22 | * Boston, MA 02110-1301, USA. |
---|
23 | * |
---|
24 | */ |
---|
25 | |
---|
26 | #ifndef _ROARD_H_ |
---|
27 | #define _ROARD_H_ |
---|
28 | |
---|
29 | // configure ROAR_INFO() |
---|
30 | extern int g_verbose; |
---|
31 | #define ROAR_DBG_INFOVAR g_verbose |
---|
32 | |
---|
33 | // configure ROAR_*() |
---|
34 | #define ROAR_DBG_PREFIX "roard" |
---|
35 | |
---|
36 | // need to include this first as we need the config |
---|
37 | #include <roaraudio.h> |
---|
38 | #include <roaraudio/units.h> |
---|
39 | #include <libroarlight/libroarlight.h> |
---|
40 | #include <libroareio/libroareio.h> |
---|
41 | |
---|
42 | #include <ctype.h> |
---|
43 | |
---|
44 | #ifdef ROAR_HAVE_H_SIGNAL |
---|
45 | #include <signal.h> |
---|
46 | #endif |
---|
47 | |
---|
48 | #if defined(ROAR_HAVE_SELECT) && defined(ROAR_HAVE_H_SYS_SELECT) |
---|
49 | #include <sys/select.h> |
---|
50 | #endif |
---|
51 | |
---|
52 | #ifdef ROAR_HAVE_WAIT |
---|
53 | #include <sys/wait.h> |
---|
54 | #endif |
---|
55 | |
---|
56 | #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) |
---|
57 | #include <pwd.h> |
---|
58 | #endif |
---|
59 | |
---|
60 | #ifdef ROAR_HAVE_H_SYS_TIME |
---|
61 | #include <sys/time.h> |
---|
62 | #endif |
---|
63 | #ifdef ROAR_HAVE_H_TIME |
---|
64 | #include <time.h> |
---|
65 | #endif |
---|
66 | |
---|
67 | #ifdef ROAR_HAVE_LIBSLP |
---|
68 | #include <slp.h> |
---|
69 | #endif |
---|
70 | |
---|
71 | /* |
---|
72 | #ifdef __linux__ |
---|
73 | #include <linux/unistd.h> |
---|
74 | #include <linux/ioprio.h> |
---|
75 | #endif |
---|
76 | */ |
---|
77 | |
---|
78 | #define ROAR_SUBSYS_NONE 0x00 |
---|
79 | #define ROAR_SUBSYS_WAVEFORM 0x01 |
---|
80 | #define ROAR_SUBSYS_MIDI 0x02 |
---|
81 | #define ROAR_SUBSYS_CB 0x04 |
---|
82 | #define ROAR_SUBSYS_LIGHT 0x08 |
---|
83 | #define ROAR_SUBSYS_RAW 0x10 |
---|
84 | #define ROAR_SUBSYS_COMPLEX 0x20 |
---|
85 | #define ROAR_SUBSYS_RDTCS 0x40 |
---|
86 | |
---|
87 | // listeing code: |
---|
88 | #define ROAR_MAX_LISTEN_SOCKETS 16 |
---|
89 | |
---|
90 | union uniinst { |
---|
91 | void * vp; |
---|
92 | int si; |
---|
93 | }; |
---|
94 | |
---|
95 | enum output_format { |
---|
96 | FORMAT_NATIVE = 1, |
---|
97 | FORMAT_WIKI, |
---|
98 | FORMAT_CSV, |
---|
99 | |
---|
100 | FORMAT_DEFAULT = FORMAT_NATIVE |
---|
101 | }; |
---|
102 | |
---|
103 | |
---|
104 | // MFOI = Marked For Optional Include |
---|
105 | |
---|
106 | //#include "buffer.h" |
---|
107 | #include "caps.h" |
---|
108 | #include "memlock.h" |
---|
109 | #include "codecfilter.h" /* MFOI */ |
---|
110 | #include "container_framework.h" /* MFOI */ |
---|
111 | #include "rolestack.h" |
---|
112 | #include "client.h" |
---|
113 | #include "auth.h" |
---|
114 | #include "driver.h" /* MFOI */ |
---|
115 | #include "output.h" |
---|
116 | #include "mixer.h" |
---|
117 | //#include "convert.h" |
---|
118 | #include "streams.h" |
---|
119 | #include "network.h" |
---|
120 | #include "commands.h" |
---|
121 | #include "req.h" |
---|
122 | #include "emul_esd.h" /* MFOI */ |
---|
123 | #include "emul_simple.h" /* MFOI */ |
---|
124 | #include "emul_rsound.h" /* MFOI */ |
---|
125 | #include "emul_rplay.h" /* MFOI */ |
---|
126 | #include "emul_gopher.h" /* MFOI */ |
---|
127 | #include "sources.h" |
---|
128 | #include "sample.h" |
---|
129 | #include "hwmixer.h" |
---|
130 | #include "meta.h" |
---|
131 | #include "midi.h" |
---|
132 | #include "ssynth.h" |
---|
133 | #include "light.h" |
---|
134 | #include "raw.h" |
---|
135 | #include "rdtcs.h" |
---|
136 | #include "waveform.h" |
---|
137 | #include "beep.h" |
---|
138 | #include "lib.h" |
---|
139 | #include "plugins.h" |
---|
140 | |
---|
141 | |
---|
142 | extern int alive; |
---|
143 | #ifdef ROAR_SUPPORT_LISTEN |
---|
144 | extern int g_no_listen; |
---|
145 | #endif |
---|
146 | |
---|
147 | extern uint32_t g_pos; // current position in output stream |
---|
148 | |
---|
149 | extern int g_standby; |
---|
150 | extern int g_autostandby; |
---|
151 | |
---|
152 | #ifdef ROAR_SUPPORT_LISTEN |
---|
153 | struct roard_listen; |
---|
154 | #endif |
---|
155 | |
---|
156 | int main_loop (struct roar_audio_info * sa, int sysclocksync); |
---|
157 | void cleanup_listen_socket (int terminate); |
---|
158 | void clean_quit (void); |
---|
159 | void clean_quit_prep (void); |
---|
160 | |
---|
161 | void on_sig_int (int signum); |
---|
162 | void on_sig_term (int signum); |
---|
163 | void on_sig_chld (int signum); |
---|
164 | void on_sig_usr1 (int signum); |
---|
165 | |
---|
166 | #ifdef ROAR_SUPPORT_LISTEN |
---|
167 | int get_listen(struct roard_listen ** sock, char *** sockname); |
---|
168 | int add_listen (char * addr, int port, int sock_type, char * user, char * group, int proto, int dir, struct roar_audio_info * info); |
---|
169 | #endif |
---|
170 | |
---|
171 | #ifdef ROAR_SUPPORT_LISTEN |
---|
172 | extern struct roard_listen { |
---|
173 | int used; |
---|
174 | struct roar_vio_calls sock; |
---|
175 | int proto; |
---|
176 | union { |
---|
177 | void * vp; |
---|
178 | int si; |
---|
179 | struct { |
---|
180 | int dir; |
---|
181 | struct roar_audio_info info; |
---|
182 | } stpl; |
---|
183 | } inst; |
---|
184 | } g_listen[ROAR_MAX_LISTEN_SOCKETS]; |
---|
185 | #endif |
---|
186 | |
---|
187 | extern int g_self_client; |
---|
188 | |
---|
189 | extern int g_terminate; |
---|
190 | |
---|
191 | extern struct roar_audio_info * g_sa, * g_max_sa; |
---|
192 | |
---|
193 | #define CONF_DEF_STRING "***default***" |
---|
194 | |
---|
195 | extern struct roard_config { |
---|
196 | uint32_t flags; |
---|
197 | struct { |
---|
198 | uint32_t flags; |
---|
199 | struct roar_mixer_settings mixer; |
---|
200 | int mixer_channels; |
---|
201 | } streams[ROAR_DIR_DIRIDS]; |
---|
202 | char * location; |
---|
203 | char * description; |
---|
204 | char * contact; |
---|
205 | char * serial; |
---|
206 | char * uiurl; |
---|
207 | size_t jumbo_mtu; |
---|
208 | int memlock_level; |
---|
209 | #ifdef ROAR_HAVE_SYSTEM |
---|
210 | struct { |
---|
211 | const char * post_shutdown; |
---|
212 | } scripts; |
---|
213 | #endif |
---|
214 | } * g_config; |
---|
215 | |
---|
216 | struct _counters { |
---|
217 | size_t clients, streams, |
---|
218 | samples, |
---|
219 | sources, outputs, |
---|
220 | mixers, bridges, |
---|
221 | listens; |
---|
222 | }; |
---|
223 | |
---|
224 | extern struct counters { |
---|
225 | struct _counters cur, sum; |
---|
226 | } g_counters; |
---|
227 | |
---|
228 | |
---|
229 | #define counters_init() memset(counters_getptr(), 0, sizeof(struct counters)) |
---|
230 | //#define counters_inc(c,i) do { signed long int __i = (i); if ( __i < 0 && __i > (g_counters.cur.c) ) { ROAR_WARN("counters_inc(c=%s, i=%li): Decrement request bigger than current counter value. Counter out of syn!", ) } while (0) |
---|
231 | #define counters_inc(c,i) do { signed long int __i = (i); counters_getptr()->cur.c += __i; if ( __i > 0 ) counters_getptr()->sum.c += __i; } while (0) |
---|
232 | |
---|
233 | #define counters_get(g,c) ((counters_getptr()->g.c)) |
---|
234 | |
---|
235 | struct counters * counters_getptr(void); |
---|
236 | void counters_print(int type, int force); |
---|
237 | |
---|
238 | #endif |
---|
239 | |
---|
240 | //ll |
---|