xref: /openbsd-src/lib/libsndio/mio_priv.h (revision d20001a803bf8b9a154852114830dee9c70d1206)
1*d20001a8Sjsg /*	$OpenBSD: mio_priv.h,v 1.14 2024/05/21 06:07:06 jsg Exp $	*/
26efede29Sratchov /*
36efede29Sratchov  * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
46efede29Sratchov  *
56efede29Sratchov  * Permission to use, copy, modify, and distribute this software for any
66efede29Sratchov  * purpose with or without fee is hereby granted, provided that the above
76efede29Sratchov  * copyright notice and this permission notice appear in all copies.
86efede29Sratchov  *
96efede29Sratchov  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
106efede29Sratchov  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
116efede29Sratchov  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
126efede29Sratchov  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
136efede29Sratchov  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
146efede29Sratchov  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
156efede29Sratchov  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
166efede29Sratchov  */
176efede29Sratchov #ifndef MIO_PRIV_H
186efede29Sratchov #define MIO_PRIV_H
196efede29Sratchov 
206efede29Sratchov #include "sndio.h"
216efede29Sratchov 
22cfb56cbfSratchov #define MIO_MAXNFDS	16
23cfb56cbfSratchov 
246efede29Sratchov /*
256efede29Sratchov  * private ``handle'' structure
266efede29Sratchov  */
276efede29Sratchov struct mio_hdl {
286efede29Sratchov 	struct mio_ops *ops;
29251b7ab1Sratchov 	unsigned mode;			/* MIO_IN | MIO_OUT */
306efede29Sratchov 	int nbio;			/* true if non-blocking io */
312c53affbSjmc 	int eof;			/* true if error occurred */
326efede29Sratchov };
336efede29Sratchov 
346efede29Sratchov /*
356efede29Sratchov  * operations every device should support
366efede29Sratchov  */
376efede29Sratchov struct mio_ops {
386efede29Sratchov 	void (*close)(struct mio_hdl *);
394c244198Sratchov 	size_t (*write)(struct mio_hdl *, const void *, size_t);
406efede29Sratchov 	size_t (*read)(struct mio_hdl *, void *, size_t);
41cfb56cbfSratchov 	int (*nfds)(struct mio_hdl *);
426efede29Sratchov 	int (*pollfd)(struct mio_hdl *, struct pollfd *, int);
436efede29Sratchov 	int (*revents)(struct mio_hdl *, struct pollfd *);
446efede29Sratchov };
456efede29Sratchov 
46d418f94bSratchov struct mio_hdl *_mio_rmidi_open(const char *, unsigned, int);
47163486f8Sratchov struct mio_hdl *_mio_aucat_open(const char *, unsigned, int);
48d418f94bSratchov void _mio_create(struct mio_hdl *, struct mio_ops *, unsigned, int);
496efede29Sratchov 
506efede29Sratchov #endif /* !defined(MIO_PRIV_H) */
51