[BACK]Return to amsg.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / aucat

Annotation of src/usr.bin/aucat/amsg.h, Revision 1.19

1.19    ! ratchov     1: /*     $OpenBSD: amsg.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:  */
1.5       ratchov    17: #ifndef AMSG_H
                     18: #define AMSG_H
1.1       ratchov    19:
                     20: #include <stdint.h>
1.18      ratchov    21: #include "conf.h"
1.1       ratchov    22:
                     23: /*
                     24:  * WARNING: since the protocol may be simultaneously used by static
                     25:  * binaries or by different versions of a shared library, we are not
                     26:  * allowed to change the packet binary representation in a backward
                     27:  * incompatible way.
1.6       ratchov    28:  *
                     29:  * Especially, make sure the amsg_xxx structures are not larger
                     30:  * than 32 bytes.
1.1       ratchov    31:  */
                     32: struct amsg {
                     33: #define AMSG_ACK       0       /* ack for START/STOP */
                     34: #define AMSG_GETPAR    1       /* get the current parameters */
                     35: #define AMSG_SETPAR    2       /* set the current parameters */
                     36: #define AMSG_START     3       /* request the server to start the stream */
1.4       ratchov    37: #define AMSG_STOP      4       /* request the server to stop the stream */
1.1       ratchov    38: #define AMSG_DATA      5       /* data block */
1.17      ratchov    39: #define AMSG_POS       6       /* initial position */
                     40: #define AMSG_MOVE      7       /* position changed */
                     41: #define AMSG_GETCAP    8       /* get capabilities */
                     42: #define AMSG_SETVOL    9       /* set volume */
                     43: #define AMSG_HELLO     10      /* say hello, check versions and so ... */
                     44: #define AMSG_BYE       11      /* ask server to drop connection */
1.1       ratchov    45:        uint32_t cmd;
                     46:        uint32_t __pad;
                     47:        union {
                     48:                struct amsg_par {
1.7       ratchov    49:                        uint8_t legacy_mode;    /* compat for old libs */
1.1       ratchov    50:                        uint8_t xrun;           /* one of above */
                     51:                        uint8_t bps;            /* bytes per sample */
                     52:                        uint8_t bits;           /* actually used bits */
                     53:                        uint8_t msb;            /* 1 if MSB justified */
                     54:                        uint8_t le;             /* 1 if little endian */
                     55:                        uint8_t sig;            /* 1 if signed */
                     56:                        uint8_t __pad1;
                     57:                        uint16_t pchan;         /* play channels */
                     58:                        uint16_t rchan;         /* record channels */
                     59:                        uint32_t rate;          /* frames per second */
1.3       ratchov    60:                        uint32_t bufsz;         /* total buffered frames */
1.1       ratchov    61:                        uint32_t round;
1.3       ratchov    62:                        uint32_t appbufsz;      /* client side bufsz */
                     63:                        uint32_t _reserved[1];  /* for future use */
1.1       ratchov    64:                } par;
                     65:                struct amsg_cap {
                     66:                        uint32_t rate;          /* native rate */
1.3       ratchov    67:                        uint32_t _reserved2[1]; /* for future use */
1.1       ratchov    68:                        uint16_t rchan;         /* native rec channels */
                     69:                        uint16_t pchan;         /* native play channels */
                     70:                        uint8_t bits;           /* native bits per sample */
                     71:                        uint8_t bps;            /* native ytes per sample */
                     72:                        uint8_t _reserved[10];  /* for future use */
                     73:                } cap;
                     74:                struct amsg_data {
                     75: #define AMSG_DATAMAX   0x1000
                     76:                        uint32_t size;
                     77:                } data;
                     78:                struct amsg_ts {
                     79:                        int32_t delta;
                     80:                } ts;
1.2       ratchov    81:                struct amsg_vol {
                     82:                        uint32_t ctl;
                     83:                } vol;
1.6       ratchov    84:                struct amsg_hello {
1.18      ratchov    85:                        uint16_t mode;          /* bitmap of MODE_XXX */
1.19    ! ratchov    86: #define AMSG_VERSION   4
1.11      ratchov    87:                        uint8_t version;        /* protocol version */
                     88:                        uint8_t reserved1[5];   /* for future use */
1.8       ratchov    89:                        char opt[12];           /* profile name */
1.6       ratchov    90:                        char who[12];           /* hint for leases */
                     91:                } hello;
1.1       ratchov    92:        } u;
                     93: };
                     94:
                     95: /*
1.9       ratchov    96:  * Initialize an amsg structure: fill all fields with 0xff, so the read
                     97:  * can test which fields were set.
1.1       ratchov    98:  */
                     99: #define AMSG_INIT(m) do { memset((m), 0xff, sizeof(struct amsg)); } while (0)
                    100:
                    101: /*
1.9       ratchov   102:  * Since the structure is memset to 0xff, the MSB can be used to check
                    103:  * if any field was set.
1.1       ratchov   104:  */
                    105: #define AMSG_ISSET(x) (((x) & (1 << (8 * sizeof(x) - 1))) == 0)
                    106:
1.5       ratchov   107: #endif /* !defined(AMSG_H) */