source: roaraudio/include/roaraudio.h @ 1098:8e1a4e4297fd

Last change on this file since 1098:8e1a4e4297fd was 1098:8e1a4e4297fd, checked in by phi, 15 years ago

force LE for win32

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