source: roaraudio/include/roaraudio.h @ 4057:dcef746274cf

Last change on this file since 4057:dcef746274cf was 4057:dcef746274cf, checked in by phi, 14 years ago

added more networ consts

File size: 10.5 KB
Line 
1//roaraudio.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
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#include <roaraudio/config.h>
33#include <roaraudio/muconthacks.h>
34#include <roaraudio/win32hacks.h> // we include this at the beginning of the file
35                                  // so we can define well known standard types known to everyone
36                                  // and everywhere but win32 here
37
38// consts we need to set depending on the OS and features:
39#if defined(ROAR_NEED_GNU_SOURCE) && !defined(_GNU_SOURCE)
40#define _GNU_SOURCE
41#endif
42
43#if defined(ROAR_NEED_BSD_VISIBLE) && !defined(__BSD_VISIBLE)
44#define __BSD_VISIBLE 1
45#endif
46
47#include <stdint.h>
48#include <stdlib.h>
49
50#ifdef ROAR_HAVE_H_UNISTD
51#include <unistd.h>
52#endif
53
54#include <stdio.h>
55#include <string.h>
56#include <errno.h>
57
58#ifdef ROAR_HAVE_H_SYS_TYPES
59#include <sys/types.h>
60#endif
61
62#include <limits.h>
63#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
64#include <sys/mman.h>
65#endif
66
67// TODO: can we move the next block into roard specific includes?
68#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
69#include <grp.h>
70#include <pwd.h>
71#include <sys/stat.h>
72#endif
73
74#ifdef ROAR_TARGET_WIN32
75#include <winsock2.h>
76#else /* ROAR_TARGET_WIN32 */
77#ifdef ROAR_HAVE_BSDSOCKETS
78
79#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
80#include <arpa/inet.h>
81#endif
82
83#ifdef ROAR_HAVE_SELECT
84#include <sys/socket.h>
85#endif
86
87#ifdef ROAR_HAVE_IPV4
88#include <netinet/in.h>
89#include <netinet/tcp.h>
90#endif
91#ifdef ROAR_HAVE_UNIX
92#include <sys/un.h>
93#endif
94
95#endif /* ROAR_HAVE_BSDSOCKETS */
96#endif /* ROAR_TARGET_WIN32 */
97
98#ifdef __NetBSD__
99#include <netinet/in_systm.h>
100#endif
101
102#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
103#include <netdb.h>
104#endif
105
106// NOTE: we need this macro in some of our header files.
107// TODO: This is oubslute, we will remove it soon.
108#if INT_MAX >= 32767
109#define roar_intm16  int
110#define roar_uintm16 unsigned int
111#else
112#define roar_intm16  int16_t
113#define roar_uintm16 uint16_t
114#endif
115
116// this is to avoid warning messages on platforms
117// where sizeof(void*) == 8 and szeof(int) == 4
118#ifdef __LP64__
119#define ROAR_INSTINT long int
120#else
121#define ROAR_INSTINT int
122#endif
123
124#ifndef __BEGIN_DECLS
125#ifdef __cplusplus
126# define __BEGIN_DECLS extern "C" {
127# define __END_DECLS }
128#else
129# define __BEGIN_DECLS
130# define __END_DECLS
131#endif
132#endif
133
134__BEGIN_DECLS
135
136#include <roaraudio/proto.h>
137#include <roaraudio/error.h>
138#include <roaraudio/audio.h>
139#include <roaraudio/stream.h>
140#include <roaraudio/client.h>
141#include <roaraudio/sample.h>
142#include <roaraudio/meta.h>
143#include <roaraudio/genre.h>
144#include <roaraudio/acl.h>
145#include <roaraudio/misc.h>
146
147#include <libroar/libroar.h>
148
149// Some glocal network defaults:
150#ifndef ROAR_NET_INET4_LOCALHOST
151#define ROAR_NET_INET4_LOCALHOST "localhost"
152#endif
153#ifndef ROAR_NET_INET4_ANYHOST
154#define ROAR_NET_INET4_ANYHOST   "0.0.0.0"
155#endif
156
157#ifndef ROAR_NET_INET6_LOCALHOST
158#define ROAR_NET_INET6_LOCALHOST "ipv6-localhost"
159#endif
160#ifndef ROAR_NET_INET6_ANYHOST
161#define ROAR_NET_INET6_ANYHOST   "::"
162#endif
163
164// IP:
165#define ROAR_DEFAULT_PORT        16002
166
167// IPv4
168#define ROAR_DEFAULT_INET4_PORT  ROAR_DEFAULT_PORT
169#define ROAR_DEFAULT_INET4_HOST  ROAR_NET_INET4_LOCALHOST
170// aliases:
171#define ROAR_DEFAULT_HOST        ROAR_DEFAULT_INET4_HOST
172
173// IPv6:
174#define ROAR_DEFAULT_INET6_PORT  ROAR_DEFAULT_PORT
175#define ROAR_DEFAULT_INET6_HOST  ROAR_NET_INET6_LOCALHOST
176
177// UNIX Domain Sockets
178#define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar"
179#define ROAR_DEFAULT_SOCK_USER   ".roar"
180
181// DECnet
182#define ROAR_DEFAULT_OBJECT      "roar"
183#define ROAR_DEFAULT_NUM         0
184#define ROAR_DEFAULT_LISTEN_OBJECT "::" ROAR_DEFAULT_OBJECT
185
186// now handled by configure:
187//#define ROAR_DEFAULT_SOCKGRP     "audio"
188
189
190// defines for emulations:
191// ESD:
192#define ROAR_DEFAULT_ESD_GSOCK   "/tmp/.esd/socket"
193#define ROAR_DEFAULT_ESD_PORT    16001
194// RSound:
195#define ROAR_DEFAULT_RSOUND_GSOCK  "/tmp/rsound"
196#define ROAR_DEFAULT_RSOUND_PORT   12345
197#define ROAR_DEFAULT_RSOUND_OBJECT "::rsound"
198// PulseAudio:
199#define ROAR_DEFAULT_PA_PORT     4712
200// RPlay:
201#define ROAR_DEFAULT_RPLAY_PORT  5556
202
203#if defined(ROAR_HAVE_LIBWSOCK32) && defined(ROAR_HAVE_LIBWS2_32)
204#define ROAR_LIBS_WIN32          " -lwsock32 -lws2_32"
205#else
206#define ROAR_LIBS_WIN32          ""
207#endif
208
209#ifdef ROAR_HAVE_LIBSOCKET
210#define ROAR_LIBS_LIBSOCKET      " -lsocket"
211#else
212#define ROAR_LIBS_LIBSOCKET      ""
213#endif
214
215#ifdef ROAR_HAVE_LIBSENDFILE
216#define ROAR_LIBS_LIBSENDFILE    " -lsendfile"
217#else
218#define ROAR_LIBS_LIBSENDFILE    ""
219#endif
220
221#define ROAR_LIBS_NET_LIBS       ROAR_LIBS_LIBSOCKET ROAR_LIBS_WIN32
222
223#define ROAR_LIBS                "-lroar"       ROAR_LIBS_LIBSENDFILE ROAR_LIBS_NET_LIBS
224#define ROAR_LIBS_DSP            "-lroardsp "   ROAR_LIBS
225#define ROAR_LIBS_MIDI           "-lroarmidi "  ROAR_LIBS_DSP
226#define ROAR_LIBS_LIGHT          "-lroarlight " ROAR_LIBS
227#define ROAR_LIBS_EIO            "-lroareio "   ROAR_LIBS
228#define ROAR_CFLAGS              ""
229
230// comp libs:
231#define ROAR_LIBS_C_ESD          "-lroaresd "   ROAR_LIBS
232#define ROAR_LIBS_C_ARTSC        "-lroarartsc " ROAR_LIBS
233#define ROAR_LIBS_C_PULSE        "-lroarpulse " ROAR_LIBS
234#define ROAR_LIBS_C_PULSE_SIMPLE "-lroarpulse-simple " ROAR_LIBS_C_PULSE
235#define ROAR_LIBS_C_SNDIO        "-lroarsndio " ROAR_LIBS
236#define ROAR_LIBS_C_YIFF         "-lroaryiff "  ROAR_LIBS
237
238//some basic macros:
239#define ROAR_STDIN  0
240#define ROAR_STDOUT 1
241#define ROAR_STDERR 2
242
243#define ROAR_DEBUG_OUTFH stderr
244
245#ifdef ROAR_DBG_PREFIX
246#undef ROAR_DBG_PREFIX
247#endif
248#define ROAR_DBG_PREFIX "roaraudio"
249
250#define ROAR_DBG_FULLPREFIX "(" ROAR_DBG_PREFIX ": " __FILE__ ":%i): "
251
252// some default info levels:
253#define ROAR_DBG_INFO_NONE             0
254#define ROAR_DBG_INFO_NOTICE           1
255#define ROAR_DBG_INFO_INFO             2
256#define ROAR_DBG_INFO_VERBOSE          3
257
258#if __GNUC__ < 3
259 #define ROAR_DBG(format, args...)
260 #define ROAR_ERR(format, args...)
261 #define ROAR_WARN(format, args...)
262 #define ROAR_INFO(format, level, args...)
263#else
264
265#ifdef DEBUG
266 #define ROAR_DBG(format, args...)  roar_debug_msg(ROAR_DEBUG_TYPE_DEBUG, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args)
267#else
268 #define ROAR_DBG(format, args...)
269#endif
270
271#define ROAR_ERR(format, args...)  roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args)
272#define ROAR_WARN(format, args...) roar_debug_msg(ROAR_DEBUG_TYPE_WARNING, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args)
273
274// INFO function:
275#ifdef DEBUG
276 #define ROAR_INFO(format, level, args...) roar_debug_msg(ROAR_DEBUG_TYPE_INFO, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args)
277#elif defined(ROAR_DBG_INFOVAR)
278 #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)
279#else
280 #define ROAR_INFO(format, level, args...)
281#endif
282
283#endif
284
285#ifdef ROAR_HAVE_SAFE_OVERFLOW
286#define ROAR_MATH_OVERFLOW_ADD(a, b) ((a)+(b))
287#else
288#define ROAR_MATH_OVERFLOW_ADD(a, b) ((4294967295U - (a)) + 1 + (b))
289#endif
290
291#ifdef ROAR_HAVE_MLOCK
292#ifdef __linux__
293#define ROAR_MLOCK(p,s) mlock((p), (s))
294#else
295int _ROAR_MLOCK(const void *addr, size_t len);
296#define ROAR_MLOCK _ROAR_MLOCK
297#endif
298#endif
299
300#ifdef ROAR_HAVE_STRCASESTR
301#define _roar_strcasestr(a,b) strcasestr((a), (b))
302#else
303#define _roar_strcasestr(a,b) NULL
304#endif
305
306#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
307
308#ifdef ROAR_TARGET_WIN32
309#error This is nonsens. No win32 runs on a BE machine
310#endif
311
312#define ROAR_NET2HOST64(x) (x)
313#define ROAR_HOST2NET64(x) (x)
314#define ROAR_NET2HOST32(x) (x)
315#define ROAR_HOST2NET32(x) (x)
316#define ROAR_NET2HOST16(x) (x)
317#define ROAR_HOST2NET16(x) (x)
318
319#define ROAR_BE2HOST64(x) (x)
320#define ROAR_HOST2BE64(x) (x)
321#define ROAR_BE2HOST32(x) (x)
322#define ROAR_HOST2BE32(x) (x)
323#define ROAR_BE2HOST16(x) (x)
324#define ROAR_HOST2BE16(x) (x)
325
326#define ROAR_LE2HOST32(x) ROAR_dn_ntohl(x)
327#define ROAR_HOST2LE32(x) ROAR_dn_htonl(x)
328#define ROAR_LE2HOST16(x) ROAR_dn_ntohs(x)
329#define ROAR_HOST2LE16(x) ROAR_dn_htons(x)
330
331#ifdef ROAR_HAVE_LIBDNET
332#define ROAR_dn_ntohs(x) ((((x)&0x0ff)<<8) | (((x)&0xff00)>>8))
333#define ROAR_dn_ntohl(x) ( ((dn_ntohs((x)&0xffff))<<16) |\
334                           ((dn_ntohs(((x)>>16)))) )
335#define ROAR_dn_htonl(x) ROAR_dn_ntohl(x)
336#define ROAR_dn_htons(x) ROAR_dn_ntohs(x)
337#endif
338
339//#elif BYTE_ORDER == LITTLE_ENDIAN
340#else
341
342#if BYTE_ORDER == LITTLE_ENDIAN
343#define _ROAR_MOVE_BYTE(x,p) (((x) & (0xFFUL << (8*(p)))) >> (8*(p)) << (64-8*((p)+1)))
344#define ROAR_NET2HOST64(x) ROAR_HOST2NET64(x)
345#define ROAR_HOST2NET64(x) (_ROAR_MOVE_BYTE((x), 0) | _ROAR_MOVE_BYTE((x), 1) | \
346                            _ROAR_MOVE_BYTE((x), 2) | _ROAR_MOVE_BYTE((x), 3) | \
347                            _ROAR_MOVE_BYTE((x), 4) | _ROAR_MOVE_BYTE((x), 5) | \
348                            _ROAR_MOVE_BYTE((x), 6) | _ROAR_MOVE_BYTE((x), 7) | )
349#else
350/* PDP byte order */
351#endif
352
353#define ROAR_NET2HOST32(x) ntohl((x))
354#define ROAR_HOST2NET32(x) htonl((x))
355#define ROAR_NET2HOST16(x) ntohs((x))
356#define ROAR_HOST2NET16(x) htons((x))
357
358#define ROAR_BE2HOST32(x) ntohl(x)
359#define ROAR_HOST2BE32(x) htonl(x)
360#define ROAR_BE2HOST16(x) ntohs(x)
361#define ROAR_HOST2BE16(x) htons(x)
362
363#define ROAR_LE2HOST64(x) (x)
364#define ROAR_HOST2LE64(x) (x)
365#define ROAR_LE2HOST32(x) (x)
366#define ROAR_HOST2LE32(x) (x)
367#define ROAR_LE2HOST16(x) (x)
368#define ROAR_HOST2LE16(x) (x)
369
370#ifdef ROAR_HAVE_LIBDNET
371#if BYTE_ORDER == LITTLE_ENDIAN
372#define ROAR_dn_ntohs(x) (x)
373#define ROAR_dn_htons(x) (x)
374
375#define ROAR_dn_ntohl(x) (x)
376#define ROAR_dn_htonl(x) (x)
377#else
378#error can not build on this architecture with DECnet support enabled
379#endif
380#endif
381
382#endif
383
384__END_DECLS
385
386#endif
387
388//ll
Note: See TracBrowser for help on using the repository browser.