[1552] | 1 | //sndiosym.h: |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009 |
---|
| 5 | * The code (may) include prototypes and comments (and maybe |
---|
| 6 | * other code fragements) from EsounD. |
---|
| 7 | * They are mostly copyrighted by Eric B. Mitchell (aka 'Ricdude) |
---|
| 8 | * <ericmit@ix.netcom.com>. For more information see AUTHORS.esd. |
---|
| 9 | * |
---|
| 10 | * This file is part of libroaresd a part of RoarAudio, |
---|
| 11 | * a cross-platform sound system for both, home and professional use. |
---|
| 12 | * See README for details. |
---|
| 13 | * |
---|
| 14 | * This file is free software; you can redistribute it and/or modify |
---|
| 15 | * it under the terms of the GNU General Public License version 3 |
---|
| 16 | * as published by the Free Software Foundation. |
---|
| 17 | * |
---|
| 18 | * RoarAudio is distributed in the hope that it will be useful, |
---|
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 21 | * GNU General Public License for more details. |
---|
| 22 | * |
---|
| 23 | * You should have received a copy of the GNU General Public License |
---|
| 24 | * along with this software; see the file COPYING. If not, write to |
---|
[3517] | 25 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 26 | * Boston, MA 02110-1301, USA. |
---|
[1552] | 27 | * |
---|
| 28 | * NOTE for everyone want's to change something and send patches: |
---|
| 29 | * read README and HACKING! There a addition information on |
---|
| 30 | * the license of this document you need to read before you send |
---|
| 31 | * any patches. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | #ifndef _LIBROARSNDIO_SNDIOSYM_H_ |
---|
| 35 | #define _LIBROARSNDIO_SNDIOSYM_H_ |
---|
| 36 | |
---|
| 37 | #include <roaraudio.h> |
---|
| 38 | |
---|
[1554] | 39 | #ifdef ROAR_HAVE_H_POLL |
---|
| 40 | #include <poll.h> |
---|
| 41 | #else |
---|
| 42 | struct pollfd; |
---|
| 43 | #endif |
---|
| 44 | |
---|
| 45 | #define SIO_PLAY 1 |
---|
| 46 | #define SIO_REC 2 |
---|
[2351] | 47 | #define MIO_OUT 4 |
---|
| 48 | #define MIO_IN 8 |
---|
[1554] | 49 | |
---|
| 50 | #define SIO_IGNORE 0 /* pause during xrun */ |
---|
| 51 | #define SIO_SYNC 1 /* resync after xrun */ |
---|
| 52 | #define SIO_ERROR 2 /* terminate on xrun */ |
---|
[1578] | 53 | #define SIO_XSTRINGS {"ignore", "sync", "error"} |
---|
| 54 | |
---|
[3240] | 55 | #define SIO_NENC 16 |
---|
[1578] | 56 | #define SIO_NCHAN 8 |
---|
| 57 | #define SIO_NRATE 16 |
---|
| 58 | #define SIO_NCONF 4 |
---|
| 59 | |
---|
| 60 | #define SIO_ENCMAX 10 |
---|
[1554] | 61 | |
---|
| 62 | #if BYTE_ORDER == BIG_ENDIAN && !defined(ROAR_TARGET_WIN32) |
---|
| 63 | #define SIO_LE_NATIVE 0 |
---|
| 64 | #else |
---|
| 65 | #if BYTE_ORDER == LITTLE_ENDIAN |
---|
| 66 | #define SIO_LE_NATIVE 1 |
---|
| 67 | #else |
---|
| 68 | #error Byte Order of this system is not supported within the sndio interface. |
---|
| 69 | #endif |
---|
| 70 | #endif |
---|
| 71 | |
---|
[1578] | 72 | #define SIO_BPS(bits) (((bits) <= 8) ? 1 : (((bits) <= 16) ? 2 : 4)) |
---|
[1554] | 73 | |
---|
[1578] | 74 | #define SIO_SUN_PATH NULL |
---|
| 75 | #define SIO_AUCAT_PATH NULL |
---|
| 76 | |
---|
| 77 | #define SIO_MAXVOL 127 |
---|
| 78 | |
---|
[1574] | 79 | |
---|
[1554] | 80 | struct sio_par { |
---|
| 81 | unsigned bits; /* bits per sample */ |
---|
| 82 | unsigned bps; /* bytes per sample */ |
---|
| 83 | unsigned sig; /* 1 = signed, 0 = unsigned */ |
---|
| 84 | unsigned le; /* 1 = LE, 0 = BE byte order */ |
---|
| 85 | unsigned msb; /* 1 = MSB, 0 = LSB aligned */ |
---|
| 86 | unsigned rchan; /* number channels for recording */ |
---|
| 87 | unsigned pchan; /* number channels for playback */ |
---|
| 88 | unsigned rate; /* frames per second */ |
---|
| 89 | unsigned appbufsz; /* minimum buffer size without xruns */ |
---|
| 90 | unsigned bufsz; /* end-to-end buffer size (read-only) */ |
---|
| 91 | unsigned round; /* optimal buffer size divisor */ |
---|
| 92 | unsigned xrun; /* what to do on overrun/underrun */ |
---|
| 93 | }; |
---|
| 94 | |
---|
[3239] | 95 | struct sio_cap { |
---|
| 96 | struct sio_enc { /* allowed encodings */ |
---|
| 97 | unsigned bits; /* bits per sample */ |
---|
| 98 | unsigned bps; /* bytes per sample */ |
---|
| 99 | unsigned sig; /* 1 = signed, 0 = unsigned */ |
---|
| 100 | unsigned le; /* 1 = LE, 0 = BE byte order */ |
---|
| 101 | unsigned msb; /* 1 = MSB, 0 = LSB aligned */ |
---|
| 102 | } enc[SIO_NENC]; |
---|
| 103 | unsigned rchan[SIO_NCHAN]; /* allowed rchans */ |
---|
| 104 | unsigned pchan[SIO_NCHAN]; /* allowed pchans */ |
---|
| 105 | unsigned rate[SIO_NRATE]; /* allowed rates */ |
---|
| 106 | unsigned nconf; /* num. of confs[] */ |
---|
| 107 | struct sio_conf { |
---|
| 108 | unsigned enc; /* bitmask of enc[] indexes */ |
---|
| 109 | unsigned rchan; /* bitmask of rchan[] indexes */ |
---|
| 110 | unsigned pchan; /* bitmask of pchan[] indexes */ |
---|
| 111 | unsigned rate; /* bitmask of rate[] indexes */ |
---|
| 112 | } confs[SIO_NCONF]; |
---|
| 113 | }; |
---|
[1556] | 114 | |
---|
[2574] | 115 | struct sio_hdl * sio_open(const char * name, unsigned mode, int nbio_flag); |
---|
[1554] | 116 | void sio_close (struct sio_hdl * hdl); |
---|
| 117 | |
---|
| 118 | void sio_initpar(struct sio_par * par); |
---|
| 119 | int sio_setpar (struct sio_hdl * hdl, struct sio_par * par); |
---|
| 120 | int sio_getpar (struct sio_hdl * hdl, struct sio_par * par); |
---|
| 121 | |
---|
| 122 | int sio_getcap (struct sio_hdl * hdl, struct sio_cap * cap); |
---|
| 123 | |
---|
| 124 | int sio_start (struct sio_hdl * hdl); |
---|
| 125 | int sio_stop (struct sio_hdl * hdl); |
---|
| 126 | |
---|
[2574] | 127 | size_t sio_read (struct sio_hdl * hdl, void * addr, size_t nbytes); |
---|
| 128 | size_t sio_write (struct sio_hdl * hdl, const void * addr, size_t nbytes); |
---|
[1554] | 129 | |
---|
| 130 | void sio_onmove (struct sio_hdl * hdl, void (*cb)(void * arg, int delta), void * arg); |
---|
| 131 | |
---|
| 132 | int sio_nfds (struct sio_hdl * hdl); |
---|
| 133 | |
---|
| 134 | int sio_pollfd (struct sio_hdl * hdl, struct pollfd * pfd, int events); |
---|
| 135 | |
---|
| 136 | int sio_revents(struct sio_hdl * hdl, struct pollfd * pfd); |
---|
| 137 | |
---|
| 138 | int sio_eof (struct sio_hdl * hdl); |
---|
| 139 | |
---|
| 140 | int sio_setvol (struct sio_hdl * hdl, unsigned vol); |
---|
| 141 | void sio_onvol (struct sio_hdl * hdl, void (*cb)(void * arg, unsigned vol), void * arg); |
---|
| 142 | |
---|
[2351] | 143 | // MIDI: |
---|
| 144 | struct mio_hdl * mio_open (const char * name, unsigned mode, int nbio_flag); |
---|
| 145 | void mio_close (struct mio_hdl * hdl); |
---|
| 146 | size_t mio_write (struct mio_hdl * hdl, const void * addr, size_t nbytes); |
---|
| 147 | size_t mio_read (struct mio_hdl * hdl, void * addr, size_t nbytes); |
---|
| 148 | int mio_nfds (struct mio_hdl * hdl); |
---|
| 149 | int mio_pollfd (struct mio_hdl * hdl, struct pollfd * pfd, int events); |
---|
| 150 | int mio_revents(struct mio_hdl * hdl, struct pollfd * pfd); |
---|
| 151 | int mio_eof (struct mio_hdl * hdl); |
---|
| 152 | |
---|
[1552] | 153 | #endif |
---|
| 154 | |
---|
| 155 | //ll |
---|