xref: /openbsd/lib/libsndio/sio_priv.h (revision 898184e3)
1 /*	$OpenBSD: sio_priv.h,v 1.4 2012/10/27 12:06:40 ratchov Exp $	*/
2 /*
3  * Copyright (c) 2008 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 SNDIO_PRIV_H
18 #define SNDIO_PRIV_H
19 
20 #include <sys/param.h>
21 #include "sndio.h"
22 
23 #define SIO_MAXNFDS	16
24 
25 /*
26  * private ``handle'' structure
27  */
28 struct sio_hdl {
29 	struct sio_ops *ops;
30 	void (*move_cb)(void *, int);	/* call-back for realpos changes */
31 	void *move_addr;		/* user priv. data for move_cb */
32 	void (*vol_cb)(void *, unsigned); /* call-back for volume changes */
33 	void *vol_addr;			/* user priv. data for vol_cb */
34 	unsigned mode;			/* SIO_PLAY | SIO_REC */
35 	int started;			/* true if started */
36 	int nbio;			/* true if non-blocking io */
37 	int eof;			/* true if error occured */
38 #ifdef DEBUG
39 	unsigned long long pollcnt;	/* times sio_revents was called */
40 	unsigned long long wcnt;	/* bytes written with sio_write() */
41 	unsigned long long rcnt;	/* bytes read with sio_read() */
42 	long long realpos;
43 	struct timeval tv;
44 	struct sio_par par;
45 #endif
46 };
47 
48 /*
49  * operations every device should support
50  */
51 struct sio_ops {
52 	void (*close)(struct sio_hdl *);
53 	int (*setpar)(struct sio_hdl *, struct sio_par *);
54 	int (*getpar)(struct sio_hdl *, struct sio_par *);
55 	int (*getcap)(struct sio_hdl *, struct sio_cap *);
56 	size_t (*write)(struct sio_hdl *, const void *, size_t);
57 	size_t (*read)(struct sio_hdl *, void *, size_t);
58 	int (*start)(struct sio_hdl *);
59 	int (*stop)(struct sio_hdl *);
60 	int (*nfds)(struct sio_hdl *);
61 	int (*pollfd)(struct sio_hdl *, struct pollfd *, int);
62 	int (*revents)(struct sio_hdl *, struct pollfd *);
63 	int (*setvol)(struct sio_hdl *, unsigned);
64 	void (*getvol)(struct sio_hdl *);
65 };
66 
67 struct sio_hdl *sio_aucat_open(const char *, unsigned, int);
68 struct sio_hdl *sio_sun_open(const char *, unsigned, int);
69 void sio_create(struct sio_hdl *, struct sio_ops *, unsigned, int);
70 void sio_destroy(struct sio_hdl *);
71 void sio_onmove_cb(struct sio_hdl *, int);
72 void sio_onvol_cb(struct sio_hdl *, unsigned);
73 
74 #endif /* !defined(SNDIO_PRIV_H) */
75