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

Annotation of src/usr.bin/aucat/file.h, Revision 1.2

1.2     ! ratchov     1: /*     $OpenBSD: file.h,v 1.1 2008/05/23 07:15:46 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 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:        int state;                      /* one of above */
                     40:        char *name;                     /* for debug purposes */
                     41:        struct aproc *rproc, *wproc;    /* reader and/or writer */
                     42:        LIST_ENTRY(file) entry;
                     43: };
                     44:
                     45: LIST_HEAD(filelist,file);
                     46:
                     47: extern struct filelist file_list;
                     48:
                     49: void file_start(void);
                     50: void file_stop(void);
                     51: struct file *file_new(int, char *);
                     52: void file_del(struct file *);
                     53: void file_attach(struct file *, struct aproc *, struct aproc *);
                     54: unsigned file_read(struct file *, unsigned char *, unsigned);
                     55: unsigned file_write(struct file *, unsigned char *, unsigned);
                     56: int file_poll(void);
                     57: void file_eof(struct file *);
                     58: void file_hup(struct file *);
                     59:
                     60: /*
                     61:  * max data of a .wav file. The total file size must be smaller than
                     62:  * 2^31, and we also have to leave some space for the headers (around 40
                     63:  * bytes)
                     64:  */
                     65: #define WAV_DATAMAX    (0x7fff0000)
                     66:
                     67: int wav_readhdr(int, struct aparams *, off_t *);
                     68: int wav_writehdr(int, struct aparams *);
                     69:
                     70: /* legacy */
                     71: int legacy_play(char *, char *);
                     72:
                     73: #endif /* !defined(FILE_H) */