[BACK]Return to sndio.h CVS log [TXT][DIR] Up to [local] / src / include

Annotation of src/include/sndio.h, Revision 1.1

1.1     ! ratchov     1: /*     $OpenBSD: sndio.h,v 1.8 2009/04/13 16:05:50 ratchov Exp $       */
        !             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 SNDIO_H
        !            18: #define SNDIO_H
        !            19:
        !            20: #include <sys/param.h>
        !            21:
        !            22: /*
        !            23:  * private ``handle'' structure
        !            24:  */
        !            25: struct sio_hdl;
        !            26:
        !            27: /*
        !            28:  * parameters of a full-duplex stream
        !            29:  */
        !            30: struct sio_par {
        !            31:        unsigned bits;          /* bits per sample */
        !            32:        unsigned bps;           /* bytes per sample */
        !            33:        unsigned sig;           /* 1 = signed, 0 = unsigned */
        !            34:        unsigned le;            /* 1 = LE, 0 = BE byte order */
        !            35:        unsigned msb;           /* 1 = MSB, 0 = LSB aligned */
        !            36:        unsigned rchan;         /* number channels for recording direction */
        !            37:        unsigned pchan;         /* number channels for playback direction */
        !            38:        unsigned rate;          /* frames per second */
        !            39:        unsigned bufsz;         /* end-to-end buffer size */
        !            40: #define SIO_IGNORE     0       /* pause during xrun */
        !            41: #define SIO_SYNC       1       /* resync after xrun */
        !            42: #define SIO_ERROR      2       /* terminate on xrun */
        !            43:        unsigned xrun;          /* what to do on overruns/underruns */
        !            44:        unsigned round;         /* optimal bufsz divisor */
        !            45:        unsigned appbufsz;      /* minimum buffer size */
        !            46:        int __pad[3];           /* for future use */
        !            47:        int __magic;            /* for internal/debug purposes only */
        !            48: };
        !            49:
        !            50: /*
        !            51:  * capabilities of a stream
        !            52:  */
        !            53: struct sio_cap {
        !            54: #define SIO_NENC       8
        !            55: #define SIO_NCHAN      8
        !            56: #define SIO_NRATE      16
        !            57: #define SIO_NCONF      4
        !            58:        struct sio_enc {                        /* allowed sample encodings */
        !            59:                unsigned bits;
        !            60:                unsigned bps;
        !            61:                unsigned sig;
        !            62:                unsigned le;
        !            63:                unsigned msb;
        !            64:        } enc[SIO_NENC];
        !            65:        unsigned rchan[SIO_NCHAN];      /* allowed values for rchan */
        !            66:        unsigned pchan[SIO_NCHAN];      /* allowed values for pchan */
        !            67:        unsigned rate[SIO_NRATE];       /* allowed rates */
        !            68:        int __pad[7];                   /* for future use */
        !            69:        unsigned nconf;                 /* number of elements in confs[] */
        !            70:        struct sio_conf {
        !            71:                unsigned enc;           /* mask of enc[] indexes */
        !            72:                unsigned rchan;         /* mask of chan[] indexes (rec) */
        !            73:                unsigned pchan;         /* mask of chan[] indexes (play) */
        !            74:                unsigned rate;          /* mask of rate[] indexes */
        !            75:        } confs[SIO_NCONF];
        !            76: };
        !            77:
        !            78: #define SIO_XSTRINGS { "ignore", "sync", "error" }
        !            79:
        !            80: /*
        !            81:  * mode bitmap
        !            82:  */
        !            83: #define SIO_PLAY       1
        !            84: #define SIO_REC                2
        !            85:
        !            86: /*
        !            87:  * maximum size of the encording string (the longest possible
        !            88:  * encoding is ``s24le3msb'')
        !            89:  */
        !            90: #define SIO_ENCMAX     10
        !            91:
        !            92: /*
        !            93:  * default bytes per sample for the given bits per sample
        !            94:  */
        !            95: #define SIO_BPS(bits) (((bits) <= 8) ? 1 : (((bits) <= 16) ? 2 : 4))
        !            96:
        !            97: /*
        !            98:  * default value of "sio_par->le" flag
        !            99:  */
        !           100: #if BYTE_ORDER == LITTLE_ENDIAN
        !           101: #define SIO_LE_NATIVE 1
        !           102: #else
        !           103: #define SIO_LE_NATIVE 0
        !           104: #endif
        !           105:
        !           106: /*
        !           107:  * default device for the sun audio(4) back-end
        !           108:  */
        !           109: #define SIO_SUN_PATH   "/dev/audio"
        !           110:
        !           111: /*
        !           112:  * default socket name for the aucat(1) back-end
        !           113:  */
        !           114: #define SIO_AUCAT_PATH "default"
        !           115:
        !           116: /*
        !           117:  * maximum value of volume, eg. for sio_setvol()
        !           118:  */
        !           119: #define SIO_MAXVOL 127
        !           120:
        !           121: #ifdef __cplusplus
        !           122: extern "C" {
        !           123: #endif
        !           124:
        !           125: struct pollfd;
        !           126:
        !           127: int sio_strtoenc(struct sio_par *, char *);
        !           128: int sio_enctostr(struct sio_par *, char *);
        !           129: void sio_initpar(struct sio_par *);
        !           130:
        !           131: struct sio_hdl *sio_open(char *, unsigned, int);
        !           132: void sio_close(struct sio_hdl *);
        !           133: int sio_setpar(struct sio_hdl *, struct sio_par *);
        !           134: int sio_getpar(struct sio_hdl *, struct sio_par *);
        !           135: int sio_getcap(struct sio_hdl *, struct sio_cap *);
        !           136: void sio_onmove(struct sio_hdl *, void (*)(void *, int), void *);
        !           137: size_t sio_write(struct sio_hdl *, void *, size_t);
        !           138: size_t sio_read(struct sio_hdl *, void *, size_t);
        !           139: int sio_start(struct sio_hdl *);
        !           140: int sio_stop(struct sio_hdl *);
        !           141: int sio_nfds(struct sio_hdl *);
        !           142: int sio_pollfd(struct sio_hdl *, struct pollfd *, int);
        !           143: int sio_revents(struct sio_hdl *, struct pollfd *);
        !           144: int sio_eof(struct sio_hdl *);
        !           145: int sio_setvol(struct sio_hdl *, unsigned);
        !           146: void sio_onvol(struct sio_hdl *, void (*)(void *, unsigned), void *);
        !           147:
        !           148: #ifdef __cplusplus
        !           149: }
        !           150: #endif
        !           151:
        !           152: #endif /* !defined(SNDIO_H) */