source: roaraudio/include/roaraudio.h @ 1425:46089a7c1e48

Last change on this file since 1425:46089a7c1e48 was 1425:46089a7c1e48, checked in by phi, 15 years ago

test for sys/types.h and fcntl.h

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