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