source: roaraudio/include/roaraudio.h @ 4975:1b8be0a0ba5f

Last change on this file since 4975:1b8be0a0ba5f was 4940:3c55a0fbd3f6, checked in by phi, 13 years ago

test for sys/stat.h and do not assume it as not present on some systems

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