1 /* $OpenBSD: sio_priv.h,v 1.12 2024/05/21 06:07:06 jsg 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 "sndio.h" 21 22 #define SIO_MAXNFDS 16 23 24 /* 25 * private ``handle'' structure 26 */ 27 struct sio_hdl { 28 struct sio_ops *ops; 29 void (*move_cb)(void *, int); /* call-back for realpos changes */ 30 void *move_addr; /* user priv. data for move_cb */ 31 void (*vol_cb)(void *, unsigned); /* call-back for volume changes */ 32 void *vol_addr; /* user priv. data for vol_cb */ 33 unsigned mode; /* SIO_PLAY | SIO_REC */ 34 int started; /* true if started */ 35 int nbio; /* true if non-blocking io */ 36 int eof; /* true if error occurred */ 37 int rdrop; /* recorded bytes to drop */ 38 int wsil; /* silence to play */ 39 int rused; /* bytes used in read buffer */ 40 int wused; /* bytes used in write buffer */ 41 long long cpos; /* clock since start */ 42 struct sio_par par; 43 #ifdef DEBUG 44 unsigned long long pollcnt; /* times sio_revents was called */ 45 long long start_nsec; 46 #endif 47 }; 48 49 /* 50 * operations every device should support 51 */ 52 struct sio_ops { 53 void (*close)(struct sio_hdl *); 54 int (*setpar)(struct sio_hdl *, struct sio_par *); 55 int (*getpar)(struct sio_hdl *, struct sio_par *); 56 int (*getcap)(struct sio_hdl *, struct sio_cap *); 57 size_t (*write)(struct sio_hdl *, const void *, size_t); 58 size_t (*read)(struct sio_hdl *, void *, size_t); 59 int (*start)(struct sio_hdl *); 60 int (*stop)(struct sio_hdl *); 61 int (*flush)(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_onmove_cb(struct sio_hdl *, int); 73 void _sio_onvol_cb(struct sio_hdl *, unsigned); 74 #ifdef DEBUG 75 void _sio_printpos(struct sio_hdl *); 76 #endif 77 78 #endif /* !defined(SNDIO_PRIV_H) */ 79