source: roaraudio/include/roaraudio.h @ 1440:2036187332e1

Last change on this file since 1440:2036187332e1 was 1428:75c043e7f58d, checked in by phi, 15 years ago

added muconthacks.h header to define some things not defined by microcontrollers needed by RoarAudio

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