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

1.1     ! ratchov     1: /*     $OpenBSD$       */
        !             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 SOCKET_H
        !            18: #define SOCKET_H
        !            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 */
        !            33: #define AMSG_STOP      4       /* request the server to stop the stream */
        !            34: #define AMSG_DATA      5       /* data block */
        !            35: #define AMSG_MOVE      6       /* position changed */
        !            36: #define AMSG_GETCAP    7       /* get capabilities */
        !            37:        uint32_t cmd;
        !            38:        uint32_t __pad;
        !            39:        union {
        !            40:                struct amsg_par {
        !            41: #define AMSG_PLAY      1                       /* will play */
        !            42: #define AMSG_REC       2                       /* will record */
        !            43:                        uint8_t mode;           /* a bitmap of above */
        !            44: #define AMSG_IGNORE    0                       /* loose sync */
        !            45: #define AMSG_SYNC      1                       /* resync after xrun */
        !            46: #define AMSG_ERROR     2                       /* kill the stream */
        !            47:                        uint8_t xrun;           /* one of above */
        !            48:                        uint8_t bps;            /* bytes per sample */
        !            49:                        uint8_t bits;           /* actually used bits */
        !            50:                        uint8_t msb;            /* 1 if MSB justified */
        !            51:                        uint8_t le;             /* 1 if little endian */
        !            52:                        uint8_t sig;            /* 1 if signed */
        !            53:                        uint8_t __pad1;
        !            54:                        uint16_t pchan;         /* play channels */
        !            55:                        uint16_t rchan;         /* record channels */
        !            56:                        uint32_t rate;          /* frames per second */
        !            57:                        uint32_t bufsz;         /* buffered frames */
        !            58:                        uint32_t round;
        !            59:                        uint32_t _reserved[2];  /* for future use */
        !            60:                } par;
        !            61:                struct amsg_cap {
        !            62:                        uint32_t rate;          /* native rate */
        !            63:                        uint32_t rate_div;      /* divisor of emul. rates */
        !            64:                        uint16_t rchan;         /* native rec channels */
        !            65:                        uint16_t pchan;         /* native play channels */
        !            66:                        uint8_t bits;           /* native bits per sample */
        !            67:                        uint8_t bps;            /* native ytes per sample */
        !            68:                        uint8_t _reserved[10];  /* for future use */
        !            69:                } cap;
        !            70:                struct amsg_data {
        !            71: #define AMSG_DATAMAX   0x1000
        !            72:                        uint32_t size;
        !            73:                } data;
        !            74:                struct amsg_ts {
        !            75:                        int32_t delta;
        !            76:                } ts;
        !            77:        } u;
        !            78: };
        !            79:
        !            80: /*
        !            81:  * initialize an amsg structure: fill all fields with 0xff, so the read
        !            82:  * can test which fields were set
        !            83:  */
        !            84: #define AMSG_INIT(m) do { memset((m), 0xff, sizeof(struct amsg)); } while (0)
        !            85:
        !            86: /*
        !            87:  * since the structure is memset to 0xff, the MSB can be used to check
        !            88:  * if any filed was set
        !            89:  */
        !            90: #define AMSG_ISSET(x) (((x) & (1 << (8 * sizeof(x) - 1))) == 0)
        !            91:
        !            92: #endif /* !defined(SOCKET_H) */