Mercurial > sdl-ios-xcode
annotate docs/html/sdlbuildaudiocvt.html @ 773:da0a2ad35bf4
Date: Sun, 4 Jan 2004 23:48:19 +0100
From: Max Horn
Subject: Re: Again Audio CD patch
Am 04.01.2004 um 22:38 schrieb Sam Lantinga:
>
> Okay, I fixed the buffering problems by simply using a 4 second buffer
> instead of a 1 second buffer. However, using your code I can't play an
> entire CD - the playback stops after the first song.
>
Found the problem: FSReadFork returns eofErr when the file is finished.
However, we check its return value for errors, and if anything but
noErr occurs, the reader thread aborts its current iteration. That is
bad, because it aborts before it can ever set the flag which tells that
the file is over (also, any remaining data which FSRead did return is
lost - so you'd not hear about to 4 seconds from the end of the file.
Furthermore, the computed data size was 8 bytes to high (I forgot to
account for the fact that the size of an (A)IFF chunk always contains
the chunk header & size fields, too). This is enough to make it work.
However, the end condition is rather fragile, so I tuned some other
things to be pessimistic (check for <= 0 instead of == 0, when eofErr
is encountered enforce mReadFilePosition == mFileLength). You never
know...
The attached patch fixes the issue for me.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 05 Jan 2004 00:57:51 +0000 |
parents | e5bc29de3f0a |
children | 355632dca928 |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_BuildAudioCVT</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64 |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="Audio" | |
14 HREF="audio.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_AudioCVT" | |
17 HREF="sdlaudiocvt.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_ConvertAudio" | |
20 HREF="sdlconvertaudio.html"></HEAD | |
21 ><BODY | |
22 CLASS="REFENTRY" | |
23 BGCOLOR="#FFF8DC" | |
24 TEXT="#000000" | |
25 LINK="#0000ee" | |
26 VLINK="#551a8b" | |
27 ALINK="#ff0000" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
31 WIDTH="100%" | |
32 BORDER="0" | |
33 CELLPADDING="0" | |
34 CELLSPACING="0" | |
35 ><TR | |
36 ><TH | |
37 COLSPAN="3" | |
38 ALIGN="center" | |
39 >SDL Library Documentation</TH | |
40 ></TR | |
41 ><TR | |
42 ><TD | |
43 WIDTH="10%" | |
44 ALIGN="left" | |
45 VALIGN="bottom" | |
46 ><A | |
47 HREF="sdlaudiocvt.html" | |
48 >Prev</A | |
49 ></TD | |
50 ><TD | |
51 WIDTH="80%" | |
52 ALIGN="center" | |
53 VALIGN="bottom" | |
54 ></TD | |
55 ><TD | |
56 WIDTH="10%" | |
57 ALIGN="right" | |
58 VALIGN="bottom" | |
59 ><A | |
60 HREF="sdlconvertaudio.html" | |
61 >Next</A | |
62 ></TD | |
63 ></TR | |
64 ></TABLE | |
65 ><HR | |
66 ALIGN="LEFT" | |
67 WIDTH="100%"></DIV | |
68 ><H1 | |
69 ><A | |
70 NAME="SDLBUILDAUDIOCVT" | |
71 >SDL_BuildAudioCVT</A | |
72 ></H1 | |
73 ><DIV | |
74 CLASS="REFNAMEDIV" | |
75 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
76 NAME="AEN6614" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_BuildAudioCVT -- Initializes a SDL_AudioCVT structure for conversion</DIV | |
81 ><DIV | |
82 CLASS="REFSYNOPSISDIV" | |
83 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
84 NAME="AEN6617" |
0 | 85 ></A |
86 ><H2 | |
87 >Synopsis</H2 | |
88 ><DIV | |
89 CLASS="FUNCSYNOPSIS" | |
90 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
91 NAME="AEN6618" |
0 | 92 ></A |
93 ><P | |
94 ></P | |
95 ><PRE | |
96 CLASS="FUNCSYNOPSISINFO" | |
97 >#include "SDL.h"</PRE | |
98 ><P | |
99 ><CODE | |
100 ><CODE | |
101 CLASS="FUNCDEF" | |
102 >int <B | |
103 CLASS="FSFUNC" | |
104 >SDL_BuildAudioCVT</B | |
105 ></CODE | |
106 >(SDL_AudioCVT *cvt, Uint16 src_format, Uint8 src_channels, int src_rate, Uint16 dst_format, Uint8 dst_channels, int dst_rate);</CODE | |
107 ></P | |
108 ><P | |
109 ></P | |
110 ></DIV | |
111 ></DIV | |
112 ><DIV | |
113 CLASS="REFSECT1" | |
114 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
115 NAME="AEN6624" |
0 | 116 ></A |
117 ><H2 | |
118 >Description</H2 | |
119 ><P | |
120 >Before an <A | |
121 HREF="sdlaudiocvt.html" | |
122 ><SPAN | |
123 CLASS="STRUCTNAME" | |
124 >SDL_AudioCVT</SPAN | |
125 ></A | |
126 > structure can be used to convert audio data it must be initialized with source and destination information. </P | |
127 ><P | |
128 ><TT | |
129 CLASS="PARAMETER" | |
130 ><I | |
131 >src_format</I | |
132 ></TT | |
133 > and <TT | |
134 CLASS="PARAMETER" | |
135 ><I | |
136 >dst_format</I | |
137 ></TT | |
138 > are the source and destination format of the conversion. (For information on audio formats see <A | |
139 HREF="sdlaudiospec.html" | |
140 ><SPAN | |
141 CLASS="STRUCTNAME" | |
142 > SDL_AudioSpec</SPAN | |
143 ></A | |
144 >). <TT | |
145 CLASS="PARAMETER" | |
146 ><I | |
147 >src_channels</I | |
148 ></TT | |
149 > and <TT | |
150 CLASS="PARAMETER" | |
151 ><I | |
152 >dst_channels</I | |
153 ></TT | |
154 > are the number of channels in the source and destination formats. Finally, <TT | |
155 CLASS="PARAMETER" | |
156 ><I | |
157 >src_rate</I | |
158 ></TT | |
159 > and <TT | |
160 CLASS="PARAMETER" | |
161 ><I | |
162 >dst_rate</I | |
163 ></TT | |
164 > are the frequency or samples-per-second of the source and destination formats. Once again, see <A | |
165 HREF="sdlaudiospec.html" | |
166 ><SPAN | |
167 CLASS="STRUCTNAME" | |
168 >SDL_AudioSpec</SPAN | |
169 ></A | |
170 >.</P | |
171 ></DIV | |
172 ><DIV | |
173 CLASS="REFSECT1" | |
174 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
175 NAME="AEN6640" |
0 | 176 ></A |
177 ><H2 | |
178 >Return Values</H2 | |
179 ><P | |
180 >Returns <SPAN | |
181 CLASS="RETURNVALUE" | |
182 >-1</SPAN | |
183 > if the filter could not be built or 1 if it could.</P | |
184 ></DIV | |
185 ><DIV | |
186 CLASS="REFSECT1" | |
187 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
188 NAME="AEN6644" |
0 | 189 ></A |
190 ><H2 | |
191 >Examples</H2 | |
192 ><P | |
193 >See <A | |
194 HREF="sdlconvertaudio.html" | |
195 ><TT | |
196 CLASS="FUNCTION" | |
197 >SDL_ConvertAudio</TT | |
198 ></A | |
199 >.</P | |
200 ></DIV | |
201 ><DIV | |
202 CLASS="REFSECT1" | |
203 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
204 NAME="AEN6649" |
0 | 205 ></A |
206 ><H2 | |
207 >See Also</H2 | |
208 ><P | |
209 ><A | |
210 HREF="sdlconvertaudio.html" | |
211 ><TT | |
212 CLASS="FUNCTION" | |
213 >SDL_ConvertAudio</TT | |
214 ></A | |
215 >, | |
216 <A | |
217 HREF="sdlaudiocvt.html" | |
218 ><TT | |
219 CLASS="FUNCTION" | |
220 >SDL_AudioCVT</TT | |
221 ></A | |
222 ></P | |
223 ></DIV | |
224 ><DIV | |
225 CLASS="NAVFOOTER" | |
226 ><HR | |
227 ALIGN="LEFT" | |
228 WIDTH="100%"><TABLE | |
229 WIDTH="100%" | |
230 BORDER="0" | |
231 CELLPADDING="0" | |
232 CELLSPACING="0" | |
233 ><TR | |
234 ><TD | |
235 WIDTH="33%" | |
236 ALIGN="left" | |
237 VALIGN="top" | |
238 ><A | |
239 HREF="sdlaudiocvt.html" | |
240 >Prev</A | |
241 ></TD | |
242 ><TD | |
243 WIDTH="34%" | |
244 ALIGN="center" | |
245 VALIGN="top" | |
246 ><A | |
247 HREF="index.html" | |
248 >Home</A | |
249 ></TD | |
250 ><TD | |
251 WIDTH="33%" | |
252 ALIGN="right" | |
253 VALIGN="top" | |
254 ><A | |
255 HREF="sdlconvertaudio.html" | |
256 >Next</A | |
257 ></TD | |
258 ></TR | |
259 ><TR | |
260 ><TD | |
261 WIDTH="33%" | |
262 ALIGN="left" | |
263 VALIGN="top" | |
264 >SDL_AudioCVT</TD | |
265 ><TD | |
266 WIDTH="34%" | |
267 ALIGN="center" | |
268 VALIGN="top" | |
269 ><A | |
270 HREF="audio.html" | |
271 >Up</A | |
272 ></TD | |
273 ><TD | |
274 WIDTH="33%" | |
275 ALIGN="right" | |
276 VALIGN="top" | |
277 >SDL_ConvertAudio</TD | |
278 ></TR | |
279 ></TABLE | |
280 ></DIV | |
281 ></BODY | |
282 ></HTML | |
283 > |