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

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