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