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