source: roaraudio/include/roaraudio.h @ 1073:d7871dad6a36

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

added roaraudio/win32hacks.h

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