Annotation of src/usr.bin/aucat/amsg.h, Revision 1.5
1.5 ! ratchov 1: /* $OpenBSD: amsg.h,v 1.4 2009/01/23 17:38:15 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: */
1.5 ! ratchov 17: #ifndef AMSG_H
! 18: #define AMSG_H
1.1 ratchov 19:
20: #include <stdint.h>
21:
22: /*
23: * WARNING: since the protocol may be simultaneously used by static
24: * binaries or by different versions of a shared library, we are not
25: * allowed to change the packet binary representation in a backward
26: * incompatible way.
27: */
28: struct amsg {
29: #define AMSG_ACK 0 /* ack for START/STOP */
30: #define AMSG_GETPAR 1 /* get the current parameters */
31: #define AMSG_SETPAR 2 /* set the current parameters */
32: #define AMSG_START 3 /* request the server to start the stream */
1.4 ratchov 33: #define AMSG_STOP 4 /* request the server to stop the stream */
1.1 ratchov 34: #define AMSG_DATA 5 /* data block */
35: #define AMSG_MOVE 6 /* position changed */
36: #define AMSG_GETCAP 7 /* get capabilities */
1.2 ratchov 37: #define AMSG_SETVOL 8 /* set volume */
1.1 ratchov 38: uint32_t cmd;
39: uint32_t __pad;
40: union {
41: struct amsg_par {
42: #define AMSG_PLAY 1 /* will play */
43: #define AMSG_REC 2 /* will record */
44: uint8_t mode; /* a bitmap of above */
45: #define AMSG_IGNORE 0 /* loose sync */
46: #define AMSG_SYNC 1 /* resync after xrun */
47: #define AMSG_ERROR 2 /* kill the stream */
48: uint8_t xrun; /* one of above */
49: uint8_t bps; /* bytes per sample */
50: uint8_t bits; /* actually used bits */
51: uint8_t msb; /* 1 if MSB justified */
52: uint8_t le; /* 1 if little endian */
53: uint8_t sig; /* 1 if signed */
54: uint8_t __pad1;
55: uint16_t pchan; /* play channels */
56: uint16_t rchan; /* record channels */
57: uint32_t rate; /* frames per second */
1.3 ratchov 58: uint32_t bufsz; /* total buffered frames */
1.1 ratchov 59: uint32_t round;
1.3 ratchov 60: uint32_t appbufsz; /* client side bufsz */
61: uint32_t _reserved[1]; /* for future use */
1.1 ratchov 62: } par;
63: struct amsg_cap {
64: uint32_t rate; /* native rate */
1.3 ratchov 65: uint32_t _reserved2[1]; /* for future use */
1.1 ratchov 66: uint16_t rchan; /* native rec channels */
67: uint16_t pchan; /* native play channels */
68: uint8_t bits; /* native bits per sample */
69: uint8_t bps; /* native ytes per sample */
70: uint8_t _reserved[10]; /* for future use */
71: } cap;
72: struct amsg_data {
73: #define AMSG_DATAMAX 0x1000
74: uint32_t size;
75: } data;
76: struct amsg_ts {
77: int32_t delta;
78: } ts;
1.2 ratchov 79: struct amsg_vol {
80: uint32_t ctl;
81: } vol;
1.1 ratchov 82: } u;
83: };
84:
85: /*
86: * initialize an amsg structure: fill all fields with 0xff, so the read
87: * can test which fields were set
88: */
89: #define AMSG_INIT(m) do { memset((m), 0xff, sizeof(struct amsg)); } while (0)
90:
91: /*
92: * since the structure is memset to 0xff, the MSB can be used to check
93: * if any filed was set
94: */
95: #define AMSG_ISSET(x) (((x) & (1 << (8 * sizeof(x) - 1))) == 0)
96:
1.5 ! ratchov 97: #endif /* !defined(AMSG_H) */