[0] | 1 | //roaraudio.h: |
---|
| 2 | |
---|
[704] | 3 | /* |
---|
[3608] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010 |
---|
[704] | 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 |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[704] | 23 | * |
---|
| 24 | * NOTE: Even though this file is LGPLed it (may) include GPLed files |
---|
| 25 | * so the license of this file is/may therefore downgraded to GPL. |
---|
| 26 | * See HACKING for details. |
---|
| 27 | */ |
---|
| 28 | |
---|
[0] | 29 | #ifndef _ROARAUDIO_H_ |
---|
| 30 | #define _ROARAUDIO_H_ |
---|
| 31 | |
---|
[4156] | 32 | #define _ROAR_MKVERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) |
---|
| 33 | |
---|
[1074] | 34 | #include <roaraudio/config.h> |
---|
[1428] | 35 | #include <roaraudio/muconthacks.h> |
---|
[1073] | 36 | #include <roaraudio/win32hacks.h> // we include this at the beginning of the file |
---|
| 37 | // so we can define well known standard types known to everyone |
---|
| 38 | // and everywhere but win32 here |
---|
| 39 | |
---|
[1251] | 40 | // consts we need to set depending on the OS and features: |
---|
| 41 | #if defined(ROAR_NEED_GNU_SOURCE) && !defined(_GNU_SOURCE) |
---|
| 42 | #define _GNU_SOURCE |
---|
| 43 | #endif |
---|
| 44 | |
---|
| 45 | #if defined(ROAR_NEED_BSD_VISIBLE) && !defined(__BSD_VISIBLE) |
---|
| 46 | #define __BSD_VISIBLE 1 |
---|
| 47 | #endif |
---|
| 48 | |
---|
[1477] | 49 | #include <stdint.h> |
---|
[0] | 50 | #include <stdlib.h> |
---|
[1426] | 51 | |
---|
| 52 | #ifdef ROAR_HAVE_H_UNISTD |
---|
[0] | 53 | #include <unistd.h> |
---|
[1426] | 54 | #endif |
---|
| 55 | |
---|
[0] | 56 | #include <stdio.h> |
---|
| 57 | #include <string.h> |
---|
| 58 | #include <errno.h> |
---|
[1425] | 59 | |
---|
| 60 | #ifdef ROAR_HAVE_H_SYS_TYPES |
---|
[0] | 61 | #include <sys/types.h> |
---|
[1425] | 62 | #endif |
---|
| 63 | |
---|
[0] | 64 | #include <limits.h> |
---|
[1422] | 65 | #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) |
---|
[57] | 66 | #include <sys/mman.h> |
---|
[1075] | 67 | #endif |
---|
[0] | 68 | |
---|
[60] | 69 | // TODO: can we move the next block into roard specific includes? |
---|
[1422] | 70 | #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) |
---|
[60] | 71 | #include <grp.h> |
---|
| 72 | #include <pwd.h> |
---|
| 73 | #include <sys/stat.h> |
---|
[1074] | 74 | #endif |
---|
[60] | 75 | |
---|
[1072] | 76 | #ifdef ROAR_TARGET_WIN32 |
---|
| 77 | #include <winsock2.h> |
---|
[1375] | 78 | #else /* ROAR_TARGET_WIN32 */ |
---|
| 79 | #ifdef ROAR_HAVE_BSDSOCKETS |
---|
| 80 | |
---|
| 81 | #if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_IPV6) |
---|
[0] | 82 | #include <arpa/inet.h> |
---|
[1375] | 83 | #endif |
---|
[0] | 84 | |
---|
[1472] | 85 | #ifdef ROAR_HAVE_SELECT |
---|
[0] | 86 | #include <sys/socket.h> |
---|
[1472] | 87 | #endif |
---|
[1375] | 88 | |
---|
| 89 | #ifdef ROAR_HAVE_IPV4 |
---|
[0] | 90 | #include <netinet/in.h> |
---|
| 91 | #include <netinet/tcp.h> |
---|
[1375] | 92 | #endif |
---|
| 93 | #ifdef ROAR_HAVE_UNIX |
---|
[0] | 94 | #include <sys/un.h> |
---|
[1072] | 95 | #endif |
---|
[0] | 96 | |
---|
[1375] | 97 | #endif /* ROAR_HAVE_BSDSOCKETS */ |
---|
| 98 | #endif /* ROAR_TARGET_WIN32 */ |
---|
| 99 | |
---|
[480] | 100 | #ifdef __NetBSD__ |
---|
| 101 | #include <netinet/in_systm.h> |
---|
| 102 | #endif |
---|
| 103 | |
---|
[1424] | 104 | #if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) |
---|
[0] | 105 | #include <netdb.h> |
---|
[1074] | 106 | #endif |
---|
[0] | 107 | |
---|
| 108 | // NOTE: we need this macro in some of our header files. |
---|
[3566] | 109 | // TODO: This is oubslute, we will remove it soon. |
---|
[0] | 110 | #if INT_MAX >= 32767 |
---|
| 111 | #define roar_intm16 int |
---|
| 112 | #define roar_uintm16 unsigned int |
---|
| 113 | #else |
---|
| 114 | #define roar_intm16 int16_t |
---|
| 115 | #define roar_uintm16 uint16_t |
---|
| 116 | #endif |
---|
| 117 | |
---|
[988] | 118 | // this is to avoid warning messages on platforms |
---|
| 119 | // where sizeof(void*) == 8 and szeof(int) == 4 |
---|
| 120 | #ifdef __LP64__ |
---|
| 121 | #define ROAR_INSTINT long int |
---|
| 122 | #else |
---|
| 123 | #define ROAR_INSTINT int |
---|
| 124 | #endif |
---|
| 125 | |
---|
[874] | 126 | #ifndef __BEGIN_DECLS |
---|
| 127 | #ifdef __cplusplus |
---|
| 128 | # define __BEGIN_DECLS extern "C" { |
---|
| 129 | # define __END_DECLS } |
---|
| 130 | #else |
---|
| 131 | # define __BEGIN_DECLS |
---|
| 132 | # define __END_DECLS |
---|
| 133 | #endif |
---|
| 134 | #endif |
---|
| 135 | |
---|
| 136 | __BEGIN_DECLS |
---|
| 137 | |
---|
[0] | 138 | #include <roaraudio/proto.h> |
---|
[780] | 139 | #include <roaraudio/error.h> |
---|
[0] | 140 | #include <roaraudio/audio.h> |
---|
| 141 | #include <roaraudio/stream.h> |
---|
| 142 | #include <roaraudio/client.h> |
---|
| 143 | #include <roaraudio/sample.h> |
---|
[4097] | 144 | #include <roaraudio/beep.h> |
---|
[87] | 145 | #include <roaraudio/meta.h> |
---|
[3048] | 146 | #include <roaraudio/genre.h> |
---|
[344] | 147 | #include <roaraudio/acl.h> |
---|
[2418] | 148 | #include <roaraudio/misc.h> |
---|
[4073] | 149 | #include <roaraudio/byteorder.h> |
---|
[4097] | 150 | #include <roaraudio/socket.h> |
---|
[4263] | 151 | #include <roaraudio/ltm.h> |
---|
[0] | 152 | |
---|
| 153 | #include <libroar/libroar.h> |
---|
| 154 | |
---|
[4057] | 155 | // Some glocal network defaults: |
---|
| 156 | #ifndef ROAR_NET_INET4_LOCALHOST |
---|
| 157 | #define ROAR_NET_INET4_LOCALHOST "localhost" |
---|
| 158 | #endif |
---|
| 159 | #ifndef ROAR_NET_INET4_ANYHOST |
---|
| 160 | #define ROAR_NET_INET4_ANYHOST "0.0.0.0" |
---|
| 161 | #endif |
---|
| 162 | |
---|
| 163 | #ifndef ROAR_NET_INET6_LOCALHOST |
---|
| 164 | #define ROAR_NET_INET6_LOCALHOST "ipv6-localhost" |
---|
| 165 | #endif |
---|
| 166 | #ifndef ROAR_NET_INET6_ANYHOST |
---|
| 167 | #define ROAR_NET_INET6_ANYHOST "::" |
---|
| 168 | #endif |
---|
| 169 | |
---|
[2514] | 170 | // IP: |
---|
| 171 | #define ROAR_DEFAULT_PORT 16002 |
---|
| 172 | |
---|
[2512] | 173 | // IPv4 |
---|
[2514] | 174 | #define ROAR_DEFAULT_INET4_PORT ROAR_DEFAULT_PORT |
---|
[4057] | 175 | #define ROAR_DEFAULT_INET4_HOST ROAR_NET_INET4_LOCALHOST |
---|
[2512] | 176 | // aliases: |
---|
| 177 | #define ROAR_DEFAULT_HOST ROAR_DEFAULT_INET4_HOST |
---|
| 178 | |
---|
| 179 | // IPv6: |
---|
[2514] | 180 | #define ROAR_DEFAULT_INET6_PORT ROAR_DEFAULT_PORT |
---|
[4057] | 181 | #define ROAR_DEFAULT_INET6_HOST ROAR_NET_INET6_LOCALHOST |
---|
[0] | 182 | |
---|
[508] | 183 | // UNIX Domain Sockets |
---|
[0] | 184 | #define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar" |
---|
| 185 | #define ROAR_DEFAULT_SOCK_USER ".roar" |
---|
| 186 | |
---|
[508] | 187 | // DECnet |
---|
| 188 | #define ROAR_DEFAULT_OBJECT "roar" |
---|
| 189 | #define ROAR_DEFAULT_NUM 0 |
---|
[515] | 190 | #define ROAR_DEFAULT_LISTEN_OBJECT "::" ROAR_DEFAULT_OBJECT |
---|
[508] | 191 | |
---|
[4057] | 192 | // now handled by configure: |
---|
[927] | 193 | //#define ROAR_DEFAULT_SOCKGRP "audio" |
---|
[450] | 194 | |
---|
[4057] | 195 | |
---|
| 196 | // defines for emulations: |
---|
| 197 | // ESD: |
---|
| 198 | #define ROAR_DEFAULT_ESD_GSOCK "/tmp/.esd/socket" |
---|
| 199 | #define ROAR_DEFAULT_ESD_PORT 16001 |
---|
| 200 | // RSound: |
---|
| 201 | #define ROAR_DEFAULT_RSOUND_GSOCK "/tmp/rsound" |
---|
| 202 | #define ROAR_DEFAULT_RSOUND_PORT 12345 |
---|
| 203 | #define ROAR_DEFAULT_RSOUND_OBJECT "::rsound" |
---|
| 204 | // PulseAudio: |
---|
| 205 | #define ROAR_DEFAULT_PA_PORT 4712 |
---|
| 206 | // RPlay: |
---|
| 207 | #define ROAR_DEFAULT_RPLAY_PORT 5556 |
---|
| 208 | |
---|
[2064] | 209 | #if defined(ROAR_HAVE_LIBWSOCK32) && defined(ROAR_HAVE_LIBWS2_32) |
---|
| 210 | #define ROAR_LIBS_WIN32 " -lwsock32 -lws2_32" |
---|
| 211 | #else |
---|
| 212 | #define ROAR_LIBS_WIN32 "" |
---|
| 213 | #endif |
---|
| 214 | |
---|
| 215 | #ifdef ROAR_HAVE_LIBSOCKET |
---|
| 216 | #define ROAR_LIBS_LIBSOCKET " -lsocket" |
---|
| 217 | #else |
---|
| 218 | #define ROAR_LIBS_LIBSOCKET "" |
---|
| 219 | #endif |
---|
| 220 | |
---|
| 221 | #ifdef ROAR_HAVE_LIBSENDFILE |
---|
| 222 | #define ROAR_LIBS_LIBSENDFILE " -lsendfile" |
---|
| 223 | #else |
---|
| 224 | #define ROAR_LIBS_LIBSENDFILE "" |
---|
| 225 | #endif |
---|
| 226 | |
---|
| 227 | #define ROAR_LIBS_NET_LIBS ROAR_LIBS_LIBSOCKET ROAR_LIBS_WIN32 |
---|
| 228 | |
---|
| 229 | #define ROAR_LIBS "-lroar" ROAR_LIBS_LIBSENDFILE ROAR_LIBS_NET_LIBS |
---|
[2024] | 230 | #define ROAR_LIBS_DSP "-lroardsp " ROAR_LIBS |
---|
| 231 | #define ROAR_LIBS_MIDI "-lroarmidi " ROAR_LIBS_DSP |
---|
| 232 | #define ROAR_LIBS_LIGHT "-lroarlight " ROAR_LIBS |
---|
[2277] | 233 | #define ROAR_LIBS_EIO "-lroareio " ROAR_LIBS |
---|
[313] | 234 | #define ROAR_CFLAGS "" |
---|
[0] | 235 | |
---|
[2876] | 236 | // comp libs: |
---|
| 237 | #define ROAR_LIBS_C_ESD "-lroaresd " ROAR_LIBS |
---|
| 238 | #define ROAR_LIBS_C_ARTSC "-lroarartsc " ROAR_LIBS |
---|
| 239 | #define ROAR_LIBS_C_PULSE "-lroarpulse " ROAR_LIBS |
---|
[3826] | 240 | #define ROAR_LIBS_C_PULSE_SIMPLE "-lroarpulse-simple " ROAR_LIBS_C_PULSE |
---|
[2876] | 241 | #define ROAR_LIBS_C_SNDIO "-lroarsndio " ROAR_LIBS |
---|
| 242 | #define ROAR_LIBS_C_YIFF "-lroaryiff " ROAR_LIBS |
---|
| 243 | |
---|
[0] | 244 | //some basic macros: |
---|
| 245 | #define ROAR_STDIN 0 |
---|
| 246 | #define ROAR_STDOUT 1 |
---|
| 247 | #define ROAR_STDERR 2 |
---|
| 248 | |
---|
| 249 | #define ROAR_DEBUG_OUTFH stderr |
---|
| 250 | |
---|
| 251 | #ifdef ROAR_DBG_PREFIX |
---|
| 252 | #undef ROAR_DBG_PREFIX |
---|
| 253 | #endif |
---|
| 254 | #define ROAR_DBG_PREFIX "roaraudio" |
---|
| 255 | |
---|
| 256 | #define ROAR_DBG_FULLPREFIX "(" ROAR_DBG_PREFIX ": " __FILE__ ":%i): " |
---|
| 257 | |
---|
[2969] | 258 | // some default info levels: |
---|
| 259 | #define ROAR_DBG_INFO_NONE 0 |
---|
| 260 | #define ROAR_DBG_INFO_NOTICE 1 |
---|
| 261 | #define ROAR_DBG_INFO_INFO 2 |
---|
| 262 | #define ROAR_DBG_INFO_VERBOSE 3 |
---|
| 263 | |
---|
[472] | 264 | #if __GNUC__ < 3 |
---|
| 265 | #define ROAR_DBG(format, args...) |
---|
| 266 | #define ROAR_ERR(format, args...) |
---|
| 267 | #define ROAR_WARN(format, args...) |
---|
[2969] | 268 | #define ROAR_INFO(format, level, args...) |
---|
[472] | 269 | #else |
---|
| 270 | |
---|
[0] | 271 | #ifdef DEBUG |
---|
[3612] | 272 | #define ROAR_DBG(format, args...) roar_debug_msg(ROAR_DEBUG_TYPE_DEBUG, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
[0] | 273 | #else |
---|
| 274 | #define ROAR_DBG(format, args...) |
---|
| 275 | #endif |
---|
| 276 | |
---|
[3612] | 277 | #define ROAR_ERR(format, args...) roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
| 278 | #define ROAR_WARN(format, args...) roar_debug_msg(ROAR_DEBUG_TYPE_WARNING, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
[0] | 279 | |
---|
[2969] | 280 | // INFO function: |
---|
[4054] | 281 | #ifdef DEBUG |
---|
| 282 | #define ROAR_INFO(format, level, args...) roar_debug_msg(ROAR_DEBUG_TYPE_INFO, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
| 283 | #elif defined(ROAR_DBG_INFOVAR) |
---|
[3612] | 284 | #define ROAR_INFO(format, level, args...) if ( (ROAR_DBG_INFOVAR) >= (level) ) roar_debug_msg(ROAR_DEBUG_TYPE_INFO, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) |
---|
[2969] | 285 | #else |
---|
| 286 | #define ROAR_INFO(format, level, args...) |
---|
| 287 | #endif |
---|
| 288 | |
---|
[472] | 289 | #endif |
---|
[0] | 290 | |
---|
| 291 | #ifdef ROAR_HAVE_SAFE_OVERFLOW |
---|
| 292 | #define ROAR_MATH_OVERFLOW_ADD(a, b) ((a)+(b)) |
---|
| 293 | #else |
---|
| 294 | #define ROAR_MATH_OVERFLOW_ADD(a, b) ((4294967295U - (a)) + 1 + (b)) |
---|
| 295 | #endif |
---|
| 296 | |
---|
[3352] | 297 | #ifdef ROAR_HAVE_STRCASESTR |
---|
| 298 | #define _roar_strcasestr(a,b) strcasestr((a), (b)) |
---|
| 299 | #else |
---|
| 300 | #define _roar_strcasestr(a,b) NULL |
---|
| 301 | #endif |
---|
| 302 | |
---|
[874] | 303 | __END_DECLS |
---|
| 304 | |
---|
[0] | 305 | #endif |
---|
| 306 | |
---|
| 307 | //ll |
---|