source: roaraudio/include/roaraudio.h @ 508:1129ff87dd1e

Last change on this file since 508:1129ff87dd1e was 508:1129ff87dd1e, checked in by phi, 16 years ago

added DECnet listen support, introused -n/--decnet to roard, added woraround to Linux DECnet stack bugs on streams and added some helpfull DECnet macros, puh...

File size: 3.6 KB
Line 
1//roaraudio.h:
2
3#ifndef _ROARAUDIO_H_
4#define _ROARAUDIO_H_
5
6#include <stdlib.h>
7#include <unistd.h>
8#include <stdio.h>
9#include <string.h>
10#include <errno.h>
11#include <sys/types.h>
12#include <limits.h>
13#include <sys/mman.h>
14
15// TODO: can we move the next block into roard specific includes?
16#include <grp.h>
17#include <pwd.h>
18#include <sys/stat.h>
19
20#include <arpa/inet.h>
21
22#include <sys/socket.h>
23#include <netinet/in.h>
24#include <netinet/tcp.h>
25#include <sys/un.h>
26
27#ifdef __NetBSD__
28#include <netinet/in_systm.h>
29#endif
30
31#include <netdb.h>
32
33#include <roaraudio/config.h>
34
35// NOTE: we need this macro in some of our header files.
36#if INT_MAX >= 32767
37#define roar_intm16  int
38#define roar_uintm16 unsigned int
39#else
40#define roar_intm16  int16_t
41#define roar_uintm16 uint16_t
42#endif
43
44#include <roaraudio/proto.h>
45#include <roaraudio/audio.h>
46#include <roaraudio/stream.h>
47#include <roaraudio/client.h>
48#include <roaraudio/sample.h>
49#include <roaraudio/meta.h>
50#include <roaraudio/acl.h>
51
52#include <libroar/libroar.h>
53
54// IP
55#define ROAR_DEFAULT_PORT        16002
56#define ROAR_DEFAULT_HOST        "localhost"
57
58// UNIX Domain Sockets
59#define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar"
60#define ROAR_DEFAULT_SOCK_USER   ".roar"
61
62// DECnet
63#define ROAR_DEFAULT_OBJECT      "roar"
64#define ROAR_DEFAULT_NUM         0
65#define ROAR_DEFAULT_LISTEN_OBJECT "LISTEN::" ROAR_DEFAULT_OBJECT
66
67#define ROAR_DEFAULT_SOCKGRP     "audio"
68
69#define ROAR_LIBS                "-lroar"
70#define ROAR_CFLAGS              ""
71
72//some basic macros:
73#define ROAR_STDIN  0
74#define ROAR_STDOUT 1
75#define ROAR_STDERR 2
76
77#define ROAR_DEBUG_OUTFH stderr
78
79#ifdef ROAR_DBG_PREFIX
80#undef ROAR_DBG_PREFIX
81#endif
82#define ROAR_DBG_PREFIX "roaraudio"
83
84#define ROAR_DBG_FULLPREFIX "(" ROAR_DBG_PREFIX ": " __FILE__ ":%i): "
85
86#if __GNUC__ < 3
87 #define ROAR_DBG(format, args...)
88 #define ROAR_ERR(format, args...)
89 #define ROAR_WARN(format, args...)
90#else
91
92#ifdef DEBUG
93 #define ROAR_DBG(format, args...)  fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "DEBUG: " format "\n", __LINE__, ## args)
94#else
95 #define ROAR_DBG(format, args...)
96#endif
97
98#define ROAR_ERR(format, args...)  fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "Error: "   format "\n", __LINE__, ## args)
99#define ROAR_WARN(format, args...) fprintf(ROAR_DEBUG_OUTFH, ROAR_DBG_FULLPREFIX "Warning: " format "\n", __LINE__, ## args)
100
101#endif
102
103#ifdef ROAR_HAVE_SAFE_OVERFLOW
104#define ROAR_MATH_OVERFLOW_ADD(a, b) ((a)+(b))
105#else
106#define ROAR_MATH_OVERFLOW_ADD(a, b) ((4294967295U - (a)) + 1 + (b))
107#endif
108
109#ifdef ROAR_HAVE_MLOCK
110#ifdef __linux__
111#define ROAR_MLOCK(p,s) mlock((p), (s))
112#else
113#undef ROAR_HAVE_MLOCK
114#define ROAR_MLOCK(p,s)
115#warning No working mlock() support for this platform
116#endif
117#endif
118
119
120#if BYTE_ORDER == BIG_ENDIAN
121
122#define ROAR_NET2HOST32(x) (x)
123#define ROAR_HOST2NET32(x) (x)
124#define ROAR_NET2HOST16(x) (x)
125#define ROAR_HOST2NET16(x) (x)
126
127#ifdef ROAR_HAVE_LIBDNET
128#define ROAR_dn_ntohs(x) ((((x)&0x0ff)<<8) | (((x)&0xff00)>>8))
129#define ROAR_dn_ntohl(x) ( ((dn_ntohs((x)&0xffff))<<16) |\
130                           ((dn_ntohs(((x)>>16)))) )
131#define ROAR_dn_htonl(x) ROAR_dn_ntohl(x)
132#define ROAR_dn_htons(x) ROAR_dn_ntohs(x)
133#endif
134
135//#elif BYTE_ORDER == LITTLE_ENDIAN
136#else
137
138#define ROAR_NET2HOST32(x) ntohl((x))
139#define ROAR_HOST2NET32(x) htonl((x))
140#define ROAR_NET2HOST16(x) ntohs((x))
141#define ROAR_HOST2NET16(x) htons((x))
142
143#ifdef ROAR_HAVE_LIBDNET
144#if BYTE_ORDER == LITTLE_ENDIAN
145#define ROAR_dn_ntohs(x) (x)
146#define ROAR_dn_htons(x) (x)
147
148#define ROAR_dn_ntohl(x) (x)
149#define ROAR_dn_htonl(x) (x)
150#else
151#error can not build on this architecture with DECnet support enabled
152#endif
153#endif
154
155#endif
156
157#endif
158
159//ll
Note: See TracBrowser for help on using the repository browser.