source: roaraudio/include/roaraudio.h @ 1320:b2cbbf55cf68

Last change on this file since 1320:b2cbbf55cf68 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
RevLine 
[0]1//roaraudio.h:
2
[704]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
[0]28#ifndef _ROARAUDIO_H_
29#define _ROARAUDIO_H_
30
[1074]31#include <roaraudio/config.h>
[1073]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
[1251]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
[0]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>
[1075]52#ifndef ROAR_TARGET_WIN32
[57]53#include <sys/mman.h>
[1075]54#endif
[0]55
[60]56// TODO: can we move the next block into roard specific includes?
[1074]57#ifndef ROAR_TARGET_WIN32
[60]58#include <grp.h>
59#include <pwd.h>
60#include <sys/stat.h>
[1074]61#endif
[60]62
[1072]63#ifdef ROAR_TARGET_WIN32
64#include <winsock2.h>
65#else
[0]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>
[1072]72#endif
[0]73
[480]74#ifdef __NetBSD__
75#include <netinet/in_systm.h>
76#endif
77
[1074]78#ifndef ROAR_TARGET_WIN32
[0]79#include <netdb.h>
[1074]80#endif
[0]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
[988]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
[874]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
[0]111#include <roaraudio/proto.h>
[780]112#include <roaraudio/error.h>
[0]113#include <roaraudio/audio.h>
114#include <roaraudio/stream.h>
115#include <roaraudio/client.h>
116#include <roaraudio/sample.h>
[87]117#include <roaraudio/meta.h>
[344]118#include <roaraudio/acl.h>
[0]119
120#include <libroar/libroar.h>
121
[508]122// IP
[0]123#define ROAR_DEFAULT_PORT        16002
124#define ROAR_DEFAULT_HOST        "localhost"
125
[508]126// UNIX Domain Sockets
[0]127#define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar"
128#define ROAR_DEFAULT_SOCK_USER   ".roar"
129
[508]130// DECnet
131#define ROAR_DEFAULT_OBJECT      "roar"
132#define ROAR_DEFAULT_NUM         0
[515]133#define ROAR_DEFAULT_LISTEN_OBJECT "::" ROAR_DEFAULT_OBJECT
[508]134
[927]135// now handled by condiguere
136//#define ROAR_DEFAULT_SOCKGRP     "audio"
[450]137
[313]138#define ROAR_LIBS                "-lroar"
139#define ROAR_CFLAGS              ""
[0]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
[472]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
[0]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
[311]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)
[0]169
[472]170#endif
[0]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
[56]178#ifdef ROAR_HAVE_MLOCK
[312]179#ifdef __linux__
[57]180#define ROAR_MLOCK(p,s) mlock((p), (s))
[312]181#else
[701]182int _ROAR_MLOCK(const void *addr, size_t len);
[700]183#define ROAR_MLOCK _ROAR_MLOCK
[56]184#endif
[699]185#endif
[0]186
[1098]187#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
[0]188
[1096]189#ifdef ROAR_TARGET_WIN32
190#error This is nonsens. No win32 runs on a BE machine
191#endif
192
[0]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
[508]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
[0]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
[508]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
[0]226#endif
227
[874]228__END_DECLS
229
[0]230#endif
231
232//ll
Note: See TracBrowser for help on using the repository browser.