xref: /openbsd-src/usr.bin/sndiod/defs.h (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /*	$OpenBSD: defs.h,v 1.2 2012/12/07 08:04:58 ratchov Exp $	*/
2 /*
3  * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 #ifndef DEFS_H
18 #define DEFS_H
19 
20 /*
21  * MIDI buffer size
22  */
23 #define MIDI_BUFSZ		3125	/* 1 second at 31.25kbit/s */
24 
25 /*
26  * units used for MTC clock.
27  */
28 #define MTC_SEC			2400	/* 1 second is 2400 ticks */
29 
30 /*
31  * device or sub-device mode, must be a superset of corresponding SIO_
32  * and MIO_ constants
33  */
34 #define MODE_PLAY	0x01	/* allowed to play */
35 #define MODE_REC	0x02	/* allowed to rec */
36 #define MODE_MIDIOUT	0x04	/* allowed to read midi */
37 #define MODE_MIDIIN	0x08	/* allowed to write midi */
38 #define MODE_MON	0x10	/* allowed to monitor */
39 #define MODE_RECMASK	(MODE_REC | MODE_MON)
40 #define MODE_AUDIOMASK	(MODE_PLAY | MODE_REC | MODE_MON)
41 #define MODE_MIDIMASK	(MODE_MIDIIN | MODE_MIDIOUT)
42 
43 /*
44  * underrun/overrun policies, must be the same as SIO_ constants
45  */
46 #define XRUN_IGNORE	0	/* on xrun silently insert/discard samples */
47 #define XRUN_SYNC	1	/* catchup to sync to the mix/sub */
48 #define XRUN_ERROR	2	/* xruns are errors, eof/hup buffer */
49 
50 /*
51  * limits
52  */
53 #define NCHAN_MAX	16		/* max channel in a stream */
54 #define RATE_MIN	4000		/* min sample rate */
55 #define RATE_MAX	192000		/* max sample rate */
56 #define BITS_MIN	1		/* min bits per sample */
57 #define BITS_MAX	32		/* max bits per sample */
58 
59 #endif /* !defined(DEFS_H) */
60