source: roaraudio/include/roaraudio.h @ 4783:fdc85d3177bd

Last change on this file since 4783:fdc85d3177bd was 4783:fdc85d3177bd, checked in by phi, 13 years ago

force ROAR_SUPPORT_TRAP to be defined if DEBUG is defined

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