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

Annotation of src/usr.bin/aucat/abuf.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 ABUF_H
        !            18: #define ABUF_H
        !            19:
        !            20: #include <sys/queue.h>
        !            21:
        !            22: struct abuf;
        !            23: struct aproc;
        !            24:
        !            25: struct abuf {
        !            26:        /*
        !            27:         * misc aproc-specific per-buffer parameters
        !            28:         */
        !            29:        int mixvol;             /* input gain */
        !            30:        unsigned mixdone;       /* input of mixer */
        !            31:        unsigned mixtodo;       /* output of mixer */
        !            32:        unsigned subdone;       /* output if sub */
        !            33:        LIST_ENTRY(abuf) ient;  /* for mix inputs list */
        !            34:        LIST_ENTRY(abuf) oent;  /* for sub outputs list */
        !            35:
        !            36:        /*
        !            37:         * fifo parameters
        !            38:         */
        !            39:        unsigned bpf;           /* bytes per frame */
        !            40:        unsigned start;         /* offset where data starts */
        !            41:        unsigned used;          /* valid data */
        !            42:        unsigned len;           /* size of the ring */
        !            43:        struct aproc *rproc;    /* reader */
        !            44:        struct aproc *wproc;    /* writer */
        !            45:        unsigned char data[];   /* actual data */
        !            46: };
        !            47:
        !            48: /*
        !            49:  * the buffer contains at least one frame. This macro should
        !            50:  * be used to check if the buffer can be flushed
        !            51:  */
        !            52: #define ABUF_ROK(b) ((b)->used >= (b)->bpf)
        !            53:
        !            54: /*
        !            55:  * there's room for at least one frame
        !            56:  */
        !            57: #define ABUF_WOK(b) ((b)->len - (b)->used >= (b)->bpf)
        !            58:
        !            59: /*
        !            60:  * the buffer is empty and has no more writer
        !            61:  */
        !            62: #define ABUF_EOF(b) (!ABUF_ROK(b) && (b)->wproc == NULL)
        !            63:
        !            64: /*
        !            65:  * similar to !ABUF_WOK, but is used for file i/o, where
        !            66:  * operation may not involve an integer number of frames
        !            67:  */
        !            68: #define ABUF_FULL(b) ((b)->used == (b)->len)
        !            69:
        !            70: /*
        !            71:  * same as !ABUF_ROK, but used for files, where
        !            72:  * operations are byte orientated, not frame-oriented
        !            73:  */
        !            74: #define ABUF_EMPTY(b) ((b)->used == 0)
        !            75:
        !            76: struct abuf *abuf_new(unsigned, unsigned);
        !            77: void abuf_del(struct abuf *);
        !            78: unsigned char *abuf_rgetblk(struct abuf *, unsigned *, unsigned);
        !            79: unsigned char *abuf_wgetblk(struct abuf *, unsigned *, unsigned);
        !            80: void abuf_fill(struct abuf *);
        !            81: void abuf_flush(struct abuf *);
        !            82: void abuf_eof(struct abuf *);
        !            83: void abuf_hup(struct abuf *);
        !            84: void abuf_run(struct abuf *);
        !            85:
        !            86: #endif /* !defined(ABUF_H) */