source: roaraudio/include/roaraudio.h @ 1472:30fb2c3c4756

Last change on this file since 1472:30fb2c3c4756 was 1472:30fb2c3c4756, checked in by phi, 15 years ago

only include select.h if we have select()

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