source: roaraudio/include/libroarsndio/sndiosym.h @ 6081:2a01850a9a8b

Last change on this file since 6081:2a01850a9a8b was 6081:2a01850a9a8b, checked in by phi, 9 years ago

Fix: Updated structs to match libsndio

File size: 6.5 KB
Line 
1//sndiosym.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2015
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
57struct pollfd;
58#endif
59
60#define SIO_DEVANY      "default"
61#define MIO_PORTANY     "default"
62
63#define SIO_PLAY        1
64#define SIO_REC         2
65#define MIO_OUT         4
66#define MIO_IN          8
67
68#define SIO_IGNORE      0       /* pause during xrun */
69#define SIO_SYNC        1       /* resync after xrun */
70#define SIO_ERROR       2       /* terminate on xrun */
71#define SIO_XSTRINGS    {"ignore", "sync", "error"}
72
73#define SIO_NENC        8
74#define SIO_NCHAN       8
75#define SIO_NRATE       16
76#define SIO_NCONF       4
77
78#define SIO_ENCMAX      10
79
80#if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32)
81#define SIO_LE_NATIVE   0
82#else
83#if BYTE_ORDER == LITTLE_ENDIAN
84#define SIO_LE_NATIVE   1
85#else
86#error Byte Order of this system is not supported within the sndio interface.
87#endif
88#endif
89
90#define SIO_BPS(bits) (((bits) <= 8) ? 1 : (((bits) <= 16) ? 2 : 4))
91
92#define SIO_SUN_PATH    NULL
93#define SIO_AUCAT_PATH  NULL
94
95#define SIO_MAXVOL 127
96
97
98struct sio_par {
99 unsigned bits;          /* bits per sample */
100 unsigned bps;           /* bytes per sample */
101 unsigned sig;           /* 1 = signed, 0 = unsigned */
102 unsigned le;            /* 1 = LE, 0 = BE byte order */
103 unsigned msb;           /* 1 = MSB, 0 = LSB aligned */
104 unsigned rchan;         /* number channels for recording */
105 unsigned pchan;         /* number channels for playback */
106 unsigned rate;          /* frames per second */
107 unsigned bufsz;         /* end-to-end buffer size (read-only) */
108 unsigned xrun;          /* what to do on overrun/underrun */
109 unsigned round;         /* optimal buffer size divisor */
110 unsigned appbufsz;      /* minimum buffer size without xruns */
111 int __pad[3];           /* for future use */
112 unsigned int __magic;   /* for internal/debug purposes only */
113};
114
115struct sio_cap {
116 struct sio_enc {                /* allowed encodings */
117  unsigned bits;                 /* bits per sample */
118  unsigned bps;                  /* bytes per sample */
119  unsigned sig;                  /* 1 = signed, 0 = unsigned */
120  unsigned le;                   /* 1 = LE, 0 = BE byte order */
121  unsigned msb;                  /* 1 = MSB, 0 = LSB aligned */
122 } enc[SIO_NENC];
123 unsigned rchan[SIO_NCHAN];      /* allowed rchans */
124 unsigned pchan[SIO_NCHAN];      /* allowed pchans */
125 unsigned rate[SIO_NRATE];       /* allowed rates */
126 int __pad[7];                   /* for future use */
127 unsigned nconf;                 /* num. of confs[] */
128 struct sio_conf {
129  unsigned enc;                  /* bitmask of enc[] indexes */
130  unsigned rchan;                /* bitmask of rchan[] indexes */
131  unsigned pchan;                /* bitmask of pchan[] indexes */
132  unsigned rate;                 /* bitmask of rate[] indexes */
133 } confs[SIO_NCONF];
134};
135
136struct sio_hdl * sio_open(const char * name, unsigned mode, int nbio_flag);
137void   sio_close  (struct sio_hdl * hdl);
138
139void   sio_initpar(struct sio_par * par);
140int    sio_setpar (struct sio_hdl * hdl, struct sio_par * par);
141int    sio_getpar (struct sio_hdl * hdl, struct sio_par * par);
142
143int    sio_getcap (struct sio_hdl * hdl, struct sio_cap * cap);
144
145int    sio_start  (struct sio_hdl * hdl);
146int    sio_stop   (struct sio_hdl * hdl);
147
148size_t sio_read   (struct sio_hdl * hdl,       void * addr, size_t nbytes);
149size_t sio_write  (struct sio_hdl * hdl, const void * addr, size_t nbytes);
150
151void   sio_onmove (struct sio_hdl * hdl, void (*cb)(void * arg, int delta), void * arg);
152
153int    sio_nfds   (struct sio_hdl * hdl);
154
155int    sio_pollfd (struct sio_hdl * hdl, struct pollfd * pfd, int events);
156
157int    sio_revents(struct sio_hdl * hdl, struct pollfd * pfd);
158
159int    sio_eof    (struct sio_hdl * hdl);
160
161int    sio_setvol (struct sio_hdl * hdl, unsigned vol);
162void   sio_onvol  (struct sio_hdl * hdl, void (*cb)(void * arg, unsigned vol), void * arg);
163
164// MIDI:
165struct mio_hdl * mio_open   (const char * name, unsigned mode, int nbio_flag);
166void             mio_close  (struct mio_hdl * hdl);
167size_t           mio_write  (struct mio_hdl * hdl, const void * addr, size_t nbytes);
168size_t           mio_read   (struct mio_hdl * hdl, void * addr, size_t nbytes);
169int              mio_nfds   (struct mio_hdl * hdl);
170int              mio_pollfd (struct mio_hdl * hdl, struct pollfd * pfd, int events);
171int              mio_revents(struct mio_hdl * hdl, struct pollfd * pfd);
172int              mio_eof    (struct mio_hdl * hdl);
173
174#endif
175
176//ll
Note: See TracBrowser for help on using the repository browser.