source: roaraudio/include/roaraudio.h @ 1074:f91e0087fb5e

Last change on this file since 1074:f91e0087fb5e was 1074:f91e0087fb5e, checked in by phi, 15 years ago

read config.h early, added another ifdef

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