[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.20

1.20    ! ratchov     1: /*     $OpenBSD: amsg.h,v 1.19 2011/04/16 10:52:22 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_SETVOL    9       /* set volume */
                     42: #define AMSG_HELLO     10      /* say hello, check versions and so ... */
                     43: #define AMSG_BYE       11      /* ask server to drop connection */
1.1       ratchov    44:        uint32_t cmd;
                     45:        uint32_t __pad;
                     46:        union {
                     47:                struct amsg_par {
1.7       ratchov    48:                        uint8_t legacy_mode;    /* compat for old libs */
1.1       ratchov    49:                        uint8_t xrun;           /* one of above */
                     50:                        uint8_t bps;            /* bytes per sample */
                     51:                        uint8_t bits;           /* actually used bits */
                     52:                        uint8_t msb;            /* 1 if MSB justified */
                     53:                        uint8_t le;             /* 1 if little endian */
                     54:                        uint8_t sig;            /* 1 if signed */
                     55:                        uint8_t __pad1;
                     56:                        uint16_t pchan;         /* play channels */
                     57:                        uint16_t rchan;         /* record channels */
                     58:                        uint32_t rate;          /* frames per second */
1.3       ratchov    59:                        uint32_t bufsz;         /* total buffered frames */
1.1       ratchov    60:                        uint32_t round;
1.3       ratchov    61:                        uint32_t appbufsz;      /* client side bufsz */
                     62:                        uint32_t _reserved[1];  /* for future use */
1.1       ratchov    63:                } par;
                     64:                struct amsg_data {
                     65: #define AMSG_DATAMAX   0x1000
                     66:                        uint32_t size;
                     67:                } data;
                     68:                struct amsg_ts {
                     69:                        int32_t delta;
                     70:                } ts;
1.2       ratchov    71:                struct amsg_vol {
                     72:                        uint32_t ctl;
                     73:                } vol;
1.6       ratchov    74:                struct amsg_hello {
1.18      ratchov    75:                        uint16_t mode;          /* bitmap of MODE_XXX */
1.20    ! ratchov    76: #define AMSG_VERSION   5
1.11      ratchov    77:                        uint8_t version;        /* protocol version */
                     78:                        uint8_t reserved1[5];   /* for future use */
1.8       ratchov    79:                        char opt[12];           /* profile name */
1.6       ratchov    80:                        char who[12];           /* hint for leases */
                     81:                } hello;
1.1       ratchov    82:        } u;
                     83: };
                     84:
                     85: /*
1.9       ratchov    86:  * Initialize an amsg structure: fill all fields with 0xff, so the read
                     87:  * can test which fields were set.
1.1       ratchov    88:  */
                     89: #define AMSG_INIT(m) do { memset((m), 0xff, sizeof(struct amsg)); } while (0)
                     90:
                     91: /*
1.9       ratchov    92:  * Since the structure is memset to 0xff, the MSB can be used to check
                     93:  * if any field was set.
1.1       ratchov    94:  */
                     95: #define AMSG_ISSET(x) (((x) & (1 << (8 * sizeof(x) - 1))) == 0)
                     96:
1.5       ratchov    97: #endif /* !defined(AMSG_H) */