| 1 | /* $Id: buffer.h,v 1.3 1999/03/10 07:58:02 boyns Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (C) 1993-99 Mark R. Boyns <[email protected]> |
| 5 | * |
| 6 | * This file is part of rplay. |
| 7 | * |
| 8 | * rplay is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * rplay is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with rplay; see the file COPYING. If not, write to the |
| 20 | * Free Software Foundation, Inc., |
| 21 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
| 22 | */ |
| 23 | |
| 24 | |
| 25 | |
| 26 | #ifndef _buffer_h |
| 27 | #define _buffer_h |
| 28 | |
| 29 | #ifdef HAVE_CONFIG_H |
| 30 | #include "config.h" |
| 31 | #endif |
| 32 | |
| 33 | #define BUFFER_SIZE 8192 /* must be >= RPTP_MAX_LINE, divisible by 2 & 4 */ |
| 34 | |
| 35 | /* |
| 36 | * Maximum number of buffers to have on the free list. |
| 37 | * The number should really depend on the value of BUFFER_SIZE. |
| 38 | */ |
| 39 | #define BUFFER_MAX_FREE 64 |
| 40 | |
| 41 | #define BUFFER_FREE 0 /* temporary buffer - put on free list or destroy */ |
| 42 | #define BUFFER_KEEP 1 /* permanent buffer - not put on free list */ |
| 43 | #define BUFFER_REUSE 2 /* temporary buffer - always put on free list */ |
| 44 | |
| 45 | typedef struct _buffer |
| 46 | { |
| 47 | struct _buffer *next; |
| 48 | int id; |
| 49 | int nbytes; |
| 50 | char buf[BUFFER_SIZE]; |
| 51 | int status; |
| 52 | int offset; |
| 53 | } |
| 54 | BUFFER; |
| 55 | |
| 56 | #ifdef __STDC__ |
| 57 | BUFFER *buffer_create (void); |
| 58 | void buffer_destroy (BUFFER *b); |
| 59 | BUFFER *buffer_alloc (int nbytes, int type); |
| 60 | void buffer_dealloc (BUFFER *b, int force); |
| 61 | void buffer_cleanup (void); |
| 62 | #else |
| 63 | BUFFER *buffer_create (); |
| 64 | void buffer_destroy ( /* BUFFER *b */ ); |
| 65 | BUFFER *buffer_alloc ( /* int nbytes, int type */ ); |
| 66 | void buffer_dealloc ( /* BUFFER *b, int force */ ); |
| 67 | void buffer_cleanup (); |
| 68 | #endif |
| 69 | |
| 70 | #endif /* _buffer_h */ |