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

Annotation of src/usr.bin/sndiod/sock.h, Revision 1.1

1.1     ! ratchov     1: /*     $OpenBSD$       */
        !             2: /*
        !             3:  * Copyright (c) 2008-2012 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:
        !            20: #include "amsg.h"
        !            21:
        !            22: struct opt;
        !            23: struct file;
        !            24: struct slot;
        !            25: struct midi;
        !            26:
        !            27: struct sock {
        !            28:        struct sock *next;
        !            29:        int fd;
        !            30:        struct file *file;
        !            31:        struct amsg rmsg, wmsg;         /* messages being sent/received */
        !            32:        unsigned int wmax;              /* max bytes we're allowed to write */
        !            33:        unsigned int rmax;              /* max bytes we're allowed to read */
        !            34:        unsigned int rsize;             /* input bytes to read (DATA msg) */
        !            35:        unsigned int wsize;             /* output bytes to write (DATA msg) */
        !            36:        unsigned int rtodo;             /* input bytes not read yet */
        !            37:        unsigned int wtodo;             /* output bytes not written yet */
        !            38: #define SOCK_RIDLE     0               /* not expecting messages */
        !            39: #define SOCK_RMSG      1               /* expecting a message */
        !            40: #define SOCK_RDATA     2               /* data chunk being read */
        !            41: #define SOCK_RRET      3               /* reply being returned */
        !            42:        unsigned int rstate;            /* state of the read-end FSM */
        !            43: #define SOCK_WIDLE     0               /* nothing to do */
        !            44: #define SOCK_WMSG      1               /* amsg being written */
        !            45: #define SOCK_WDATA     2               /* data chunk being written */
        !            46:        unsigned int wstate;            /* state of the write-end FSM */
        !            47: #define SOCK_AUTH      0               /* waiting for AUTH message */
        !            48: #define SOCK_HELLO     1               /* waiting for HELLO message */
        !            49: #define SOCK_INIT      2               /* parameter negotiation */
        !            50: #define SOCK_START     3               /* filling play buffers */
        !            51: #define SOCK_STOP      4               /* draining rec buffers */
        !            52:        unsigned int pstate;            /* one of the above */
        !            53:        int tickpending;                /* tick waiting to be transmitted */
        !            54:        int fillpending;                /* flowctl waiting to be transmitted */
        !            55:        int stoppending;                /* last STOP ack to be sent */
        !            56:        unsigned int walign;            /* align written data to this */
        !            57:        unsigned int ralign;            /* read data is aligned to this */
        !            58:        int lastvol;                    /* last volume */
        !            59:        struct opt *opt;                /* "subdevice" definition */
        !            60:        struct slot *slot;              /* audio device slot number */
        !            61:        struct midi *midi;              /* midi endpoint number */
        !            62:        char who[12];                   /* label, mostly for debugging */
        !            63: };
        !            64:
        !            65: struct sock *sock_new(int fd);
        !            66: void sock_close(struct sock *);
        !            67: extern struct sock *sock_list;
        !            68:
        !            69: #endif /* !defined(SOCK_H) */