[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 | |
---|
| 69 | #include <roaraudio/proto.h> |
---|
[780] | 70 | #include <roaraudio/error.h> |
---|
[0] | 71 | #include <roaraudio/audio.h> |
---|
| 72 | #include <roaraudio/stream.h> |
---|
| 73 | #include <roaraudio/client.h> |
---|
| 74 | #include <roaraudio/sample.h> |
---|
[87] | 75 | #include <roaraudio/meta.h> |
---|
[344] | 76 | #include <roaraudio/acl.h> |
---|
[0] | 77 | |
---|
| 78 | #include <libroar/libroar.h> |
---|
| 79 | |
---|
[508] | 80 | // IP |
---|
[0] | 81 | #define ROAR_DEFAULT_PORT 16002 |
---|
| 82 | #define ROAR_DEFAULT_HOST "localhost" |
---|
| 83 | |
---|
[508] | 84 | // UNIX Domain Sockets |
---|
[0] | 85 | #define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar" |
---|
| 86 | #define ROAR_DEFAULT_SOCK_USER ".roar" |
---|
| 87 | |
---|
[508] | 88 | // DECnet |
---|
| 89 | #define ROAR_DEFAULT_OBJECT "roar" |
---|
| 90 | #define ROAR_DEFAULT_NUM 0 |
---|
[515] | 91 | #define ROAR_DEFAULT_LISTEN_OBJECT "::" ROAR_DEFAULT_OBJECT |
---|
[508] | 92 | |
---|
[450] | 93 | #define ROAR_DEFAULT_SOCKGRP "audio" |
---|
| 94 | |
---|
[313] | 95 | #define ROAR_LIBS "-lroar" |
---|
| 96 | #define ROAR_CFLAGS "" |
---|
[0] | 97 | |
---|
| 98 | //some basic macros: |
---|
| 99 | #define ROAR_STDIN 0 |
---|
| 100 | #define ROAR_STDOUT 1 |
---|
| 101 | #define ROAR_STDERR 2 |
---|
| 102 | |
---|
| 103 | #define ROAR_DEBUG_OUTFH stderr |
---|
| 104 | |
---|
| 105 | #ifdef ROAR_DBG_PREFIX |
---|
| 106 | #undef ROAR_DBG_PREFIX |
---|
| 107 | #endif |
---|
| 108 | #define ROAR_DBG_PREFIX "roaraudio" |
---|
| 109 | |
---|
| 110 | #define ROAR_DBG_FULLPREFIX "(" ROAR_DBG_PREFIX ": " __FILE__ ":%i): " |
---|
| 111 | |
---|
[472] | 112 | #if __GNUC__ < 3 |
---|
| 113 | #define ROAR_DBG(format, args...) |
---|
| 114 | #define ROAR_ERR(format, args...) |
---|
| 115 | #define ROAR_WARN(format, args...) |
---|
| 116 | #else |
---|
| 117 | |
---|
[0] | 118 | #ifdef DEBUG |
---|
| 119 | #define ROAR_DBG(format, args...) fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "DEBUG: " format "\n", __LINE__, ## args) |
---|
| 120 | #else |
---|
| 121 | #define ROAR_DBG(format, args...) |
---|
| 122 | #endif |
---|
| 123 | |
---|
[311] | 124 | #define ROAR_ERR(format, args...) fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "Error: " format "\n", __LINE__, ## args) |
---|
| 125 | #define ROAR_WARN(format, args...) fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "Warning: " format "\n", __LINE__, ## args) |
---|
[0] | 126 | |
---|
[472] | 127 | #endif |
---|
[0] | 128 | |
---|
| 129 | #ifdef ROAR_HAVE_SAFE_OVERFLOW |
---|
| 130 | #define ROAR_MATH_OVERFLOW_ADD(a, b) ((a)+(b)) |
---|
| 131 | #else |
---|
| 132 | #define ROAR_MATH_OVERFLOW_ADD(a, b) ((4294967295U - (a)) + 1 + (b)) |
---|
| 133 | #endif |
---|
| 134 | |
---|
[56] | 135 | #ifdef ROAR_HAVE_MLOCK |
---|
[312] | 136 | #ifdef __linux__ |
---|
[57] | 137 | #define ROAR_MLOCK(p,s) mlock((p), (s)) |
---|
[312] | 138 | #else |
---|
[701] | 139 | int _ROAR_MLOCK(const void *addr, size_t len); |
---|
[700] | 140 | #define ROAR_MLOCK _ROAR_MLOCK |
---|
[56] | 141 | #endif |
---|
[699] | 142 | #endif |
---|
[0] | 143 | |
---|
| 144 | |
---|
| 145 | #if BYTE_ORDER == BIG_ENDIAN |
---|
| 146 | |
---|
| 147 | #define ROAR_NET2HOST32(x) (x) |
---|
| 148 | #define ROAR_HOST2NET32(x) (x) |
---|
| 149 | #define ROAR_NET2HOST16(x) (x) |
---|
| 150 | #define ROAR_HOST2NET16(x) (x) |
---|
| 151 | |
---|
[508] | 152 | #ifdef ROAR_HAVE_LIBDNET |
---|
| 153 | #define ROAR_dn_ntohs(x) ((((x)&0x0ff)<<8) | (((x)&0xff00)>>8)) |
---|
| 154 | #define ROAR_dn_ntohl(x) ( ((dn_ntohs((x)&0xffff))<<16) |\ |
---|
| 155 | ((dn_ntohs(((x)>>16)))) ) |
---|
| 156 | #define ROAR_dn_htonl(x) ROAR_dn_ntohl(x) |
---|
| 157 | #define ROAR_dn_htons(x) ROAR_dn_ntohs(x) |
---|
| 158 | #endif |
---|
| 159 | |
---|
[0] | 160 | //#elif BYTE_ORDER == LITTLE_ENDIAN |
---|
| 161 | #else |
---|
| 162 | |
---|
| 163 | #define ROAR_NET2HOST32(x) ntohl((x)) |
---|
| 164 | #define ROAR_HOST2NET32(x) htonl((x)) |
---|
| 165 | #define ROAR_NET2HOST16(x) ntohs((x)) |
---|
| 166 | #define ROAR_HOST2NET16(x) htons((x)) |
---|
| 167 | |
---|
[508] | 168 | #ifdef ROAR_HAVE_LIBDNET |
---|
| 169 | #if BYTE_ORDER == LITTLE_ENDIAN |
---|
| 170 | #define ROAR_dn_ntohs(x) (x) |
---|
| 171 | #define ROAR_dn_htons(x) (x) |
---|
| 172 | |
---|
| 173 | #define ROAR_dn_ntohl(x) (x) |
---|
| 174 | #define ROAR_dn_htonl(x) (x) |
---|
| 175 | #else |
---|
| 176 | #error can not build on this architecture with DECnet support enabled |
---|
| 177 | #endif |
---|
| 178 | #endif |
---|
| 179 | |
---|
[0] | 180 | #endif |
---|
| 181 | |
---|
| 182 | #endif |
---|
| 183 | |
---|
| 184 | //ll |
---|