Annotation of src/usr.bin/aucat/wav.h, Revision 1.8
1.8 ! ratchov 1: /* $OpenBSD: wav.h,v 1.7 2010/04/03 17:59:17 ratchov Exp $ */
1.1 ratchov 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 WAV_H
18: #define WAV_H
19:
20: #include <sys/types.h>
21:
1.4 ratchov 22: #include "aparams.h"
1.1 ratchov 23: #include "pipe.h"
24:
25: struct wav {
26: struct pipe pipe;
27: #define HDR_AUTO 0 /* guess by looking at the file name */
28: #define HDR_RAW 1 /* no headers, ie openbsd native ;-) */
29: #define HDR_WAV 2 /* microsoft riff wave */
30: unsigned hdr; /* HDR_RAW or HDR_WAV */
1.8 ! ratchov 31: unsigned xrun; /* xrun policy */
1.1 ratchov 32: struct aparams hpar; /* parameters to write on the header */
33: off_t rbytes; /* bytes to read, -1 if no limit */
34: off_t wbytes; /* bytes to write, -1 if no limit */
1.8 ! ratchov 35: off_t startpos; /* beginning of the data chunk */
! 36: off_t endpos; /* end of the data chunk */
! 37: off_t mmcpos; /* play/rec start point set by MMC */
1.3 ratchov 38: short *map; /* mulaw/alaw -> s16 conversion table */
1.8 ! ratchov 39: int slot; /* mixer ctl slot number */
! 40: int tr; /* use MMC control */
! 41: unsigned vol; /* current volume */
! 42: unsigned maxweight; /* dynamic range when vol == 127 */
! 43: #define WAV_INIT 0 /* not trying to do anything */
! 44: #define WAV_START 1 /* buffer allocated */
! 45: #define WAV_READY 2 /* buffer filled enough */
! 46: #define WAV_RUN 3 /* buffer attached to device */
! 47: #define WAV_FAILED 4 /* failed to seek */
! 48: unsigned pstate; /* one of above */
! 49: unsigned mode; /* bitmap of MODE_* */
1.1 ratchov 50: };
51:
52: extern struct fileops wav_ops;
53:
1.8 ! ratchov 54: struct wav *wav_new_in(struct fileops *, unsigned, char *, unsigned,
! 55: struct aparams *, unsigned, unsigned, int);
! 56: struct wav *wav_new_out(struct fileops *, unsigned, char *, unsigned,
! 57: struct aparams *, unsigned, int);
1.1 ratchov 58: unsigned wav_read(struct file *, unsigned char *, unsigned);
59: unsigned wav_write(struct file *, unsigned char *, unsigned);
60: void wav_close(struct file *);
1.8 ! ratchov 61: int wav_readhdr(int, struct aparams *, off_t *, off_t *, short **);
! 62: int wav_writehdr(int, struct aparams *, off_t *, off_t);
1.3 ratchov 63: void wav_conv(unsigned char *, unsigned, short *);
1.1 ratchov 64:
65: /* legacy */
66: int legacy_play(char *, char *);
1.3 ratchov 67:
68: extern short wav_ulawmap[256];
69: extern short wav_alawmap[256];
1.1 ratchov 70:
71: #endif /* !defined(WAV_H) */