Mercurial > sdl-ios-xcode
annotate docs/html/sdlcd.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_CD</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="CD-ROM" | |
14 HREF="cdrom.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_CDClose" | |
17 HREF="sdlcdclose.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_CDtrack" | |
20 HREF="sdlcdtrack.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="sdlcdclose.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="sdlcdtrack.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="SDLCD" | |
71 >SDL_CD</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="AEN7178" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_CD -- CDROM Drive Information</DIV | |
81 ><DIV | |
82 CLASS="REFSECT1" | |
83 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
84 NAME="AEN7181" |
0 | 85 ></A |
86 ><H2 | |
87 >Structure Definition</H2 | |
88 ><PRE | |
89 CLASS="PROGRAMLISTING" | |
90 >typedef struct{ | |
91 int id; | |
92 CDstatus status; | |
93 int numtracks; | |
94 int cur_track; | |
95 int cur_frame; | |
96 SDL_CDtrack track[SDL_MAX_TRACKS+1]; | |
97 } SDL_CD;</PRE | |
98 ></DIV | |
99 ><DIV | |
100 CLASS="REFSECT1" | |
101 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
102 NAME="AEN7184" |
0 | 103 ></A |
104 ><H2 | |
105 >Structure Data</H2 | |
106 ><DIV | |
107 CLASS="INFORMALTABLE" | |
108 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
109 NAME="AEN7186" |
0 | 110 ></A |
111 ><P | |
112 ></P | |
113 ><TABLE | |
114 BORDER="0" | |
115 CLASS="CALSTABLE" | |
116 ><TBODY | |
117 ><TR | |
118 ><TD | |
119 ALIGN="LEFT" | |
120 VALIGN="TOP" | |
121 ><TT | |
122 CLASS="STRUCTFIELD" | |
123 ><I | |
124 >id</I | |
125 ></TT | |
126 ></TD | |
127 ><TD | |
128 ALIGN="LEFT" | |
129 VALIGN="TOP" | |
130 >Private drive identifier</TD | |
131 ></TR | |
132 ><TR | |
133 ><TD | |
134 ALIGN="LEFT" | |
135 VALIGN="TOP" | |
136 ><TT | |
137 CLASS="STRUCTFIELD" | |
138 ><I | |
139 >status</I | |
140 ></TT | |
141 ></TD | |
142 ><TD | |
143 ALIGN="LEFT" | |
144 VALIGN="TOP" | |
145 >Drive <A | |
146 HREF="sdlcdstatus.html" | |
147 >status</A | |
148 ></TD | |
149 ></TR | |
150 ><TR | |
151 ><TD | |
152 ALIGN="LEFT" | |
153 VALIGN="TOP" | |
154 ><TT | |
155 CLASS="STRUCTFIELD" | |
156 ><I | |
157 >numtracks</I | |
158 ></TT | |
159 ></TD | |
160 ><TD | |
161 ALIGN="LEFT" | |
162 VALIGN="TOP" | |
163 >Number of tracks on the CD</TD | |
164 ></TR | |
165 ><TR | |
166 ><TD | |
167 ALIGN="LEFT" | |
168 VALIGN="TOP" | |
169 ><TT | |
170 CLASS="STRUCTFIELD" | |
171 ><I | |
172 >cur_track</I | |
173 ></TT | |
174 ></TD | |
175 ><TD | |
176 ALIGN="LEFT" | |
177 VALIGN="TOP" | |
178 >Current track</TD | |
179 ></TR | |
180 ><TR | |
181 ><TD | |
182 ALIGN="LEFT" | |
183 VALIGN="TOP" | |
184 ><TT | |
185 CLASS="STRUCTFIELD" | |
186 ><I | |
187 >cur_frame</I | |
188 ></TT | |
189 ></TD | |
190 ><TD | |
191 ALIGN="LEFT" | |
192 VALIGN="TOP" | |
193 >Current frame offset within the track</TD | |
194 ></TR | |
195 ><TR | |
196 ><TD | |
197 ALIGN="LEFT" | |
198 VALIGN="TOP" | |
199 ><TT | |
200 CLASS="STRUCTFIELD" | |
201 ><I | |
202 >track</I | |
203 ></TT | |
204 >[SDL_MAX_TRACKS+1]</TD | |
205 ><TD | |
206 ALIGN="LEFT" | |
207 VALIGN="TOP" | |
208 >Array of track descriptions. (see <A | |
209 HREF="sdlcdtrack.html" | |
210 ><SPAN | |
211 CLASS="STRUCTNAME" | |
212 >SDL_CDtrack</SPAN | |
213 ></A | |
214 >)</TD | |
215 ></TR | |
216 ></TBODY | |
217 ></TABLE | |
218 ><P | |
219 ></P | |
220 ></DIV | |
221 ></DIV | |
222 ><DIV | |
223 CLASS="REFSECT1" | |
224 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
225 NAME="AEN7216" |
0 | 226 ></A |
227 ><H2 | |
228 >Description</H2 | |
229 ><P | |
230 >An <SPAN | |
231 CLASS="STRUCTNAME" | |
232 >SDL_CD</SPAN | |
233 > structure is returned by <A | |
234 HREF="sdlcdopen.html" | |
235 ><TT | |
236 CLASS="FUNCTION" | |
237 >SDL_CDOpen</TT | |
238 ></A | |
239 >. It represents an opened CDROM device and stores information on the layout of the tracks on the disc.</P | |
240 ><P | |
241 >A frame is the base data unit of a CD. <TT | |
242 CLASS="LITERAL" | |
243 >CD_FPS</TT | |
244 > frames is equal to 1 second of music. SDL provides two macros for converting between time and frames: <TT | |
245 CLASS="LITERAL" | |
246 >FRAMES_TO_MSF(f, M,S,F)</TT | |
247 > and <TT | |
248 CLASS="LITERAL" | |
249 >MSF_TO_FRAMES</TT | |
250 >.</P | |
251 ></DIV | |
252 ><DIV | |
253 CLASS="REFSECT1" | |
254 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
255 NAME="AEN7226" |
0 | 256 ></A |
257 ><H2 | |
258 >Examples</H2 | |
259 ><PRE | |
260 CLASS="PROGRAMLISTING" | |
261 >int min, sec, frame; | |
262 int frame_offset; | |
263 | |
264 FRAMES_TO_MSF(cdrom->cur_frame, &min, &sec, &frame); | |
265 printf("Current Position: %d minutes, %d seconds, %d frames\n", min, sec, frame); | |
266 | |
267 frame_offset=MSF_TO_FRAMES(min, sec, frame);</PRE | |
268 ></DIV | |
269 ><DIV | |
270 CLASS="REFSECT1" | |
271 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
272 NAME="AEN7229" |
0 | 273 ></A |
274 ><H2 | |
275 >See Also</H2 | |
276 ><P | |
277 ><A | |
278 HREF="sdlcdopen.html" | |
279 ><TT | |
280 CLASS="FUNCTION" | |
281 >SDL_CDOpen</TT | |
282 ></A | |
283 >, | |
284 <A | |
285 HREF="sdlcdtrack.html" | |
286 ><SPAN | |
287 CLASS="STRUCTNAME" | |
288 >SDL_CDtrack</SPAN | |
289 ></A | |
290 ></P | |
291 ></DIV | |
292 ><DIV | |
293 CLASS="NAVFOOTER" | |
294 ><HR | |
295 ALIGN="LEFT" | |
296 WIDTH="100%"><TABLE | |
297 WIDTH="100%" | |
298 BORDER="0" | |
299 CELLPADDING="0" | |
300 CELLSPACING="0" | |
301 ><TR | |
302 ><TD | |
303 WIDTH="33%" | |
304 ALIGN="left" | |
305 VALIGN="top" | |
306 ><A | |
307 HREF="sdlcdclose.html" | |
308 >Prev</A | |
309 ></TD | |
310 ><TD | |
311 WIDTH="34%" | |
312 ALIGN="center" | |
313 VALIGN="top" | |
314 ><A | |
315 HREF="index.html" | |
316 >Home</A | |
317 ></TD | |
318 ><TD | |
319 WIDTH="33%" | |
320 ALIGN="right" | |
321 VALIGN="top" | |
322 ><A | |
323 HREF="sdlcdtrack.html" | |
324 >Next</A | |
325 ></TD | |
326 ></TR | |
327 ><TR | |
328 ><TD | |
329 WIDTH="33%" | |
330 ALIGN="left" | |
331 VALIGN="top" | |
332 >SDL_CDClose</TD | |
333 ><TD | |
334 WIDTH="34%" | |
335 ALIGN="center" | |
336 VALIGN="top" | |
337 ><A | |
338 HREF="cdrom.html" | |
339 >Up</A | |
340 ></TD | |
341 ><TD | |
342 WIDTH="33%" | |
343 ALIGN="right" | |
344 VALIGN="top" | |
345 >SDL_CDtrack</TD | |
346 ></TR | |
347 ></TABLE | |
348 ></DIV | |
349 ></BODY | |
350 ></HTML | |
351 > |