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