Annotation of src/usr.bin/aucat/sock.h, Revision 1.10
1.10 ! ratchov 1: /* $OpenBSD: sock.h,v 1.9 2009/08/21 16:48:03 ratchov Exp $ */
1.1 ratchov 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 SOCK_H
18: #define SOCK_H
19:
1.8 ratchov 20: #include "amsg.h"
21: #include "aparams.h"
1.1 ratchov 22: #include "pipe.h"
23:
1.7 ratchov 24: struct opt;
25:
1.1 ratchov 26: struct sock {
27: struct pipe pipe;
28: /*
1.8 ratchov 29: * Socket and protocol specific stuff, mainly used
1.1 ratchov 30: * to decode/encode messages in the stream.
31: */
32: struct amsg rmsg, wmsg; /* messages being sent/received */
33: unsigned rtodo; /* input bytes not read yet */
34: unsigned wtodo; /* output bytes not written yet */
35: #define SOCK_RDATA 0 /* data chunk being read */
36: #define SOCK_RMSG 1 /* amsg query being processed */
37: #define SOCK_RRET 2 /* amsg reply being returned */
38: unsigned rstate; /* state of the read-end FSM */
39: #define SOCK_WIDLE 0 /* nothing to do */
40: #define SOCK_WMSG 1 /* amsg being written */
41: #define SOCK_WDATA 2 /* data chunk being written */
42: unsigned wstate; /* state of the write-end FSM */
1.6 ratchov 43: #define SOCK_HELLO 0 /* waiting for HELLO message */
44: #define SOCK_INIT 1 /* parameter negotiation */
45: #define SOCK_START 2 /* filling play buffers */
46: #define SOCK_RUN 3 /* attached to the mix / sub */
1.7 ratchov 47: #define SOCK_MIDI 4 /* raw byte stream (midi) */
1.1 ratchov 48: unsigned pstate; /* one of the above */
49: unsigned mode; /* a set of AMSG_PLAY, AMSG_REC */
50: struct aparams rpar; /* read (ie play) parameters */
51: struct aparams wpar; /* write (ie rec) parameters */
1.5 ratchov 52: int delta; /* pos. change to send */
53: int tickpending; /* delta waiting to be transmitted */
1.1 ratchov 54: unsigned bufsz; /* total buffer size */
55: unsigned round; /* block size */
56: unsigned xrun; /* one of AMSG_IGNORE, ... */
1.3 ratchov 57: int vol; /* requested volume */
1.10 ! ratchov 58: int lastvol; /* last volume */
1.9 ratchov 59: int slot; /* mixer ctl slot number */
1.7 ratchov 60: struct opt *opt; /* "subdevice" definition */
1.1 ratchov 61: };
62:
1.7 ratchov 63: struct sock *sock_new(struct fileops *, int fd);
1.1 ratchov 64: extern struct fileops sock_ops;
65:
66: #endif /* !defined(SOCK_H) */