xref: /openbsd-src/lib/libsndio/sio_priv.h (revision 6f05df2d9be0954bec42d51d943d77bd250fb664)
1 /*	$OpenBSD: sio_priv.h,v 1.8 2014/03/05 20:40:49 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 	int rdrop;			/* recorded bytes to drop */
39 	int wsil;			/* silence to play */
40 	int rused;			/* bytes used in read buffer */
41 	int wused;			/* bytes used in write buffer */
42 	long long cpos;			/* clock since start */
43 	struct sio_par par;
44 #ifdef DEBUG
45 	unsigned long long pollcnt;	/* times sio_revents was called */
46 	long long start_nsec;
47 #endif
48 };
49 
50 /*
51  * operations every device should support
52  */
53 struct sio_ops {
54 	void (*close)(struct sio_hdl *);
55 	int (*setpar)(struct sio_hdl *, struct sio_par *);
56 	int (*getpar)(struct sio_hdl *, struct sio_par *);
57 	int (*getcap)(struct sio_hdl *, struct sio_cap *);
58 	size_t (*write)(struct sio_hdl *, const void *, size_t);
59 	size_t (*read)(struct sio_hdl *, void *, size_t);
60 	int (*start)(struct sio_hdl *);
61 	int (*stop)(struct sio_hdl *);
62 	int (*nfds)(struct sio_hdl *);
63 	int (*pollfd)(struct sio_hdl *, struct pollfd *, int);
64 	int (*revents)(struct sio_hdl *, struct pollfd *);
65 	int (*setvol)(struct sio_hdl *, unsigned);
66 	void (*getvol)(struct sio_hdl *);
67 };
68 
69 struct sio_hdl *_sio_aucat_open(const char *, unsigned, int);
70 struct sio_hdl *_sio_sun_open(const char *, unsigned, int);
71 void _sio_create(struct sio_hdl *, struct sio_ops *, unsigned, int);
72 void _sio_destroy(struct sio_hdl *);
73 void _sio_onmove_cb(struct sio_hdl *, int);
74 void _sio_onvol_cb(struct sio_hdl *, unsigned);
75 #ifdef DEBUG
76 void _sio_printpos(struct sio_hdl *);
77 #endif
78 
79 #endif /* !defined(SNDIO_PRIV_H) */
80