source: roaraudio/include/roaraudio.h @ 4999:0663e148f769

Last change on this file since 4999:0663e148f769 was 4999:0663e148f769, checked in by phi, 13 years ago

corrected a missing cast

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