Mercurial > SDL_sound_CoreAudio
annotate SDL_sound_internal.h @ 340:5a72981b8cba
Added optional, experimental audio conversion routines by Frank Ranostaj.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 20 May 2002 16:21:58 +0000 |
parents | 31cc49d7d0ce |
children | cbb15ecf423a |
rev | line source |
---|---|
4 | 1 /* |
2 * SDL_sound -- An abstract sound format decoding API. | |
3 * Copyright (C) 2001 Ryan C. Gordon. | |
4 * | |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2.1 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Lesser General Public | |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 */ | |
19 | |
20 /* | |
21 * Internal function/structure declaration. Do NOT include in your | |
22 * application. | |
23 * | |
184
47cc2de2ae36
Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents:
143
diff
changeset
|
24 * Please see the file COPYING in the source's root directory. |
4 | 25 * |
26 * This file written by Ryan C. Gordon. (icculus@clutteredmind.org) | |
27 */ | |
28 | |
29 #ifndef _INCLUDE_SDL_SOUND_INTERNAL_H_ | |
30 #define _INCLUDE_SDL_SOUND_INTERNAL_H_ | |
31 | |
32 #ifndef __SDL_SOUND_INTERNAL__ | |
33 #error Do not include this header from your applications. | |
34 #endif | |
35 | |
36 #include "SDL.h" | |
37 | |
322 | 38 #if (defined(_MSC_VER) && !defined(inline)) |
301 | 39 # define inline __inline__ |
40 #endif | |
41 | |
12
2888101dcf98
Added _D(()) macro, decoder_private field, and changed read() method from
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
42 #if (defined DEBUG_CHATTER) |
62
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
42
diff
changeset
|
43 #define SNDDBG(x) printf x |
12
2888101dcf98
Added _D(()) macro, decoder_private field, and changed read() method from
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
44 #else |
62
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
42
diff
changeset
|
45 #define SNDDBG(x) |
12
2888101dcf98
Added _D(()) macro, decoder_private field, and changed read() method from
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
46 #endif |
2888101dcf98
Added _D(()) macro, decoder_private field, and changed read() method from
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
47 |
4 | 48 typedef struct __SOUND_DECODERFUNCTIONS__ |
49 { | |
50 /* This is a block of info about your decoder. See SDL_sound.h. */ | |
51 const Sound_DecoderInfo info; | |
52 | |
53 /* | |
42
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
54 * This is called during the Sound_Init() function. Use this to |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
55 * set up any global state that your decoder needs, such as |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
56 * initializing an external library, etc. |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
57 * |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
58 * Return non-zero if initialization is successful, zero if there's |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
59 * a fatal error. If this method fails, then this decoder is |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
60 * flagged as unavailable until SDL_sound() is shut down and |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
61 * reinitialized, in which case this method will be tried again. |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
62 * |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
63 * Note that the decoders quit() method won't be called if this |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
64 * method fails, so if you can't intialize, you'll have to clean |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
65 * up the half-initialized state in this method. |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
66 */ |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
67 int (*init)(void); |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
68 |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
69 /* |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
70 * This is called during the Sound_Quit() function. Use this to |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
71 * clean up any global state that your decoder has used during its |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
72 * lifespan. |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
73 */ |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
74 void (*quit)(void); |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
75 |
2b63642fb6ff
Removed MULTIPLE_STREAMS_PER_RWOPS and added init() and quit() methods to
Ryan C. Gordon <icculus@icculus.org>
parents:
39
diff
changeset
|
76 /* |
4 | 77 * Returns non-zero if (sample) has a valid fileformat that this |
78 * driver can handle. Zero if this driver can NOT handle the data. | |
79 * | |
80 * Extension, which may be NULL, is just a hint as to the form of | |
81 * data that is being passed in. Most decoders should determine if | |
82 * they can handle the data by the data itself, but others, like | |
83 * the raw data handler, need this hint to know if they should | |
84 * accept the data in the first place. | |
85 * | |
86 * (sample)'s (opaque) field should be cast to a Sound_SampleInternal | |
87 * pointer: | |
88 * | |
89 * Sound_SampleInternal *internal; | |
90 * internal = (Sound_SampleInternal *) sample->opaque; | |
91 * | |
92 * Certain fields of sample will be filled in for the decoder before | |
93 * this call, and others should be filled in by the decoder. Some | |
94 * fields are offlimits, and should NOT be modified. The list: | |
95 * | |
96 * in Sound_SampleInternal section: | |
97 * Sound_Sample *next; (offlimits) | |
98 * Sound_Sample *prev; (offlimits) | |
99 * SDL_RWops *rw; (can use, but do NOT close it) | |
100 * const Sound_DecoderFunctions *funcs; (that's this structure) | |
143
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
101 * Sound_AudioCVT sdlcvt; (offlimits) |
4 | 102 * void *buffer; (offlimits until read() method) |
103 * Uint32 buffer_size; (offlimits until read() method) | |
12
2888101dcf98
Added _D(()) macro, decoder_private field, and changed read() method from
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
104 * void *decoder_private; (read and write access) |
4 | 105 * |
106 * in rest of Sound_Sample: | |
107 * void *opaque; (this was internal section, above) | |
108 * const Sound_DecoderInfo *decoder; (read only) | |
109 * Sound_AudioInfo desired; (read only, usually not needed here) | |
110 * Sound_AudioInfo actual; (please fill this in) | |
111 * void *buffer; (offlimits) | |
112 * Uint32 buffer_size; (offlimits) | |
113 * Sound_SampleFlags flags; (set appropriately) | |
114 */ | |
115 int (*open)(Sound_Sample *sample, const char *ext); | |
116 | |
117 /* | |
118 * Clean up. SDL_sound is done with this sample, so the decoder should | |
119 * clean up any resources it allocated. Anything that wasn't | |
120 * explicitly allocated by the decoder should be LEFT ALONE, since | |
121 * the higher-level SDL_sound layer will clean up its own mess. | |
122 */ | |
123 void (*close)(Sound_Sample *sample); | |
124 | |
125 /* | |
126 * Get more data from (sample). The decoder should get a pointer to | |
127 * the internal structure... | |
128 * | |
129 * Sound_SampleInternal *internal; | |
130 * internal = (Sound_SampleInternal *) sample->opaque; | |
131 * | |
132 * ...and then start decoding. Fill in up to internal->buffer_size | |
133 * bytes of decoded sound in the space pointed to by | |
134 * internal->buffer. The encoded data is read in from internal->rw. | |
135 * Data should be decoded in the format specified during the | |
136 * decoder's open() method in the sample->actual field. The | |
137 * conversion to the desired format is done at a higher level. | |
138 * | |
139 * The return value is the number of bytes decoded into | |
140 * internal->buffer, which can be no more than internal->buffer_size, | |
141 * but can be less. If it is less, you should set a state flag: | |
142 * | |
143 * If there's just no more data (end of file, etc), then do: | |
144 * sample->flags |= SOUND_SAMPLEFLAG_EOF; | |
145 * | |
146 * If there's an unrecoverable error, then do: | |
147 * Sound_SetError(ERR_EXPLAIN_WHAT_WENT_WRONG); | |
148 * sample->flags |= SOUND_SAMPLEFLAG_ERROR; | |
149 * | |
150 * If there's more data, but you'd have to block for considerable | |
151 * amounts of time to get at it, or there's a recoverable error, | |
152 * then do: | |
153 * Sound_SetError(ERR_EXPLAIN_WHAT_WENT_WRONG); | |
154 * sample->flags |= SOUND_SAMPLEFLAG_EAGAIN; | |
155 * | |
156 * SDL_sound will not call your read() method for any samples with | |
157 * SOUND_SAMPLEFLAG_EOF or SOUND_SAMPLEFLAG_ERROR set. The | |
158 * SOUND_SAMPLEFLAG_EAGAIN flag is reset before each call to this | |
159 * method. | |
160 */ | |
12
2888101dcf98
Added _D(()) macro, decoder_private field, and changed read() method from
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
161 Uint32 (*read)(Sound_Sample *sample); |
223
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
162 |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
163 /* |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
164 * Reset the decoding to the beginning of the stream. Nonzero on |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
165 * success, zero on failure. |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
166 * |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
167 * The purpose of this method is to allow for higher efficiency than |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
168 * an application could get by just recreating the sample externally; |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
169 * not only do they not have to reopen the RWops, reallocate buffers, |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
170 * and potentially pass the data through several rejecting decoders, |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
171 * but certain decoders will not have to recreate their existing |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
172 * state (search for metadata, etc) since they already know they |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
173 * have a valid audio stream with a given set of characteristics. |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
174 * |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
175 * The decoder is responsible for calling seek() on the associated |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
176 * SDL_RWops. A failing call to seek() should be the ONLY reason that |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
177 * this method should ever fail! |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
178 */ |
249186e31431
Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
179 int (*rewind)(Sound_Sample *sample); |
306
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
180 |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
181 /* |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
182 * Reposition the decoding to an arbitrary point. Nonzero on |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
183 * success, zero on failure. |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
184 * |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
185 * The purpose of this method is to allow for higher efficiency than |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
186 * an application could get by just rewinding the sample and |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
187 * decoding to a given point. |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
188 * |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
189 * The decoder is responsible for calling seek() on the associated |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
190 * SDL_RWops. |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
191 * |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
192 * If there is an error, try to recover so that the next read will |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
193 * continue as if nothing happened. |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
194 */ |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
195 int (*seek)(Sound_Sample *sample, Uint32 ms); |
4 | 196 } Sound_DecoderFunctions; |
197 | |
198 | |
143
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
199 /* A structure to hold a set of audio conversion filters and buffers */ |
340
5a72981b8cba
Added optional, experimental audio conversion routines by Frank Ranostaj.
Ryan C. Gordon <icculus@icculus.org>
parents:
322
diff
changeset
|
200 #if (defined SOUND_USE_ALTCVT) |
5a72981b8cba
Added optional, experimental audio conversion routines by Frank Ranostaj.
Ryan C. Gordon <icculus@icculus.org>
parents:
322
diff
changeset
|
201 #include "alt_audio_convert.h" |
5a72981b8cba
Added optional, experimental audio conversion routines by Frank Ranostaj.
Ryan C. Gordon <icculus@icculus.org>
parents:
322
diff
changeset
|
202 #else |
143
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
203 typedef struct Sound_AudioCVT |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
204 { |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
205 int needed; /* Set to 1 if conversion possible */ |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
206 Uint16 src_format; /* Source audio format */ |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
207 Uint16 dst_format; /* Target audio format */ |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
208 double rate_incr; /* Rate conversion increment */ |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
209 Uint8 *buf; /* Buffer to hold entire audio data */ |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
210 int len; /* Length of original audio buffer */ |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
211 int len_cvt; /* Length of converted audio buffer */ |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
212 int len_mult; /* buffer must be len*len_mult big */ |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
213 double len_ratio; /* Given len, final size is len*len_ratio */ |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
214 void (*filters[20])(struct Sound_AudioCVT *cvt, Uint16 *format); |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
215 int filter_index; /* Current audio conversion function */ |
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
216 } Sound_AudioCVT; |
340
5a72981b8cba
Added optional, experimental audio conversion routines by Frank Ranostaj.
Ryan C. Gordon <icculus@icculus.org>
parents:
322
diff
changeset
|
217 #endif |
143
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
218 |
4 | 219 typedef struct __SOUND_SAMPLEINTERNAL__ |
220 { | |
221 Sound_Sample *next; | |
222 Sound_Sample *prev; | |
223 SDL_RWops *rw; | |
224 const Sound_DecoderFunctions *funcs; | |
143
3e60862fbd76
Start of audio converter work.
Ryan C. Gordon <icculus@icculus.org>
parents:
107
diff
changeset
|
225 Sound_AudioCVT sdlcvt; |
4 | 226 void *buffer; |
227 Uint32 buffer_size; | |
12
2888101dcf98
Added _D(()) macro, decoder_private field, and changed read() method from
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
228 void *decoder_private; |
4 | 229 } Sound_SampleInternal; |
230 | |
231 | |
232 /* error messages... */ | |
233 #define ERR_IS_INITIALIZED "Already initialized" | |
234 #define ERR_NOT_INITIALIZED "Not initialized" | |
235 #define ERR_INVALID_ARGUMENT "Invalid argument" | |
236 #define ERR_OUT_OF_MEMORY "Out of memory" | |
237 #define ERR_NOT_SUPPORTED "Operation not supported" | |
238 #define ERR_UNSUPPORTED_FORMAT "Sound format unsupported" | |
239 #define ERR_NOT_A_HANDLE "Not a file handle" | |
240 #define ERR_NO_SUCH_FILE "No such file" | |
241 #define ERR_PAST_EOF "Past end of file" | |
242 #define ERR_IO_ERROR "I/O error" | |
243 #define ERR_COMPRESSION "(De)compression error" | |
244 #define ERR_PREV_ERROR "Previous decoding already caused an error" | |
245 #define ERR_PREV_EOF "Previous decoding already triggered EOF" | |
306
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
246 #define ERR_CANNOT_SEEK "Sample is not seekable" |
4 | 247 |
248 /* | |
249 * Call this to set the message returned by Sound_GetError(). | |
250 * Please only use the ERR_* constants above, or add new constants to the | |
251 * above group, but I want these all in one place. | |
252 * | |
253 * Calling this with a NULL argument is a safe no-op. | |
254 */ | |
306
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
255 void __Sound_SetError(const char *err); |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
256 |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
257 /* !!! FIXME: Clean up elsewhere and get rid of this. */ |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
258 #define Sound_SetError __Sound_SetError |
4 | 259 |
306
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
260 /* |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
261 * Call this to convert milliseconds to an actual byte position, based on |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
262 * audio data characteristics. |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
263 */ |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
264 Uint32 __Sound_convertMsToBytePos(Sound_AudioInfo *info, Uint32 ms); |
4 | 265 |
266 /* | |
267 * Use this if you need a cross-platform stricmp(). | |
268 */ | |
269 int __Sound_strcasecmp(const char *x, const char *y); | |
270 | |
271 | |
272 /* These get used all over for lessening code clutter. */ | |
306
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
273 #define BAIL_MACRO(e, r) { __Sound_SetError(e); return r; } |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
274 #define BAIL_IF_MACRO(c, e, r) if (c) { __Sound_SetError(e); return r; } |
4 | 275 |
276 | |
277 | |
278 | |
279 /*--------------------------------------------------------------------------*/ | |
280 /*--------------------------------------------------------------------------*/ | |
281 /*------------ ----------------*/ | |
282 /*------------ You MUST implement the following functions ----------------*/ | |
283 /*------------ if porting to a new platform. ----------------*/ | |
284 /*------------ (see platform/unix.c for an example) ----------------*/ | |
285 /*------------ ----------------*/ | |
286 /*--------------------------------------------------------------------------*/ | |
287 /*--------------------------------------------------------------------------*/ | |
288 | |
289 | |
290 /* (None, right now.) */ | |
291 | |
292 | |
293 #ifdef __cplusplus | |
294 extern "C" { | |
295 #endif | |
296 | |
297 #endif /* defined _INCLUDE_SDL_SOUND_INTERNAL_H_ */ | |
298 | |
299 /* end of SDL_sound_internal.h ... */ | |
300 |