source: roaraudio/include/roaraudio.h @ 1251:07369caecd6b

Last change on this file since 1251:07369caecd6b was 1251:07369caecd6b, checked in by phi, 15 years ago

added support for ROAR_NEED_GNU_SOURCE and ROAR_NEED_BSD_VISIBLE

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