[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 | |
---|
[0] | 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> |
---|
[1075] | 43 | #ifndef ROAR_TARGET_WIN32 |
---|
[57] | 44 | #include <sys/mman.h> |
---|
[1075] | 45 | #endif |
---|
[0] | 46 | |
---|
[60] | 47 | // TODO: can we move the next block into roard specific includes? |
---|
[1074] | 48 | #ifndef ROAR_TARGET_WIN32 |
---|
[60] | 49 | #include <grp.h> |
---|
| 50 | #include <pwd.h> |
---|
| 51 | #include <sys/stat.h> |
---|
[1074] | 52 | #endif |
---|
[60] | 53 | |
---|
[1072] | 54 | #ifdef ROAR_TARGET_WIN32 |
---|
| 55 | #include <winsock2.h> |
---|
| 56 | #else |
---|
[0] | 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> |
---|
[1072] | 63 | #endif |
---|
[0] | 64 | |
---|
[480] | 65 | #ifdef __NetBSD__ |
---|
| 66 | #include <netinet/in_systm.h> |
---|
| 67 | #endif |
---|
| 68 | |
---|
[1074] | 69 | #ifndef ROAR_TARGET_WIN32 |
---|
[0] | 70 | #include <netdb.h> |
---|
[1074] | 71 | #endif |
---|
[0] | 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 | |
---|
[988] | 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 | |
---|
[874] | 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 | |
---|
[0] | 102 | #include <roaraudio/proto.h> |
---|
[780] | 103 | #include <roaraudio/error.h> |
---|
[0] | 104 | #include <roaraudio/audio.h> |
---|
| 105 | #include <roaraudio/stream.h> |
---|
| 106 | #include <roaraudio/client.h> |
---|
| 107 | #include <roaraudio/sample.h> |
---|
[87] | 108 | #include <roaraudio/meta.h> |
---|
[344] | 109 | #include <roaraudio/acl.h> |
---|
[0] | 110 | |
---|
| 111 | #include <libroar/libroar.h> |
---|
| 112 | |
---|
[508] | 113 | // IP |
---|
[0] | 114 | #define ROAR_DEFAULT_PORT 16002 |
---|
| 115 | #define ROAR_DEFAULT_HOST "localhost" |
---|
| 116 | |
---|
[508] | 117 | // UNIX Domain Sockets |
---|
[0] | 118 | #define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar" |
---|
| 119 | #define ROAR_DEFAULT_SOCK_USER ".roar" |
---|
| 120 | |
---|
[508] | 121 | // DECnet |
---|
| 122 | #define ROAR_DEFAULT_OBJECT "roar" |
---|
| 123 | #define ROAR_DEFAULT_NUM 0 |
---|
[515] | 124 | #define ROAR_DEFAULT_LISTEN_OBJECT "::" ROAR_DEFAULT_OBJECT |
---|
[508] | 125 | |
---|
[927] | 126 | // now handled by condiguere |
---|
| 127 | //#define ROAR_DEFAULT_SOCKGRP "audio" |
---|
[450] | 128 | |
---|
[313] | 129 | #define ROAR_LIBS "-lroar" |
---|
| 130 | #define ROAR_CFLAGS "" |
---|
[0] | 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 | |
---|
[472] | 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 | |
---|
[0] | 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 | |
---|
[311] | 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) |
---|
[0] | 160 | |
---|
[472] | 161 | #endif |
---|
[0] | 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 | |
---|
[56] | 169 | #ifdef ROAR_HAVE_MLOCK |
---|
[312] | 170 | #ifdef __linux__ |
---|
[57] | 171 | #define ROAR_MLOCK(p,s) mlock((p), (s)) |
---|
[312] | 172 | #else |
---|
[701] | 173 | int _ROAR_MLOCK(const void *addr, size_t len); |
---|
[700] | 174 | #define ROAR_MLOCK _ROAR_MLOCK |
---|
[56] | 175 | #endif |
---|
[699] | 176 | #endif |
---|
[0] | 177 | |
---|
[1098] | 178 | #if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32) |
---|
[0] | 179 | |
---|
[1096] | 180 | #ifdef ROAR_TARGET_WIN32 |
---|
| 181 | #error This is nonsens. No win32 runs on a BE machine |
---|
| 182 | #endif |
---|
| 183 | |
---|
[0] | 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 | |
---|
[508] | 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 | |
---|
[0] | 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 | |
---|
[508] | 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 | |
---|
[0] | 217 | #endif |
---|
| 218 | |
---|
[874] | 219 | __END_DECLS |
---|
| 220 | |
---|
[0] | 221 | #endif |
---|
| 222 | |
---|
| 223 | //ll |
---|