1 | //sndiosym.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2010 |
---|
5 | * The code (may) include prototypes and comments (and maybe |
---|
6 | * other code fragements) from OpenBSD's sndio. |
---|
7 | * See 'Copyright for sndio' below for more information on |
---|
8 | * code fragments taken from OpenBSD's sndio. |
---|
9 | * |
---|
10 | * --- Copyright for sndio --- |
---|
11 | * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> |
---|
12 | * |
---|
13 | * Permission to use, copy, modify, and distribute this software for any |
---|
14 | * purpose with or without fee is hereby granted, provided that the above |
---|
15 | * copyright notice and this permission notice appear in all copies. |
---|
16 | * |
---|
17 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
---|
18 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
---|
19 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
---|
20 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
---|
21 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
---|
22 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
---|
23 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
---|
24 | * --- End of Copyright for sndio --- |
---|
25 | * |
---|
26 | * This file is part of libroaresd a part of RoarAudio, |
---|
27 | * a cross-platform sound system for both, home and professional use. |
---|
28 | * See README for details. |
---|
29 | * |
---|
30 | * This file is free software; you can redistribute it and/or modify |
---|
31 | * it under the terms of the GNU General Public License version 3 |
---|
32 | * as published by the Free Software Foundation. |
---|
33 | * |
---|
34 | * RoarAudio is distributed in the hope that it will be useful, |
---|
35 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
36 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
37 | * GNU General Public License for more details. |
---|
38 | * |
---|
39 | * You should have received a copy of the GNU General Public License |
---|
40 | * along with this software; see the file COPYING. If not, write to |
---|
41 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
42 | * |
---|
43 | * NOTE for everyone want's to change something and send patches: |
---|
44 | * read README and HACKING! There a addition information on |
---|
45 | * the license of this document you need to read before you send |
---|
46 | * any patches. |
---|
47 | */ |
---|
48 | |
---|
49 | #ifndef _LIBROARSNDIO_SNDIOSYM_H_ |
---|
50 | #define _LIBROARSNDIO_SNDIOSYM_H_ |
---|
51 | |
---|
52 | #include <roaraudio.h> |
---|
53 | |
---|
54 | #ifdef ROAR_HAVE_H_POLL |
---|
55 | #include <poll.h> |
---|
56 | #else |
---|
57 | struct pollfd; |
---|
58 | #endif |
---|
59 | |
---|
60 | #define SIO_PLAY 1 |
---|
61 | #define SIO_REC 2 |
---|
62 | #define MIO_OUT 4 |
---|
63 | #define MIO_IN 8 |
---|
64 | |
---|
65 | #define SIO_IGNORE 0 /* pause during xrun */ |
---|
66 | #define SIO_SYNC 1 /* resync after xrun */ |
---|
67 | #define SIO_ERROR 2 /* terminate on xrun */ |
---|
68 | #define SIO_XSTRINGS {"ignore", "sync", "error"} |
---|
69 | |
---|
70 | #define SIO_NENC 16 |
---|
71 | #define SIO_NCHAN 8 |
---|
72 | #define SIO_NRATE 16 |
---|
73 | #define SIO_NCONF 4 |
---|
74 | |
---|
75 | #define SIO_ENCMAX 10 |
---|
76 | |
---|
77 | #if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32) |
---|
78 | #define SIO_LE_NATIVE 0 |
---|
79 | #else |
---|
80 | #if BYTE_ORDER == LITTLE_ENDIAN |
---|
81 | #define SIO_LE_NATIVE 1 |
---|
82 | #else |
---|
83 | #error Byte Order of this system is not supported within the sndio interface. |
---|
84 | #endif |
---|
85 | #endif |
---|
86 | |
---|
87 | #define SIO_BPS(bits) (((bits) <= 8) ? 1 : (((bits) <= 16) ? 2 : 4)) |
---|
88 | |
---|
89 | #define SIO_SUN_PATH NULL |
---|
90 | #define SIO_AUCAT_PATH NULL |
---|
91 | |
---|
92 | #define SIO_MAXVOL 127 |
---|
93 | |
---|
94 | |
---|
95 | struct sio_par { |
---|
96 | unsigned bits; /* bits per sample */ |
---|
97 | unsigned bps; /* bytes per sample */ |
---|
98 | unsigned sig; /* 1 = signed, 0 = unsigned */ |
---|
99 | unsigned le; /* 1 = LE, 0 = BE byte order */ |
---|
100 | unsigned msb; /* 1 = MSB, 0 = LSB aligned */ |
---|
101 | unsigned rchan; /* number channels for recording */ |
---|
102 | unsigned pchan; /* number channels for playback */ |
---|
103 | unsigned rate; /* frames per second */ |
---|
104 | unsigned appbufsz; /* minimum buffer size without xruns */ |
---|
105 | unsigned bufsz; /* end-to-end buffer size (read-only) */ |
---|
106 | unsigned round; /* optimal buffer size divisor */ |
---|
107 | unsigned xrun; /* what to do on overrun/underrun */ |
---|
108 | }; |
---|
109 | |
---|
110 | struct sio_cap { |
---|
111 | struct sio_enc { /* allowed encodings */ |
---|
112 | unsigned bits; /* bits per sample */ |
---|
113 | unsigned bps; /* bytes per sample */ |
---|
114 | unsigned sig; /* 1 = signed, 0 = unsigned */ |
---|
115 | unsigned le; /* 1 = LE, 0 = BE byte order */ |
---|
116 | unsigned msb; /* 1 = MSB, 0 = LSB aligned */ |
---|
117 | } enc[SIO_NENC]; |
---|
118 | unsigned rchan[SIO_NCHAN]; /* allowed rchans */ |
---|
119 | unsigned pchan[SIO_NCHAN]; /* allowed pchans */ |
---|
120 | unsigned rate[SIO_NRATE]; /* allowed rates */ |
---|
121 | unsigned nconf; /* num. of confs[] */ |
---|
122 | struct sio_conf { |
---|
123 | unsigned enc; /* bitmask of enc[] indexes */ |
---|
124 | unsigned rchan; /* bitmask of rchan[] indexes */ |
---|
125 | unsigned pchan; /* bitmask of pchan[] indexes */ |
---|
126 | unsigned rate; /* bitmask of rate[] indexes */ |
---|
127 | } confs[SIO_NCONF]; |
---|
128 | }; |
---|
129 | |
---|
130 | struct sio_hdl * sio_open(const char * name, unsigned mode, int nbio_flag); |
---|
131 | void sio_close (struct sio_hdl * hdl); |
---|
132 | |
---|
133 | void sio_initpar(struct sio_par * par); |
---|
134 | int sio_setpar (struct sio_hdl * hdl, struct sio_par * par); |
---|
135 | int sio_getpar (struct sio_hdl * hdl, struct sio_par * par); |
---|
136 | |
---|
137 | int sio_getcap (struct sio_hdl * hdl, struct sio_cap * cap); |
---|
138 | |
---|
139 | int sio_start (struct sio_hdl * hdl); |
---|
140 | int sio_stop (struct sio_hdl * hdl); |
---|
141 | |
---|
142 | size_t sio_read (struct sio_hdl * hdl, void * addr, size_t nbytes); |
---|
143 | size_t sio_write (struct sio_hdl * hdl, const void * addr, size_t nbytes); |
---|
144 | |
---|
145 | void sio_onmove (struct sio_hdl * hdl, void (*cb)(void * arg, int delta), void * arg); |
---|
146 | |
---|
147 | int sio_nfds (struct sio_hdl * hdl); |
---|
148 | |
---|
149 | int sio_pollfd (struct sio_hdl * hdl, struct pollfd * pfd, int events); |
---|
150 | |
---|
151 | int sio_revents(struct sio_hdl * hdl, struct pollfd * pfd); |
---|
152 | |
---|
153 | int sio_eof (struct sio_hdl * hdl); |
---|
154 | |
---|
155 | int sio_setvol (struct sio_hdl * hdl, unsigned vol); |
---|
156 | void sio_onvol (struct sio_hdl * hdl, void (*cb)(void * arg, unsigned vol), void * arg); |
---|
157 | |
---|
158 | // MIDI: |
---|
159 | struct mio_hdl * mio_open (const char * name, unsigned mode, int nbio_flag); |
---|
160 | void mio_close (struct mio_hdl * hdl); |
---|
161 | size_t mio_write (struct mio_hdl * hdl, const void * addr, size_t nbytes); |
---|
162 | size_t mio_read (struct mio_hdl * hdl, void * addr, size_t nbytes); |
---|
163 | int mio_nfds (struct mio_hdl * hdl); |
---|
164 | int mio_pollfd (struct mio_hdl * hdl, struct pollfd * pfd, int events); |
---|
165 | int mio_revents(struct mio_hdl * hdl, struct pollfd * pfd); |
---|
166 | int mio_eof (struct mio_hdl * hdl); |
---|
167 | |
---|
168 | #endif |
---|
169 | |
---|
170 | //ll |
---|