Debian Codegraph @

rplayd/sound.h

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /* $Id: sound.h,v 1.4 1999/06/09 06:27:44 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 _sound_h
27 #define _sound_h
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32 #include "buffer.h"
33 #include "rplay.h"
34 #include "server.h"
35 #include <sys/types.h>
36 #include <sys/uio.h>
37 #ifdef HAVE_ADPCM
38 #include "g72x.h"
39 #endif /* HAVE_ADPCM */
40 #ifdef HAVE_GSM
41 #ifdef HAVE_GSM_GSM_H
42 #include <gsm/gsm.h>
43 #else
44 #ifdef HAVE_GSM_H
45 #include <gsm.h>
46 #else
47 #include "gsm.h"
48 #endif
49 #endif
50 #endif /* HAVE_GSM */
51
52 #undef NUMBER_OF_SAMPLES
53 #define NUMBER_OF_SAMPLES(s) (((s->tail ? (s->tail - s->offset) : (s->size - s->offset)) << 3) / (s->input_precision * s->channels))
54
55 #undef HIGH_WATER_MARK
56 #define HIGH_WATER_MARK(s) (s->sample_rate * s->input_sample_size * 2) /* 2 seconds */
57
58 #undef LOW_WATER_MARK
59 #define LOW_WATER_MARK(s) (s->sample_rate * s->input_sample_size * 1) /* 1 seconds */
60
61 #define SOUND_LIST_SIZE 256 /* maximum size of a sound list */
62
63 /*
64 * Sound types
65 */
66 #define SOUND_FILE 1 /* A sound file. */
67 #define SOUND_FLOW 2 /* A sound flow. */
68 #ifdef HAVE_CDROM
69 #define SOUND_CDROM 3 /* Sound is on a CDROM. */
70 #endif /* HAVE_CDROM */
71 #define SOUND_VIRTUAL 4 /* Virtual sound */
72
73 /*
74 * Sound storage methods
75 */
76 #define SOUND_STORAGE_NULL 0
77 #define SOUND_STORAGE_NONE 1 /* Input is discarded. */
78 #define SOUND_STORAGE_DISK 2 /* Input is stored on disk. */
79 #define SOUND_STORAGE_MEMORY 3 /* Input is stored in memory. */
80
81 /*
82 * sound status values
83 */
84 #define SOUND_NULL 0
85 #define SOUND_READY 1 /* sound is ready to be played */
86 #define SOUND_NOT_READY 2 /* sound is being transferred */
87 #define SOUND_SEARCH 3 /* sound is being searched for */
88
89 /*
90 * sound lookup modes
91 */
92 #define SOUND_FIND 1
93 #define SOUND_DONT_FIND 2
94 #define SOUND_DONT_COUNT 3
95 #define SOUND_LOAD 4
96 #define SOUND_CREATE 5
97
98 /*
99 * Maximum size of an audio file header.
100 */
101 #define SOUND_MAX_HEADER_SIZE 1024
102
103 /*
104 * Maximum piece of a sound that can be read by sound_fill ().
105 */
106 #define SOUND_FILL_SIZE (UIO_MAXIOV * BUFFER_SIZE)
107
108 typedef struct _sound
109 {
110 struct _sound *list; /* next pointer for entire sound list */
111 struct _sound *list_prev; /* prev pointer for entire sound list */
112 struct _sound *next; /* list for sounds with the same hash key */
113 struct _sound *prev; /* prev pointer for the next list */
114 int type; /* type of sound */
115 int storage; /* storage method */
116 char *name; /* name of the sound */
117 char *hash_key; /* sound's hash key */
118 char *path; /* complete path of the sound */
119 int count; /* relative sound count, use for caching */
120 int status; /* status of the sound */
121 int format; /* format of the audio data - RPLAY_FORMAT_* */
122 int byte_order; /* big endian or little endian */
123 int sample_rate; /* audio sample rate */
124 float input_precision; /* bits per sample in the audio file */
125 int output_precision; /* bits per sample that are output */
126 int channels; /* number of channels */
127 int samples; /* number of samples */
128 float input_sample_size; /* size of one input sample = bits/sample * channels */
129 int output_sample_size; /* size of one output sample = bits/sample * channels */
130 int offset; /* audio data offset in the file */
131 int size; /* total size of the sound file */
132 int tail; /* audio offset from the end of the file */
133 int chunk_size; /* size of audio data */
134 int mapped; /* sound info is known */
135 char *cache; /* audio data cache */
136 BUFFER *flow; /* list of flow data */
137 BUFFER **flowp; /* where the next flow data will be put */
138 #ifdef HAVE_CDROM
139 int starting_track; /* CD start track */
140 int ending_track; /* CD end track */
141 #endif /* HAVE_CDROM */
142 #ifdef HAVE_HELPERS
143 int needs_helper;
144 #endif /* HAVE_HELPERS */
145 }
146 SOUND;
147
148 typedef struct _sindex
149 {
150 SOUND *sound; /* the sound being referenced */
151 int offset; /* current position */
152 int is_cached; /* is the sound cached? */
153 int fd; /* file descriptor used when sound isn't cached */
154 int eof; /* the end has been reached */
155 int skip;
156 int buffer_offset; /* offset in a shared BUFFER */
157 int is_flow; /* is this sound a flow? */
158 BUFFER **flowp; /* pointer to a sound's flow */
159 int water_mark;
160 int low_water_mark;
161 int high_water_mark;
162 #ifdef HAVE_ADPCM
163 struct g72x_state adpcm_state[2]; /* state used in adpcm_decode */
164 unsigned int adpcm_in_buffer; /* state variable used adpcm_unpack */
165 int adpcm_in_bits; /* state variable used adpcm_unpack */
166 #endif /* HAVE_ADPCM */
167 #ifdef HAVE_GSM
168 gsm gsm_object; /* GSM state object */
169 gsm_frame gsm_bit_frame; /* GSM bit buffer - 33 bytes */
170 int gsm_bit_frame_bytes; /* Number of bytes in gsm_bit_frame */
171 int gsm_fixed_buffer_size;
172 #endif /* HAVE_GSM */
•173 #if defined(HAVE_CDROM) || defined(HAVE_HELPERS)
174 int pid;
•175 #endif /* HAVE_CDROM || HAVE_HELPERS */
176 }
177 SINDEX;
178
179 /* The deadsnd header. */
180 typedef struct
181 {
182 long id;
183 long freq;
184 int bps;
185 int mode;
186 char title[80];
187 }
188 DSID;
189
190
191 extern SOUND *sounds; /* list of all sounds. */
192 extern int sound_count; /* sound reference count used in LRU caching */
193 extern int sound_cache_size; /* current size of the cache */
194 extern int sound_cache_max_sound_size; /* maximum size of a sound that can be cached */
195 extern int sound_cache_max_size; /* maximum size of cached sounds */
196
197 #ifdef __STDC__
198 extern void sound_read (char *filename);
199 extern void sound_reread (char *filename);
200 extern void sound_stat (char *filename);
201 extern SOUND *sound_lookup (char *sound_name, int mode, SERVER *server);
202 extern SOUND *sound_create (void);
203 extern SOUND *sound_insert (char *, int, int);
204 extern int sound_map (SOUND *s);
205 extern int sound_unmap (SOUND *s);
206 extern void sound_delete (SOUND *s, int remove);
207 extern BUFFER *sound_list_create ();
208 extern void sound_cleanup ();
209 extern SINDEX *sound_open (SOUND *, int);
210 extern int sound_close (SINDEX *);
211 extern int sound_fill (SINDEX *, BUFFER *data, int as_is);
212 extern int sound_seek (SINDEX *, int offset, int whence);
213 extern void sound_clean (SOUND *s);
214 extern int number_of_samples (SOUND *s, int bytes);
215 #else
216 extern void sound_read ( /* char *filename */ );
217 extern void sound_reread ( /* char *filename */ );
218 extern void sound_stat ( /* char *filename */ );
219 extern SOUND *sound_lookup ( /* char *sound_name, int mode, SERVER *server */ );
220 extern SOUND *sound_create ();
221 extern SOUND *sound_insert ( /* char *, int, int */ );
222 extern int sound_map ( /* SOUND *s */ );
223 extern int sound_unmap ( /* SOUND *s */ );
224 extern void sound_delete ( /* SOUND *s, int remove */ );
225 extern BUFFER *sound_list_create ();
226 extern void sound_cleanup ();
227 extern SINDEX *sound_open ( /* SOUND *, int */ );
228 extern int sound_close ( /* SINDEX * */ );
229 extern int sound_fill ( /* SINDEX *, BUFFER *data, int as_is */ );
230 extern int sound_seek ( /* SINDEX *, int offset, int whence */ );
231 extern void sound_clean ( /* SOUND *s */ );
232 extern int number_of_samples ( /* SOUND *s, int bytes */ );
233 #endif
234
235 #if defined(HAVE_CDROM) || defined(HAVE_HELPERS)
236 #ifdef __STDC__
237 extern BUFFER *sound_pipe_read (SINDEX *si);
238 #else
239 extern BUFFER *sound_pipe_read (/* SINDEX *si */);
240 #endif
241 #endif
242
243 #endif /* _sound_h */