1 | //roaraudio.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011 |
---|
5 | * |
---|
6 | * This file is 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 Lesser 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 Lesser General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU Lesser 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 | * NOTE: Even though this file is LGPLed it (may) include GPLed files |
---|
25 | * so the license of this file is/may therefore downgraded to GPL. |
---|
26 | * See HACKING for details. |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef _ROARAUDIO_H_ |
---|
30 | #define _ROARAUDIO_H_ |
---|
31 | |
---|
32 | #define _ROAR_MKVERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) |
---|
33 | |
---|
34 | #include <roaraudio/config.h> |
---|
35 | #include <roaraudio/targethacks.h> |
---|
36 | #include <roaraudio/muconthacks.h> |
---|
37 | #include <roaraudio/win32hacks.h> // we include this at the beginning of the file |
---|
38 | // so we can define well known standard types known to everyone |
---|
39 | // and everywhere but win32 here |
---|
40 | |
---|
41 | // consts we need to set depending on the OS and features: |
---|
42 | #if defined(ROAR_NEED_GNU_SOURCE) && !defined(_GNU_SOURCE) |
---|
43 | #define _GNU_SOURCE |
---|
44 | #endif |
---|
45 | |
---|
46 | #if defined(ROAR_NEED_BSD_VISIBLE) && !defined(__BSD_VISIBLE) |
---|
47 | #define __BSD_VISIBLE 1 |
---|
48 | #endif |
---|
49 | |
---|
50 | #ifdef ROAR_HAVE_H_STDINT |
---|
51 | #include <stdint.h> |
---|
52 | #endif |
---|
53 | |
---|
54 | #include <stdlib.h> |
---|
55 | |
---|
56 | #ifdef ROAR_HAVE_H_UNISTD |
---|
57 | #include <unistd.h> |
---|
58 | #endif |
---|
59 | |
---|
60 | #include <stdio.h> |
---|
61 | #include <string.h> |
---|
62 | #include <errno.h> |
---|
63 | |
---|
64 | #ifdef ROAR_HAVE_H_SYS_TYPES |
---|
65 | #include <sys/types.h> |
---|
66 | #endif |
---|
67 | |
---|
68 | #include <limits.h> |
---|
69 | #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) |
---|
70 | #include <sys/mman.h> |
---|
71 | #endif |
---|
72 | |
---|
73 | // TODO: can we move the next block into roard specific includes? |
---|
74 | #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) |
---|
75 | #include <grp.h> |
---|
76 | #include <pwd.h> |
---|
77 | #include <sys/stat.h> |
---|
78 | #endif |
---|
79 | |
---|
80 | #ifdef ROAR_TARGET_WIN32 |
---|
81 | #include <winsock2.h> |
---|
82 | #else /* ROAR_TARGET_WIN32 */ |
---|
83 | #ifdef ROAR_HAVE_BSDSOCKETS |
---|
84 | |
---|
85 | #if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6) |
---|
86 | #include <arpa/inet.h> |
---|
87 | #endif |
---|
88 | |
---|
89 | #ifdef ROAR_HAVE_H_SYS_SOCKET |
---|
90 | #include <sys/socket.h> |
---|
91 | #endif |
---|
92 | |
---|
93 | #ifdef ROAR_HAVE_IPV4 |
---|
94 | #include <netinet/in.h> |
---|
95 | #include <netinet/tcp.h> |
---|
96 | #endif |
---|
97 | #ifdef ROAR_HAVE_UNIX |
---|
98 | #include <sys/un.h> |
---|
99 | #endif |
---|
100 | |
---|
101 | #endif /* ROAR_HAVE_BSDSOCKETS */ |
---|
102 | #endif /* ROAR_TARGET_WIN32 */ |
---|
103 | |
---|
104 | #ifdef __NetBSD__ |
---|
105 | #include <netinet/in_systm.h> |
---|
106 | #endif |
---|
107 | |
---|
108 | #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) |
---|
109 | #include <netdb.h> |
---|
110 | #endif |
---|
111 | |
---|
112 | // NOTE: we need this macro in some of our header files. |
---|
113 | // TODO: This is oubslute, we will remove it soon. |
---|
114 | #if INT_MAX >= 32767 |
---|
115 | #define roar_intm16 int |
---|
116 | #define roar_uintm16 unsigned int |
---|
117 | #else |
---|
118 | #define roar_intm16 int16_t |
---|
119 | #define roar_uintm16 uint16_t |
---|
120 | #endif |
---|
121 | |
---|
122 | // this is to avoid warning messages on platforms |
---|
123 | // where sizeof(void*) == 8 and szeof(int) == 4 |
---|
124 | #ifdef __LP64__ |
---|
125 | #define ROAR_INSTINT long int |
---|
126 | #else |
---|
127 | #define ROAR_INSTINT int |
---|
128 | #endif |
---|
129 | |
---|
130 | #ifndef __BEGIN_DECLS |
---|
131 | #ifdef __cplusplus |
---|
132 | # define __BEGIN_DECLS extern "C" { |
---|
133 | # define __END_DECLS } |
---|
134 | #else |
---|
135 | # define __BEGIN_DECLS |
---|
136 | # define __END_DECLS |
---|
137 | #endif |
---|
138 | #endif |
---|
139 | |
---|
140 | __BEGIN_DECLS |
---|
141 | |
---|
142 | #include <roaraudio/proto.h> |
---|
143 | #include <roaraudio/caps.h> |
---|
144 | #include <roaraudio/error.h> |
---|
145 | #include <roaraudio/audio.h> |
---|
146 | #include <roaraudio/stream.h> |
---|
147 | #include <roaraudio/client.h> |
---|
148 | #include <roaraudio/sample.h> |
---|
149 | #include <roaraudio/beep.h> |
---|
150 | #include <roaraudio/meta.h> |
---|
151 | #include <roaraudio/genre.h> |
---|
152 | #include <roaraudio/acl.h> |
---|
153 | #include <roaraudio/misc.h> |
---|
154 | #include <roaraudio/byteorder.h> |
---|
155 | #include <roaraudio/socket.h> |
---|
156 | #include <roaraudio/ltm.h> |
---|
157 | #include <roaraudio/notify.h> |
---|
158 | |
---|
159 | #include <libroar/libroar.h> |
---|
160 | |
---|
161 | // Some glocal network defaults: |
---|
162 | #ifndef ROAR_NET_INET4_LOCALHOST |
---|
163 | #define ROAR_NET_INET4_LOCALHOST "localhost" |
---|
164 | #endif |
---|
165 | #ifndef ROAR_NET_INET4_ANYHOST |
---|
166 | #define ROAR_NET_INET4_ANYHOST "0.0.0.0" |
---|
167 | #endif |
---|
168 | |
---|
169 | #ifndef ROAR_NET_INET6_LOCALHOST |
---|
170 | #define ROAR_NET_INET6_LOCALHOST "ipv6-localhost" |
---|
171 | #endif |
---|
172 | #ifndef ROAR_NET_INET6_ANYHOST |
---|
173 | #define ROAR_NET_INET6_ANYHOST "::" |
---|
174 | #endif |
---|
175 | |
---|
176 | // IP: |
---|
177 | #define ROAR_DEFAULT_PORT 16002 |
---|
178 | |
---|
179 | // IPv4 |
---|
180 | #define ROAR_DEFAULT_INET4_PORT ROAR_DEFAULT_PORT |
---|
181 | #define ROAR_DEFAULT_INET4_HOST ROAR_NET_INET4_LOCALHOST |
---|
182 | // aliases: |
---|
183 | #define ROAR_DEFAULT_HOST ROAR_DEFAULT_INET4_HOST |
---|
184 | |
---|
185 | // IPv6: |
---|
186 | #define ROAR_DEFAULT_INET6_PORT ROAR_DEFAULT_PORT |
---|
187 | #define ROAR_DEFAULT_INET6_HOST ROAR_NET_INET6_LOCALHOST |
---|
188 | |
---|
189 | // UNIX Domain Sockets |
---|
190 | #define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar" |
---|
191 | #define ROAR_DEFAULT_SOCK_USER ".roar" |
---|
192 | |
---|
193 | // DECnet |
---|
194 | #define ROAR_DEFAULT_OBJECT "roar" |
---|
195 | #define ROAR_DEFAULT_NUM 0 |
---|
196 | #define ROAR_DEFAULT_LISTEN_OBJECT "::" ROAR_DEFAULT_OBJECT |
---|
197 | |
---|
198 | // now handled by configure: |
---|
199 | //#define ROAR_DEFAULT_SOCKGRP "audio" |
---|
200 | |
---|
201 | |
---|
202 | // defines for emulations: |
---|
203 | // ESD: |
---|
204 | #define ROAR_DEFAULT_ESD_GSOCK "/tmp/.esd/socket" |
---|
205 | #define ROAR_DEFAULT_ESD_PORT 16001 |
---|
206 | // RSound: |
---|
207 | #define ROAR_DEFAULT_RSOUND_GSOCK "/tmp/rsound" |
---|
208 | #define ROAR_DEFAULT_RSOUND_PORT 12345 |
---|
209 | #define ROAR_DEFAULT_RSOUND_OBJECT "::rsound" |
---|
210 | // PulseAudio: |
---|
211 | #define ROAR_DEFAULT_PA_PORT 4712 |
---|
212 | // RPlay: |
---|
213 | #define ROAR_DEFAULT_RPLAY_PORT 5556 |
---|
214 | // Gopher: |
---|
215 | #define ROAR_DEFAULT_GOPHER_PORT 70 |
---|
216 | // WWW/HTTP: |
---|
217 | #define ROAR_DEFAULT_HTTP_PORT 80 |
---|
218 | |
---|
219 | #if defined(ROAR_HAVE_LIBWSOCK32) && defined(ROAR_HAVE_LIBWS2_32) |
---|
220 | #define ROAR_LIBS_WIN32 " -lwsock32 -lws2_32" |
---|
221 | #else |
---|
222 | #define ROAR_LIBS_WIN32 "" |
---|
223 | #endif |
---|
224 | |
---|
225 | #ifdef ROAR_HAVE_LIBSOCKET |
---|
226 | #define ROAR_LIBS_LIBSOCKET " -lsocket" |
---|
227 | #else |
---|
228 | #define ROAR_LIBS_LIBSOCKET "" |
---|
229 | #endif |
---|
230 | |
---|
231 | #ifdef ROAR_HAVE_LIBSENDFILE |
---|
232 | #define ROAR_LIBS_LIBSENDFILE " -lsendfile" |
---|
233 | #else |
---|
234 | #define ROAR_LIBS_LIBSENDFILE "" |
---|
235 | #endif |
---|
236 | |
---|
237 | #define ROAR_LIBS_NET_LIBS ROAR_LIBS_LIBSOCKET ROAR_LIBS_WIN32 |
---|
238 | |
---|
239 | #define ROAR_LIBS "-lroar" ROAR_LIBS_LIBSENDFILE ROAR_LIBS_NET_LIBS |
---|
240 | #define ROAR_LIBS_DSP "-lroardsp " ROAR_LIBS |
---|
241 | #define ROAR_LIBS_MIDI "-lroarmidi " ROAR_LIBS_DSP |
---|
242 | #define ROAR_LIBS_LIGHT "-lroarlight " ROAR_LIBS |
---|
243 | #define ROAR_LIBS_EIO "-lroareio " ROAR_LIBS |
---|
244 | #define ROAR_CFLAGS "" |
---|
245 | |
---|
246 | // comp libs: |
---|
247 | #define ROAR_LIBS_C_ESD "-lroaresd " ROAR_LIBS |
---|
248 | #define ROAR_LIBS_C_ARTSC "-lroarartsc " ROAR_LIBS |
---|
249 | #define ROAR_LIBS_C_PULSE "-lroarpulse " ROAR_LIBS |
---|
250 | #define ROAR_LIBS_C_PULSE_SIMPLE "-lroarpulse-simple " ROAR_LIBS_C_PULSE |
---|
251 | #define ROAR_LIBS_C_SNDIO "-lroarsndio " ROAR_LIBS |
---|
252 | #define ROAR_LIBS_C_YIFF "-lroaryiff " ROAR_LIBS |
---|
253 | |
---|
254 | //some basic macros: |
---|
255 | #define ROAR_STDIN 0 |
---|
256 | #define ROAR_STDOUT 1 |
---|
257 | #define ROAR_STDERR 2 |
---|
258 | |
---|
259 | #define ROAR_DEBUG_OUTFH stderr |
---|
260 | |
---|
261 | #ifndef ROAR_DBG_PREFIX |
---|
262 | #define ROAR_DBG_PREFIX "roaraudio" |
---|
263 | #endif |
---|
264 | |
---|
265 | #define ROAR_DBG_FULLPREFIX "(" ROAR_DBG_PREFIX ": " __FILE__ ":%i): " |
---|
266 | |
---|
267 | // some default info levels: |
---|
268 | #define ROAR_DBG_INFO_NONE 0 |
---|
269 | #define ROAR_DBG_INFO_NOTICE 1 |
---|
270 | #define ROAR_DBG_INFO_INFO 2 |
---|
271 | #define ROAR_DBG_INFO_VERBOSE 3 |
---|
272 | |
---|
273 | #if !defined(__GNUC__) |
---|
274 | #define ROAR_DBG(format, ...) |
---|
275 | #define ROAR_ERR(format, ...) |
---|
276 | #define ROAR_WARN(format, ...) |
---|
277 | #define ROAR_INFO(format, level, ...) |
---|
278 | #elif __GNUC__ < 3 |
---|
279 | #define ROAR_DBG(format, args...) |
---|
280 | #define ROAR_ERR(format, args...) |
---|
281 | #define ROAR_WARN(format, args...) |
---|
282 | #define ROAR_INFO(format, level, args...) |
---|
283 | #else |
---|
284 | |
---|
285 | #ifdef DEBUG |
---|
286 | #define ROAR_DBG(format, args...) roar_debug_msg(ROAR_DEBUG_TYPE_DEBUG, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
287 | #else |
---|
288 | #define ROAR_DBG(format, args...) |
---|
289 | #endif |
---|
290 | |
---|
291 | #define ROAR_ERR(format, args...) roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
292 | #define ROAR_WARN(format, args...) roar_debug_msg(ROAR_DEBUG_TYPE_WARNING, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
293 | |
---|
294 | // INFO function: |
---|
295 | #ifdef DEBUG |
---|
296 | #define ROAR_INFO(format, level, args...) roar_debug_msg(ROAR_DEBUG_TYPE_INFO, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
297 | #elif defined(ROAR_DBG_INFOVAR) |
---|
298 | #define ROAR_INFO(format, level, args...) if ( (ROAR_DBG_INFOVAR) >= (level) ) roar_debug_msg(ROAR_DEBUG_TYPE_INFO, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
299 | #else |
---|
300 | #define ROAR_INFO(format, level, args...) |
---|
301 | #endif |
---|
302 | |
---|
303 | #endif |
---|
304 | |
---|
305 | #ifdef ROAR_HAVE_SAFE_OVERFLOW |
---|
306 | #define ROAR_MATH_OVERFLOW_ADD(a, b) ((a)+(b)) |
---|
307 | #else |
---|
308 | #define ROAR_MATH_OVERFLOW_ADD(a, b) ((4294967295U - (a)) + 1 + (b)) |
---|
309 | #endif |
---|
310 | |
---|
311 | #ifdef ROAR_HAVE_STRCASESTR |
---|
312 | #define _roar_strcasestr(a,b) strcasestr((a), (b)) |
---|
313 | #else |
---|
314 | #define _roar_strcasestr(a,b) NULL |
---|
315 | #endif |
---|
316 | |
---|
317 | __END_DECLS |
---|
318 | |
---|
319 | #endif |
---|
320 | |
---|
321 | //ll |
---|