Annotation of src/usr.bin/aucat/file.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 FILE_H
! 18: #define FILE_H
! 19:
! 20: #include <sys/queue.h>
! 21: #include <sys/types.h>
! 22:
! 23: #include <poll.h>
! 24:
! 25: struct aparams;
! 26: struct aproc;
! 27: struct abuf;
! 28:
! 29: struct file {
! 30: int fd; /* file descriptor */
! 31: struct pollfd *pfd; /* arg to poll(2) syscall */
! 32: off_t rbytes; /* bytes to read, -1 if no limit */
! 33: off_t wbytes; /* bytes to write, -1 if no limit */
! 34: int events; /* events for poll(2) */
! 35: #define FILE_ROK 0x1 /* file readable */
! 36: #define FILE_WOK 0x2 /* file writable */
! 37: #define FILE_EOF 0x4 /* eof on the read end */
! 38: #define FILE_HUP 0x8 /* eof on the write end */
! 39: #define FILE_RFLOW 0x10 /* has flow control on read() */
! 40: #define FILE_WFLOW 0x20 /* has flow control on write() */
! 41: int state; /* one of above */
! 42: char *name; /* for debug purposes */
! 43: struct aproc *rproc, *wproc; /* reader and/or writer */
! 44: LIST_ENTRY(file) entry;
! 45: };
! 46:
! 47: LIST_HEAD(filelist,file);
! 48:
! 49: extern struct filelist file_list;
! 50:
! 51: void file_start(void);
! 52: void file_stop(void);
! 53: struct file *file_new(int, char *);
! 54: void file_del(struct file *);
! 55: void file_attach(struct file *, struct aproc *, struct aproc *);
! 56: unsigned file_read(struct file *, unsigned char *, unsigned);
! 57: unsigned file_write(struct file *, unsigned char *, unsigned);
! 58: int file_poll(void);
! 59: void file_eof(struct file *);
! 60: void file_hup(struct file *);
! 61:
! 62: /*
! 63: * max data of a .wav file. The total file size must be smaller than
! 64: * 2^31, and we also have to leave some space for the headers (around 40
! 65: * bytes)
! 66: */
! 67: #define WAV_DATAMAX (0x7fff0000)
! 68:
! 69: int wav_readhdr(int, struct aparams *, off_t *);
! 70: int wav_writehdr(int, struct aparams *);
! 71:
! 72: /* legacy */
! 73: int legacy_play(char *, char *);
! 74:
! 75: #endif /* !defined(FILE_H) */