source: roaraudio/include/roaraudio.h @ 1428:75c043e7f58d

Last change on this file since 1428:75c043e7f58d was 1428:75c043e7f58d, checked in by phi, 15 years ago

added muconthacks.h header to define some things not defined by microcontrollers needed by RoarAudio

File size: 6.2 KB
Line 
1//roaraudio.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008
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, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 *  NOTE: Even though this file is LGPLed it (may) include GPLed files
24 *  so the license of this file is/may therefore downgraded to GPL.
25 *  See HACKING for details.
26 */
27
28#ifndef _ROARAUDIO_H_
29#define _ROARAUDIO_H_
30
31#include <roaraudio/config.h>
32#include <roaraudio/muconthacks.h>
33#include <roaraudio/win32hacks.h> // we include this at the beginning of the file
34                                  // so we can define well known standard types known to everyone
35                                  // and everywhere but win32 here
36
37// consts we need to set depending on the OS and features:
38#if defined(ROAR_NEED_GNU_SOURCE) && !defined(_GNU_SOURCE)
39#define _GNU_SOURCE
40#endif
41
42#if defined(ROAR_NEED_BSD_VISIBLE) && !defined(__BSD_VISIBLE)
43#define __BSD_VISIBLE 1
44#endif
45
46#include <stdlib.h>
47
48#ifdef ROAR_HAVE_H_UNISTD
49#include <unistd.h>
50#endif
51
52#include <stdio.h>
53#include <string.h>
54#include <errno.h>
55
56#ifdef ROAR_HAVE_H_SYS_TYPES
57#include <sys/types.h>
58#endif
59
60#include <limits.h>
61#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
62#include <sys/mman.h>
63#endif
64
65// TODO: can we move the next block into roard specific includes?
66#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
67#include <grp.h>
68#include <pwd.h>
69#include <sys/stat.h>
70#endif
71
72#ifdef ROAR_TARGET_WIN32
73#include <winsock2.h>
74#else /* ROAR_TARGET_WIN32 */
75#ifdef ROAR_HAVE_BSDSOCKETS
76
77#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6)
78#include <arpa/inet.h>
79#endif
80
81#include <sys/socket.h>
82
83#ifdef ROAR_HAVE_IPV4
84#include <netinet/in.h>
85#include <netinet/tcp.h>
86#endif
87#ifdef ROAR_HAVE_UNIX
88#include <sys/un.h>
89#endif
90
91#endif /* ROAR_HAVE_BSDSOCKETS */
92#endif /* ROAR_TARGET_WIN32 */
93
94#ifdef __NetBSD__
95#include <netinet/in_systm.h>
96#endif
97
98#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER)
99#include <netdb.h>
100#endif
101
102// NOTE: we need this macro in some of our header files.
103#if INT_MAX >= 32767
104#define roar_intm16  int
105#define roar_uintm16 unsigned int
106#else
107#define roar_intm16  int16_t
108#define roar_uintm16 uint16_t
109#endif
110
111// this is to avoid warning messages on platforms
112// where sizeof(void*) == 8 and szeof(int) == 4
113#ifdef __LP64__
114#define ROAR_INSTINT long int
115#else
116#define ROAR_INSTINT int
117#endif
118
119#ifndef __BEGIN_DECLS
120#ifdef __cplusplus
121# define __BEGIN_DECLS extern "C" {
122# define __END_DECLS }
123#else
124# define __BEGIN_DECLS
125# define __END_DECLS
126#endif
127#endif
128
129__BEGIN_DECLS
130
131#include <roaraudio/proto.h>
132#include <roaraudio/error.h>
133#include <roaraudio/audio.h>
134#include <roaraudio/stream.h>
135#include <roaraudio/client.h>
136#include <roaraudio/sample.h>
137#include <roaraudio/meta.h>
138#include <roaraudio/acl.h>
139
140#include <libroar/libroar.h>
141
142// IP
143#define ROAR_DEFAULT_PORT        16002
144#define ROAR_DEFAULT_HOST        "localhost"
145
146// UNIX Domain Sockets
147#define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar"
148#define ROAR_DEFAULT_SOCK_USER   ".roar"
149
150// DECnet
151#define ROAR_DEFAULT_OBJECT      "roar"
152#define ROAR_DEFAULT_NUM         0
153#define ROAR_DEFAULT_LISTEN_OBJECT "::" ROAR_DEFAULT_OBJECT
154
155// now handled by condiguere
156//#define ROAR_DEFAULT_SOCKGRP     "audio"
157
158#define ROAR_LIBS                "-lroar"
159#define ROAR_CFLAGS              ""
160
161//some basic macros:
162#define ROAR_STDIN  0
163#define ROAR_STDOUT 1
164#define ROAR_STDERR 2
165
166#define ROAR_DEBUG_OUTFH stderr
167
168#ifdef ROAR_DBG_PREFIX
169#undef ROAR_DBG_PREFIX
170#endif
171#define ROAR_DBG_PREFIX "roaraudio"
172
173#define ROAR_DBG_FULLPREFIX "(" ROAR_DBG_PREFIX ": " __FILE__ ":%i): "
174
175#if __GNUC__ < 3
176 #define ROAR_DBG(format, args...)
177 #define ROAR_ERR(format, args...)
178 #define ROAR_WARN(format, args...)
179#else
180
181#ifdef DEBUG
182 #define ROAR_DBG(format, args...)  fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "DEBUG: " format "\n", __LINE__, ## args)
183#else
184 #define ROAR_DBG(format, args...)
185#endif
186
187#define ROAR_ERR(format, args...)  fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "Error: "   format "\n", __LINE__, ## args)
188#define ROAR_WARN(format, args...) fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "Warning: " format "\n", __LINE__, ## args)
189
190#endif
191
192#ifdef ROAR_HAVE_SAFE_OVERFLOW
193#define ROAR_MATH_OVERFLOW_ADD(a, b) ((a)+(b))
194#else
195#define ROAR_MATH_OVERFLOW_ADD(a, b) ((4294967295U - (a)) + 1 + (b))
196#endif
197
198#ifdef ROAR_HAVE_MLOCK
199#ifdef __linux__
200#define ROAR_MLOCK(p,s) mlock((p), (s))
201#else
202int _ROAR_MLOCK(const void *addr, size_t len);
203#define ROAR_MLOCK _ROAR_MLOCK
204#endif
205#endif
206
207#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
208
209#ifdef ROAR_TARGET_WIN32
210#error This is nonsens. No win32 runs on a BE machine
211#endif
212
213#define ROAR_NET2HOST32(x) (x)
214#define ROAR_HOST2NET32(x) (x)
215#define ROAR_NET2HOST16(x) (x)
216#define ROAR_HOST2NET16(x) (x)
217
218#ifdef ROAR_HAVE_LIBDNET
219#define ROAR_dn_ntohs(x) ((((x)&0x0ff)<<8) | (((x)&0xff00)>>8))
220#define ROAR_dn_ntohl(x) ( ((dn_ntohs((x)&0xffff))<<16) |\
221                           ((dn_ntohs(((x)>>16)))) )
222#define ROAR_dn_htonl(x) ROAR_dn_ntohl(x)
223#define ROAR_dn_htons(x) ROAR_dn_ntohs(x)
224#endif
225
226//#elif BYTE_ORDER == LITTLE_ENDIAN
227#else
228
229#define ROAR_NET2HOST32(x) ntohl((x))
230#define ROAR_HOST2NET32(x) htonl((x))
231#define ROAR_NET2HOST16(x) ntohs((x))
232#define ROAR_HOST2NET16(x) htons((x))
233
234#ifdef ROAR_HAVE_LIBDNET
235#if BYTE_ORDER == LITTLE_ENDIAN
236#define ROAR_dn_ntohs(x) (x)
237#define ROAR_dn_htons(x) (x)
238
239#define ROAR_dn_ntohl(x) (x)
240#define ROAR_dn_htonl(x) (x)
241#else
242#error can not build on this architecture with DECnet support enabled
243#endif
244#endif
245
246#endif
247
248__END_DECLS
249
250#endif
251
252//ll
Note: See TracBrowser for help on using the repository browser.