Annotation of src/usr.bin/aucat/sock.h, Revision 1.19
1.19 ! ratchov 1: /* $OpenBSD: sock.h,v 1.18 2010/10/21 18:57:42 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 */
1.15 ratchov 33: unsigned wmax; /* max frames we're allowed to write */
34: unsigned rmax; /* max frames we're allowed to read */
1.1 ratchov 35: unsigned rtodo; /* input bytes not read yet */
36: unsigned wtodo; /* output bytes not written yet */
37: #define SOCK_RDATA 0 /* data chunk being read */
38: #define SOCK_RMSG 1 /* amsg query being processed */
39: #define SOCK_RRET 2 /* amsg reply being returned */
40: unsigned rstate; /* state of the read-end FSM */
41: #define SOCK_WIDLE 0 /* nothing to do */
42: #define SOCK_WMSG 1 /* amsg being written */
43: #define SOCK_WDATA 2 /* data chunk being written */
44: unsigned wstate; /* state of the write-end FSM */
1.19 ! ratchov 45: #define SOCK_AUTH 0 /* waiting for AUTH message */
! 46: #define SOCK_HELLO 1 /* waiting for HELLO message */
! 47: #define SOCK_INIT 2 /* parameter negotiation */
! 48: #define SOCK_START 3 /* filling play buffers */
! 49: #define SOCK_READY 4 /* play buffers full */
! 50: #define SOCK_RUN 5 /* attached to the mix / sub */
! 51: #define SOCK_STOP 6 /* draining rec buffers */
! 52: #define SOCK_MIDI 7 /* raw byte stream (midi) */
1.1 ratchov 53: unsigned pstate; /* one of the above */
1.18 ratchov 54: unsigned mode; /* bitmask of MODE_XXX */
1.1 ratchov 55: struct aparams rpar; /* read (ie play) parameters */
56: struct aparams wpar; /* write (ie rec) parameters */
1.5 ratchov 57: int delta; /* pos. change to send */
1.17 ratchov 58: int startpos; /* initial pos. to send */
1.5 ratchov 59: int tickpending; /* delta waiting to be transmitted */
1.15 ratchov 60: int startpending; /* initial delta waiting to be transmitted */
1.12 ratchov 61: unsigned walign; /* align data packets to this */
1.1 ratchov 62: unsigned bufsz; /* total buffer size */
63: unsigned round; /* block size */
64: unsigned xrun; /* one of AMSG_IGNORE, ... */
1.3 ratchov 65: int vol; /* requested volume */
1.10 ratchov 66: int lastvol; /* last volume */
1.9 ratchov 67: int slot; /* mixer ctl slot number */
1.7 ratchov 68: struct opt *opt; /* "subdevice" definition */
1.16 ratchov 69: struct dev *dev; /* actual hardware device */
1.11 ratchov 70: char who[12]; /* label, mostly for debugging */
1.1 ratchov 71: };
72:
1.7 ratchov 73: struct sock *sock_new(struct fileops *, int fd);
1.1 ratchov 74: extern struct fileops sock_ops;
75:
76: #endif /* !defined(SOCK_H) */