Mercurial > SDL_sound_CoreAudio
annotate SDL_sound.c @ 104:103cfcb3c014
Updated to fix build system problem.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 03 Oct 2001 18:15:52 +0000 |
parents | 72502bed0aef |
children | 427541211bfd |
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 * This file implements the core API, which is relatively simple. | |
22 * The real meat of SDL_sound is in the decoders directory. | |
23 * | |
24 * Documentation is in SDL_sound.h ... It's verbose, honest. :) | |
25 * | |
26 * Please see the file LICENSE in the source's root directory. | |
27 * | |
28 * This file written by Ryan C. Gordon. (icculus@clutteredmind.org) | |
29 */ | |
30 | |
31 | |
32 #include <stdio.h> | |
33 #include <stdlib.h> | |
34 #include <string.h> | |
35 #include <assert.h> | |
36 #include <ctype.h> | |
37 | |
38 #include "SDL.h" | |
39 #include "SDL_sound.h" | |
40 | |
41 #define __SDL_SOUND_INTERNAL__ | |
42 #include "SDL_sound_internal.h" | |
43 | |
44 | |
45 /* The various decoder drivers... */ | |
46 | |
10
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
47 #if (defined SOUND_SUPPORTS_MP3) |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
48 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_MP3; |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
49 #endif |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
50 |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
51 #if (defined SOUND_SUPPORTS_MOD) |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
52 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_MOD; |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
53 #endif |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
54 |
20 | 55 #if (defined SOUND_SUPPORTS_WAV) |
56 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_WAV; | |
57 #endif | |
58 | |
37
f27bcbcaeab1
Added AIFF entry, and (for now) some multiple-streams-in-one-rwops support.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
59 #if (defined SOUND_SUPPORTS_AIFF) |
f27bcbcaeab1
Added AIFF entry, and (for now) some multiple-streams-in-one-rwops support.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
60 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_AIFF; |
f27bcbcaeab1
Added AIFF entry, and (for now) some multiple-streams-in-one-rwops support.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
61 #endif |
f27bcbcaeab1
Added AIFF entry, and (for now) some multiple-streams-in-one-rwops support.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
62 |
26
ddc3614c9042
Bugfix (thanks Tsuyoshi Iguchi!), and Ogg Vorbis decoder entry.
Ryan C. Gordon <icculus@icculus.org>
parents:
20
diff
changeset
|
63 #if (defined SOUND_SUPPORTS_OGG) |
ddc3614c9042
Bugfix (thanks Tsuyoshi Iguchi!), and Ogg Vorbis decoder entry.
Ryan C. Gordon <icculus@icculus.org>
parents:
20
diff
changeset
|
64 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_OGG; |
ddc3614c9042
Bugfix (thanks Tsuyoshi Iguchi!), and Ogg Vorbis decoder entry.
Ryan C. Gordon <icculus@icculus.org>
parents:
20
diff
changeset
|
65 #endif |
ddc3614c9042
Bugfix (thanks Tsuyoshi Iguchi!), and Ogg Vorbis decoder entry.
Ryan C. Gordon <icculus@icculus.org>
parents:
20
diff
changeset
|
66 |
4 | 67 #if (defined SOUND_SUPPORTS_VOC) |
68 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_VOC; | |
69 #endif | |
70 | |
71 #if (defined SOUND_SUPPORTS_RAW) | |
72 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_RAW; | |
73 #endif | |
74 | |
102 | 75 #if (defined SOUND_SUPPORTS_SHN) |
76 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_SHN; | |
77 #endif | |
78 | |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
79 |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
80 |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
81 typedef struct |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
82 { |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
83 int available; |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
84 const Sound_DecoderFunctions *funcs; |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
85 } decoder_element; |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
86 |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
87 static decoder_element decoders[] = |
4 | 88 { |
10
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
89 #if (defined SOUND_SUPPORTS_MP3) |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
90 { 0, &__Sound_DecoderFunctions_MP3 }, |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
91 #endif |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
92 |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
93 #if (defined SOUND_SUPPORTS_MOD) |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
94 { 0, &__Sound_DecoderFunctions_MOD }, |
10
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
95 #endif |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
96 |
20 | 97 #if (defined SOUND_SUPPORTS_WAV) |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
98 { 0, &__Sound_DecoderFunctions_WAV }, |
20 | 99 #endif |
100 | |
37
f27bcbcaeab1
Added AIFF entry, and (for now) some multiple-streams-in-one-rwops support.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
101 #if (defined SOUND_SUPPORTS_AIFF) |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
102 { 0, &__Sound_DecoderFunctions_AIFF }, |
37
f27bcbcaeab1
Added AIFF entry, and (for now) some multiple-streams-in-one-rwops support.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
103 #endif |
f27bcbcaeab1
Added AIFF entry, and (for now) some multiple-streams-in-one-rwops support.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
104 |
26
ddc3614c9042
Bugfix (thanks Tsuyoshi Iguchi!), and Ogg Vorbis decoder entry.
Ryan C. Gordon <icculus@icculus.org>
parents:
20
diff
changeset
|
105 #if (defined SOUND_SUPPORTS_OGG) |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
106 { 0, &__Sound_DecoderFunctions_OGG }, |
26
ddc3614c9042
Bugfix (thanks Tsuyoshi Iguchi!), and Ogg Vorbis decoder entry.
Ryan C. Gordon <icculus@icculus.org>
parents:
20
diff
changeset
|
107 #endif |
ddc3614c9042
Bugfix (thanks Tsuyoshi Iguchi!), and Ogg Vorbis decoder entry.
Ryan C. Gordon <icculus@icculus.org>
parents:
20
diff
changeset
|
108 |
4 | 109 #if (defined SOUND_SUPPORTS_VOC) |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
110 { 0, &__Sound_DecoderFunctions_VOC }, |
4 | 111 #endif |
112 | |
113 #if (defined SOUND_SUPPORTS_RAW) | |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
114 { 0, &__Sound_DecoderFunctions_RAW }, |
4 | 115 #endif |
102 | 116 |
117 #if (defined SOUND_SUPPORTS_SHN) | |
118 { 0, &__Sound_DecoderFunctions_SHN }, | |
119 #endif | |
4 | 120 }; |
121 | |
122 | |
123 | |
124 /* General SDL_sound state ... */ | |
125 | |
126 static int initialized = 0; | |
127 static Sound_Sample *samplesList = NULL; /* this is a linked list. */ | |
128 static const Sound_DecoderInfo **available_decoders = NULL; | |
129 | |
130 | |
131 /* functions ... */ | |
132 | |
133 void Sound_GetLinkedVersion(Sound_Version *ver) | |
134 { | |
135 if (ver != NULL) | |
136 { | |
137 ver->major = SOUND_VER_MAJOR; | |
138 ver->minor = SOUND_VER_MINOR; | |
139 ver->patch = SOUND_VER_PATCH; | |
140 } /* if */ | |
141 } /* Sound_GetLinkedVersion */ | |
142 | |
143 | |
144 int Sound_Init(void) | |
145 { | |
146 size_t i; | |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
147 size_t pos = 0; |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
148 size_t total = sizeof (decoders) / sizeof (decoders[0]); |
4 | 149 BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0); |
150 samplesList = NULL; | |
151 | |
152 SDL_Init(SDL_INIT_AUDIO); | |
153 | |
154 available_decoders = (const Sound_DecoderInfo **) | |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
155 malloc((total + 1) * sizeof (Sound_DecoderInfo *)); |
4 | 156 BAIL_IF_MACRO(available_decoders == NULL, ERR_OUT_OF_MEMORY, 0); |
157 | |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
158 for (i = 0; i < total; i++) |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
159 { |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
160 decoders[i].available = decoders[i].funcs->init(); |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
161 if (decoders[i].available) |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
162 { |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
163 available_decoders[pos] = &(decoders[i].funcs->info); |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
164 pos++; |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
165 } /* if */ |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
166 } /* for */ |
4 | 167 |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
168 available_decoders[pos] = NULL; |
26
ddc3614c9042
Bugfix (thanks Tsuyoshi Iguchi!), and Ogg Vorbis decoder entry.
Ryan C. Gordon <icculus@icculus.org>
parents:
20
diff
changeset
|
169 |
4 | 170 initialized = 1; |
171 return(1); | |
172 } /* Sound_Init */ | |
173 | |
174 | |
175 int Sound_Quit(void) | |
176 { | |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
177 size_t total = sizeof (decoders) / sizeof (decoders[0]); |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
178 size_t i; |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
179 |
4 | 180 BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0); |
181 | |
182 while (((volatile Sound_Sample *) samplesList) != NULL) | |
183 Sound_FreeSample(samplesList); | |
184 | |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
185 for (i = 0; i < total; i++) |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
186 { |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
187 if (decoders[i].available) |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
188 { |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
189 decoders[i].funcs->quit(); |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
190 decoders[i].available = 0; |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
191 } /* if */ |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
192 } /* for */ |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
193 |
4 | 194 if (available_decoders != NULL) |
80
25ee62c6b333
Fixed a const complaint from Visual C++ 6.0.
Ryan C. Gordon <icculus@icculus.org>
parents:
62
diff
changeset
|
195 free((void *) available_decoders); |
4 | 196 available_decoders = NULL; |
197 | |
198 initialized = 0; | |
199 | |
200 return(1); | |
201 } /* Sound_Quit */ | |
202 | |
203 | |
204 const Sound_DecoderInfo **Sound_AvailableDecoders(void) | |
205 { | |
206 return(available_decoders); /* READ. ONLY. */ | |
207 } /* Sound_AvailableDecoders */ | |
208 | |
209 | |
210 const char *Sound_GetError(void) | |
211 { | |
212 return(SDL_GetError()); | |
213 } /* Sound_GetError */ | |
214 | |
215 | |
216 void Sound_ClearError(void) | |
217 { | |
218 SDL_ClearError(); | |
219 } /* Sound_ClearError */ | |
220 | |
221 | |
222 /* | |
223 * This is declared in the internal header. | |
224 */ | |
225 void Sound_SetError(const char *err) | |
226 { | |
227 if (err != NULL) | |
10
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
228 { |
62
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
229 SNDDBG(("Sound_SetError(\"%s\");\n", err)); |
4 | 230 SDL_SetError(err); |
10
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
231 } /* if */ |
4 | 232 } /* Sound_SetError */ |
233 | |
234 | |
235 /* | |
236 * -ansi and -pedantic flags prevent use of strcasecmp() on Linux, and | |
237 * I honestly don't want to mess around with figuring out if a given | |
238 * platform has "strcasecmp", "stricmp", or | |
239 * "compare_two_damned_strings_case_insensitive", which I hear is in the | |
240 * next release of Carbon. :) This is exported so decoders may use it if | |
241 * they like. | |
242 */ | |
243 int __Sound_strcasecmp(const char *x, const char *y) | |
244 { | |
245 int ux, uy; | |
246 | |
98
dfdf7b4e05bd
Changed __Sound_strcasecmp() to handle NULL strings gracefully.
Ryan C. Gordon <icculus@icculus.org>
parents:
80
diff
changeset
|
247 if (x == y) /* same pointer? Both NULL? */ |
dfdf7b4e05bd
Changed __Sound_strcasecmp() to handle NULL strings gracefully.
Ryan C. Gordon <icculus@icculus.org>
parents:
80
diff
changeset
|
248 return(0); |
dfdf7b4e05bd
Changed __Sound_strcasecmp() to handle NULL strings gracefully.
Ryan C. Gordon <icculus@icculus.org>
parents:
80
diff
changeset
|
249 |
dfdf7b4e05bd
Changed __Sound_strcasecmp() to handle NULL strings gracefully.
Ryan C. Gordon <icculus@icculus.org>
parents:
80
diff
changeset
|
250 if (x == NULL) |
dfdf7b4e05bd
Changed __Sound_strcasecmp() to handle NULL strings gracefully.
Ryan C. Gordon <icculus@icculus.org>
parents:
80
diff
changeset
|
251 return(-1); |
dfdf7b4e05bd
Changed __Sound_strcasecmp() to handle NULL strings gracefully.
Ryan C. Gordon <icculus@icculus.org>
parents:
80
diff
changeset
|
252 |
dfdf7b4e05bd
Changed __Sound_strcasecmp() to handle NULL strings gracefully.
Ryan C. Gordon <icculus@icculus.org>
parents:
80
diff
changeset
|
253 if (y == NULL) |
dfdf7b4e05bd
Changed __Sound_strcasecmp() to handle NULL strings gracefully.
Ryan C. Gordon <icculus@icculus.org>
parents:
80
diff
changeset
|
254 return(1); |
dfdf7b4e05bd
Changed __Sound_strcasecmp() to handle NULL strings gracefully.
Ryan C. Gordon <icculus@icculus.org>
parents:
80
diff
changeset
|
255 |
4 | 256 do |
257 { | |
258 ux = toupper((int) *x); | |
259 uy = toupper((int) *y); | |
260 if (ux > uy) | |
261 return(1); | |
262 else if (ux < uy) | |
263 return(-1); | |
264 x++; | |
265 y++; | |
266 } while ((ux) && (uy)); | |
267 | |
268 return(0); | |
269 } /* __Sound_strcasecmp */ | |
270 | |
271 | |
272 /* | |
273 * Allocate a Sound_Sample, and fill in most of its fields. Those that need | |
274 * to be filled in later, by a decoder, will be initialized to zero. | |
275 */ | |
276 static Sound_Sample *alloc_sample(SDL_RWops *rw, Sound_AudioInfo *desired, | |
277 Uint32 bufferSize) | |
278 { | |
279 Sound_Sample *retval = malloc(sizeof (Sound_Sample)); | |
280 Sound_SampleInternal *internal = malloc(sizeof (Sound_SampleInternal)); | |
281 if ((retval == NULL) || (internal == NULL)) | |
282 { | |
283 Sound_SetError(ERR_OUT_OF_MEMORY); | |
284 if (retval) | |
285 free(retval); | |
286 if (internal) | |
287 free(internal); | |
288 | |
289 return(NULL); | |
290 } /* if */ | |
291 | |
292 memset(retval, '\0', sizeof (Sound_Sample)); | |
293 memset(internal, '\0', sizeof (Sound_SampleInternal)); | |
294 | |
295 assert(bufferSize > 0); | |
296 retval->buffer = malloc(bufferSize); /* pure ugly. */ | |
297 if (!retval->buffer) | |
298 { | |
299 Sound_SetError(ERR_OUT_OF_MEMORY); | |
300 free(internal); | |
301 free(retval); | |
302 return(NULL); | |
303 } /* if */ | |
304 memset(retval->buffer, '\0', bufferSize); | |
305 retval->buffer_size = bufferSize; | |
306 | |
307 if (desired != NULL) | |
308 memcpy(&retval->desired, desired, sizeof (Sound_AudioInfo)); | |
309 | |
310 internal->rw = rw; | |
311 retval->opaque = internal; | |
312 return(retval); | |
313 } /* alloc_sample */ | |
314 | |
315 | |
10
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
316 #if (defined DEBUG_CHATTER) |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
317 static __inline__ const char *fmt_to_str(Uint16 fmt) |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
318 { |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
319 switch(fmt) |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
320 { |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
321 case AUDIO_U8: |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
322 return("U8"); |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
323 case AUDIO_S8: |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
324 return("S8"); |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
325 case AUDIO_U16LSB: |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
326 return("U16LSB"); |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
327 case AUDIO_S16LSB: |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
328 return("S16LSB"); |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
329 case AUDIO_U16MSB: |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
330 return("U16MSB"); |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
331 case AUDIO_S16MSB: |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
332 return("S16MSB"); |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
333 } /* switch */ |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
334 |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
335 return("Unknown"); |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
336 } /* fmt_to_str */ |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
337 #endif |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
338 |
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
339 |
4 | 340 /* |
341 * The bulk of the Sound_NewSample() work is done here... | |
342 * Ask the specified decoder to handle the data in (rw), and if | |
343 * so, construct the Sound_Sample. Otherwise, try to wind (rw)'s stream | |
344 * back to where it was, and return false. | |
345 * | |
346 * !!! FIXME: This is big, ugly, nasty, and smelly. | |
347 */ | |
348 static int init_sample(const Sound_DecoderFunctions *funcs, | |
349 Sound_Sample *sample, const char *ext, | |
350 Sound_AudioInfo *_desired) | |
351 { | |
352 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; | |
37
f27bcbcaeab1
Added AIFF entry, and (for now) some multiple-streams-in-one-rwops support.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
353 Sound_AudioInfo desired; |
4 | 354 int pos = SDL_RWtell(internal->rw); /* !!! FIXME: Int? Really? */ |
355 | |
356 /* fill in the funcs for this decoder... */ | |
357 sample->decoder = &funcs->info; | |
358 internal->funcs = funcs; | |
359 if (!funcs->open(sample, ext)) | |
360 { | |
361 SDL_RWseek(internal->rw, pos, SEEK_SET); /* set for next try... */ | |
362 return(0); | |
363 } /* if */ | |
364 | |
365 /* success; we've got a decoder! */ | |
366 | |
367 /* Now we need to set up the conversion buffer... */ | |
368 | |
369 memcpy(&desired, (_desired != NULL) ? _desired : &sample->actual, | |
370 sizeof (Sound_AudioInfo)); | |
371 | |
372 if (SDL_BuildAudioCVT(&internal->sdlcvt, | |
373 sample->actual.format, | |
374 sample->actual.channels, | |
375 (int) sample->actual.rate, /* !!! FIXME: Int? Really? */ | |
376 desired.format, | |
377 desired.channels, | |
378 (int) desired.rate) == -1) /* !!! FIXME: Int? Really? */ | |
379 { | |
380 Sound_SetError(SDL_GetError()); | |
381 funcs->close(sample); | |
382 SDL_RWseek(internal->rw, pos, SEEK_SET); /* set for next try... */ | |
383 return(0); | |
384 } /* if */ | |
385 | |
386 if (internal->sdlcvt.len_mult > 1) | |
387 { | |
388 void *rc = realloc(sample->buffer, | |
389 sample->buffer_size * internal->sdlcvt.len_mult); | |
390 if (rc == NULL) | |
391 { | |
392 funcs->close(sample); | |
393 SDL_RWseek(internal->rw, pos, SEEK_SET); /* set for next try... */ | |
394 return(0); | |
395 } /* if */ | |
396 | |
397 sample->buffer = rc; | |
398 } /* if */ | |
399 | |
400 /* these pointers are all one and the same. */ | |
401 memcpy(&sample->desired, &desired, sizeof (Sound_AudioInfo)); | |
402 internal->sdlcvt.buf = internal->buffer = sample->buffer; | |
403 internal->buffer_size = sample->buffer_size / internal->sdlcvt.len_mult; | |
404 internal->sdlcvt.len = internal->buffer_size; | |
405 | |
406 /* Prepend our new Sound_Sample to the samplesList... */ | |
407 if (samplesList != NULL) | |
408 { | |
409 internal->next = samplesList; | |
410 if (samplesList != NULL) | |
411 internal->prev = sample; | |
412 } /* if */ | |
413 samplesList = sample; | |
414 | |
62
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
415 SNDDBG(("New sample DESIRED format: %s format, %d rate, %d channels.\n", |
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
416 fmt_to_str(sample->desired.format), |
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
417 sample->desired.rate, |
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
418 sample->desired.channels)); |
10
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
419 |
62
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
420 SNDDBG(("New sample ACTUAL format: %s format, %d rate, %d channels.\n", |
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
421 fmt_to_str(sample->actual.format), |
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
422 sample->actual.rate, |
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
423 sample->actual.channels)); |
10
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
424 |
62
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
425 SNDDBG(("On-the-fly conversion: %s.\n", |
b13fafb976be
Changed _D macro to DBGSND.
Ryan C. Gordon <icculus@icculus.org>
parents:
48
diff
changeset
|
426 internal->sdlcvt.needed ? "ENABLED" : "DISABLED")); |
10
cc2c32349380
Some debugging output, and MP3 and VOC entries, added.
Ryan C. Gordon <icculus@icculus.org>
parents:
4
diff
changeset
|
427 |
4 | 428 return(1); |
429 } /* init_sample */ | |
430 | |
431 | |
432 Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext, | |
433 Sound_AudioInfo *desired, Uint32 bSize) | |
434 { | |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
435 size_t total = sizeof (decoders) / sizeof (decoders[0]); |
4 | 436 size_t i; |
437 Sound_Sample *retval; | |
438 | |
439 /* sanity checks. */ | |
440 BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, NULL); | |
441 BAIL_IF_MACRO(rw == NULL, ERR_INVALID_ARGUMENT, NULL); | |
442 | |
443 retval = alloc_sample(rw, desired, bSize); | |
444 if (!retval) | |
445 return(NULL); /* alloc_sample() sets error message... */ | |
446 | |
447 if (ext != NULL) | |
448 { | |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
449 for (i = 0; i < total; i++) |
4 | 450 { |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
451 if (decoders[i].available) |
4 | 452 { |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
453 const char *decoderExt = decoders[i].funcs->info.extension; |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
454 if (__Sound_strcasecmp(decoderExt, ext) == 0) |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
455 { |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
456 if (init_sample(decoders[i].funcs, retval, ext, desired)) |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
457 return(retval); |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
458 } /* if */ |
4 | 459 } /* if */ |
460 } /* for */ | |
461 } /* if */ | |
462 | |
463 /* no direct extension match? Try everything we've got... */ | |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
464 for (i = 0; i < total; i++) |
4 | 465 { |
48
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
466 if (decoders[i].available) |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
467 { |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
468 if (init_sample(decoders[i].funcs, retval, ext, desired)) |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
469 return(retval); |
c4b8c39a9798
Individual decoders are now initialized during Sound_Init(), and deinitialized
Ryan C. Gordon <icculus@icculus.org>
parents:
37
diff
changeset
|
470 } /* if */ |
4 | 471 } /* for */ |
472 | |
473 /* nothing could handle the sound data... */ | |
474 free(retval->opaque); | |
475 if (retval->buffer != NULL) | |
476 free(retval->buffer); | |
477 free(retval); | |
478 SDL_RWclose(rw); | |
479 Sound_SetError(ERR_UNSUPPORTED_FORMAT); | |
480 return(NULL); | |
481 } /* Sound_NewSample */ | |
482 | |
483 | |
484 Sound_Sample *Sound_NewSampleFromFile(const char *filename, | |
485 Sound_AudioInfo *desired, | |
486 Uint32 bufferSize) | |
487 { | |
488 const char *ext; | |
489 SDL_RWops *rw; | |
490 | |
491 BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, NULL); | |
492 BAIL_IF_MACRO(filename == NULL, ERR_INVALID_ARGUMENT, NULL); | |
493 | |
494 ext = strrchr(filename, '.'); | |
495 rw = SDL_RWFromFile(filename, "rb"); | |
496 BAIL_IF_MACRO(rw == NULL, SDL_GetError(), NULL); | |
497 | |
498 if (ext != NULL) | |
499 ext++; | |
500 | |
501 return(Sound_NewSample(rw, ext, desired, bufferSize)); | |
502 } /* Sound_NewSampleFromFile */ | |
503 | |
504 | |
505 void Sound_FreeSample(Sound_Sample *sample) | |
506 { | |
507 Sound_SampleInternal *internal; | |
508 | |
509 if (!initialized) | |
510 { | |
511 Sound_SetError(ERR_NOT_INITIALIZED); | |
512 return; | |
513 } /* if */ | |
514 | |
515 if (sample == NULL) | |
516 { | |
517 Sound_SetError(ERR_INVALID_ARGUMENT); | |
518 return; | |
519 } /* if */ | |
520 | |
521 internal = (Sound_SampleInternal *) sample->opaque; | |
522 | |
523 internal->funcs->close(sample); | |
524 | |
525 /* update the samplesList... */ | |
526 if (internal->prev != NULL) | |
527 { | |
528 Sound_SampleInternal *prevInternal; | |
529 prevInternal = (Sound_SampleInternal *) internal->prev->opaque; | |
530 prevInternal->next = internal->next; | |
531 } /* if */ | |
532 else | |
533 { | |
534 assert(samplesList == sample); | |
535 samplesList = internal->next; | |
536 } /* else */ | |
537 | |
538 if (internal->next != NULL) | |
539 { | |
540 Sound_SampleInternal *nextInternal; | |
541 nextInternal = (Sound_SampleInternal *) internal->next->opaque; | |
542 nextInternal->prev = internal->prev; | |
543 } /* if */ | |
544 | |
545 /* nuke it... */ | |
546 if (internal->rw != NULL) /* this condition is a "just in case" thing. */ | |
547 SDL_RWclose(internal->rw); | |
548 assert(internal->buffer != NULL); | |
549 if (internal->buffer != sample->buffer) | |
550 free(internal->buffer); | |
551 free(internal); | |
552 if (sample->buffer != NULL) | |
553 free(sample->buffer); | |
554 free(sample); | |
555 } /* Sound_FreeSample */ | |
556 | |
557 | |
558 int Sound_SetBufferSize(Sound_Sample *sample, Uint32 newSize) | |
559 { | |
560 void *newBuf = NULL; | |
561 Sound_SampleInternal *internal = NULL; | |
562 | |
563 BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0); | |
564 BAIL_IF_MACRO(sample == NULL, ERR_INVALID_ARGUMENT, 0); | |
565 internal = ((Sound_SampleInternal *) sample->opaque); | |
566 newBuf = realloc(sample->buffer, newSize * internal->sdlcvt.len_mult); | |
567 BAIL_IF_MACRO(newBuf == NULL, ERR_OUT_OF_MEMORY, 0); | |
568 | |
569 internal->sdlcvt.buf = internal->buffer = sample->buffer = newBuf; | |
570 sample->buffer_size = newSize; | |
571 internal->buffer_size = newSize / internal->sdlcvt.len_mult; | |
572 internal->sdlcvt.len = internal->buffer_size; | |
573 | |
574 return(1); | |
575 } /* Sound_SetBufferSize */ | |
576 | |
577 | |
578 Uint32 Sound_Decode(Sound_Sample *sample) | |
579 { | |
580 Sound_SampleInternal *internal = NULL; | |
581 Uint32 retval = 0; | |
582 | |
583 /* a boatload of sanity checks... */ | |
584 BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0); | |
585 BAIL_IF_MACRO(sample == NULL, ERR_INVALID_ARGUMENT, 0); | |
586 BAIL_IF_MACRO(sample->flags & SOUND_SAMPLEFLAG_ERROR, ERR_PREV_ERROR, 0); | |
587 BAIL_IF_MACRO(sample->flags & SOUND_SAMPLEFLAG_EOF, ERR_PREV_EOF, 0); | |
588 | |
589 internal = (Sound_SampleInternal *) sample->opaque; | |
590 | |
591 assert(sample->buffer != NULL); | |
592 assert(sample->buffer_size > 0); | |
593 assert(internal->buffer != NULL); | |
594 assert(internal->buffer_size > 0); | |
595 | |
596 /* reset EAGAIN. Decoder can flip it back on if it needs to. */ | |
597 sample->flags &= !SOUND_SAMPLEFLAG_EAGAIN; | |
598 retval = internal->funcs->read(sample); | |
37
f27bcbcaeab1
Added AIFF entry, and (for now) some multiple-streams-in-one-rwops support.
Ryan C. Gordon <icculus@icculus.org>
parents:
26
diff
changeset
|
599 |
4 | 600 if (internal->sdlcvt.needed) |
601 { | |
602 internal->sdlcvt.len = retval; | |
603 SDL_ConvertAudio(&internal->sdlcvt); | |
604 retval *= internal->sdlcvt.len_mult; | |
605 } /* if */ | |
606 | |
607 return(retval); | |
608 } /* Sound_Decode */ | |
609 | |
610 | |
611 Uint32 Sound_DecodeAll(Sound_Sample *sample) | |
612 { | |
613 Sound_SampleInternal *internal = NULL; | |
614 void *buf = NULL; | |
615 Uint32 newBufSize = 0; | |
616 | |
617 BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0); | |
618 | |
619 internal = (Sound_SampleInternal *) sample->opaque; | |
620 | |
621 while ( ((sample->flags & SOUND_SAMPLEFLAG_EOF) == 0) && | |
622 ((sample->flags & SOUND_SAMPLEFLAG_ERROR) == 0) ) | |
623 { | |
624 void *ptr = realloc(buf, newBufSize + sample->buffer_size); | |
625 if (ptr == NULL) | |
626 { | |
627 sample->flags |= SOUND_SAMPLEFLAG_ERROR; | |
628 Sound_SetError(ERR_OUT_OF_MEMORY); | |
629 } /* if */ | |
630 else | |
631 { | |
632 Uint32 br = Sound_Decode(sample); | |
633 memcpy( ((char *) buf) + newBufSize, sample->buffer, br ); | |
634 newBufSize += br; | |
635 } /* else */ | |
636 } /* while */ | |
637 | |
638 free(sample->buffer); | |
639 sample->buffer = internal->buffer = internal->sdlcvt.buf = buf; | |
640 sample->buffer_size = newBufSize; | |
641 internal->buffer_size = newBufSize / internal->sdlcvt.len_mult; | |
642 internal->sdlcvt.len_mult = internal->buffer_size; | |
643 | |
644 return(newBufSize); | |
645 } /* Sound_DecodeAll */ | |
646 | |
647 | |
648 /* end of SDL_sound.c ... */ | |
649 |