1 /* $OpenBSD: mio_priv.h,v 1.5 2011/04/12 21:40:22 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 MIO_PRIV_H 18 #define MIO_PRIV_H 19 20 #include <sys/param.h> 21 #include "sndio.h" 22 23 #ifdef DEBUG 24 #define DPRINTF(...) \ 25 do { \ 26 if (mio_debug > 0) \ 27 fprintf(stderr, __VA_ARGS__); \ 28 } while(0) 29 #define DPERROR(s) \ 30 do { \ 31 if (mio_debug > 0) \ 32 perror(s); \ 33 } while(0) 34 #else 35 #define DPRINTF(...) do {} while(0) 36 #define DPERROR(s) do {} while(0) 37 #endif 38 39 /* 40 * private ``handle'' structure 41 */ 42 struct mio_hdl { 43 struct mio_ops *ops; 44 unsigned mode; /* MIO_IN | MIO_OUT */ 45 int nbio; /* true if non-blocking io */ 46 int eof; /* true if error occured */ 47 }; 48 49 /* 50 * operations every device should support 51 */ 52 struct mio_ops { 53 void (*close)(struct mio_hdl *); 54 size_t (*write)(struct mio_hdl *, const void *, size_t); 55 size_t (*read)(struct mio_hdl *, void *, size_t); 56 int (*pollfd)(struct mio_hdl *, struct pollfd *, int); 57 int (*revents)(struct mio_hdl *, struct pollfd *); 58 }; 59 60 struct mio_hdl *mio_rmidi_open(const char *, unsigned, int); 61 struct mio_hdl *mio_midithru_open(const char *, unsigned, int); 62 struct mio_hdl *mio_aucat_open(const char *, unsigned, int); 63 void mio_create(struct mio_hdl *, struct mio_ops *, unsigned, int); 64 void mio_destroy(struct mio_hdl *); 65 66 #ifdef DEBUG 67 extern int mio_debug; 68 #endif 69 70 #endif /* !defined(MIO_PRIV_H) */ 71