Mercurial > sdl-ios-xcode
annotate docs/html/sdlcdplaytracks.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_CDPlayTracks</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_CDPlay" | |
17 HREF="sdlcdplay.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_CDPause" | |
20 HREF="sdlcdpause.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="sdlcdplay.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="sdlcdpause.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="SDLCDPLAYTRACKS" | |
71 >SDL_CDPlayTracks</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="AEN6987" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_CDPlayTracks -- Play the given CD track(s)</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="AEN6990" |
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="AEN6991" |
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_CDPlayTracks</B | |
105 ></CODE | |
106 >(SDL_CD *cdrom, int start_track, int start_frame, int ntracks, int nframes));</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="AEN6997" |
0 | 116 ></A |
117 ><H2 | |
118 >Description</H2 | |
119 ><P | |
120 ><TT | |
121 CLASS="FUNCTION" | |
122 >SDL_CDPlayTracks</TT | |
123 > plays the given CD starting at track | |
124 <TT | |
125 CLASS="PARAMETER" | |
126 ><I | |
127 >start_track</I | |
128 ></TT | |
129 >, for <TT | |
130 CLASS="PARAMETER" | |
131 ><I | |
132 >ntracks</I | |
133 ></TT | |
134 > tracks. </P | |
135 ><P | |
136 ><TT | |
137 CLASS="PARAMETER" | |
138 ><I | |
139 >start_frame</I | |
140 ></TT | |
141 > is the frame offset, from the beginning of the <TT | |
142 CLASS="PARAMETER" | |
143 ><I | |
144 >start_track</I | |
145 ></TT | |
146 >, at which to start. <TT | |
147 CLASS="PARAMETER" | |
148 ><I | |
149 >nframes</I | |
150 ></TT | |
151 > is the frame offset, from the beginning of the last track (<TT | |
152 CLASS="PARAMETER" | |
153 ><I | |
154 >start_track</I | |
155 ></TT | |
156 >+<TT | |
157 CLASS="PARAMETER" | |
158 ><I | |
159 >ntracks</I | |
160 ></TT | |
161 >), at which to end playing.</P | |
162 ><P | |
163 ><TT | |
164 CLASS="FUNCTION" | |
165 >SDL_CDPlayTracks</TT | |
166 > should only be called after calling | |
167 <A | |
168 HREF="sdlcdstatus.html" | |
169 ><TT | |
170 CLASS="FUNCTION" | |
171 >SDL_CDStatus</TT | |
172 ></A | |
173 > | |
174 to get track information about the CD.</P | |
175 ><DIV | |
176 CLASS="NOTE" | |
177 ><BLOCKQUOTE | |
178 CLASS="NOTE" | |
179 ><P | |
180 ><B | |
181 >Note: </B | |
182 >Data tracks are ignored.</P | |
183 ></BLOCKQUOTE | |
184 ></DIV | |
185 ></DIV | |
186 ><DIV | |
187 CLASS="REFSECT1" | |
188 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
189 NAME="AEN7015" |
0 | 190 ></A |
191 ><H2 | |
192 >Return Value</H2 | |
193 ><P | |
194 >Returns <SPAN | |
195 CLASS="RETURNVALUE" | |
196 >0</SPAN | |
197 >, or <SPAN | |
198 CLASS="RETURNVALUE" | |
199 >-1</SPAN | |
200 > | |
201 if there was an error.</P | |
202 ></DIV | |
203 ><DIV | |
204 CLASS="REFSECT1" | |
205 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
206 NAME="AEN7020" |
0 | 207 ></A |
208 ><H2 | |
209 >Examples</H2 | |
210 ><P | |
211 ><PRE | |
212 CLASS="PROGRAMLISTING" | |
213 >/* assuming cdrom is a previously opened device */ | |
214 /* Play the entire CD */ | |
215 if(CD_INDRIVE(SDL_CDStatus(cdrom))) | |
216 SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); | |
217 | |
218 /* Play the first track */ | |
219 if(CD_INDRIVE(SDL_CDStatus(cdrom))) | |
220 SDL_CDPlayTracks(cdrom, 0, 0, 1, 0); | |
221 | |
222 /* Play first 15 seconds of the 2nd track */ | |
223 if(CD_INDRIVE(SDL_CDStatus(cdrom))) | |
224 SDL_CDPlayTracks(cdrom, 1, 0, 0, CD_FPS*15);</PRE | |
225 > | |
226 </P | |
227 ></DIV | |
228 ><DIV | |
229 CLASS="REFSECT1" | |
230 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
231 NAME="AEN7024" |
0 | 232 ></A |
233 ><H2 | |
234 >See Also</H2 | |
235 ><P | |
236 ><A | |
237 HREF="sdlcdplay.html" | |
238 ><TT | |
239 CLASS="FUNCTION" | |
240 >SDL_CDPlay</TT | |
241 ></A | |
242 >, | |
243 <A | |
244 HREF="sdlcdstatus.html" | |
245 ><TT | |
246 CLASS="FUNCTION" | |
247 >SDL_CDStatus</TT | |
248 ></A | |
249 >, | |
250 <A | |
251 HREF="sdlcd.html" | |
252 ><TT | |
253 CLASS="FUNCTION" | |
254 >SDL_CD</TT | |
255 ></A | |
256 ></P | |
257 ></DIV | |
258 ><DIV | |
259 CLASS="NAVFOOTER" | |
260 ><HR | |
261 ALIGN="LEFT" | |
262 WIDTH="100%"><TABLE | |
263 WIDTH="100%" | |
264 BORDER="0" | |
265 CELLPADDING="0" | |
266 CELLSPACING="0" | |
267 ><TR | |
268 ><TD | |
269 WIDTH="33%" | |
270 ALIGN="left" | |
271 VALIGN="top" | |
272 ><A | |
273 HREF="sdlcdplay.html" | |
274 >Prev</A | |
275 ></TD | |
276 ><TD | |
277 WIDTH="34%" | |
278 ALIGN="center" | |
279 VALIGN="top" | |
280 ><A | |
281 HREF="index.html" | |
282 >Home</A | |
283 ></TD | |
284 ><TD | |
285 WIDTH="33%" | |
286 ALIGN="right" | |
287 VALIGN="top" | |
288 ><A | |
289 HREF="sdlcdpause.html" | |
290 >Next</A | |
291 ></TD | |
292 ></TR | |
293 ><TR | |
294 ><TD | |
295 WIDTH="33%" | |
296 ALIGN="left" | |
297 VALIGN="top" | |
298 >SDL_CDPlay</TD | |
299 ><TD | |
300 WIDTH="34%" | |
301 ALIGN="center" | |
302 VALIGN="top" | |
303 ><A | |
304 HREF="cdrom.html" | |
305 >Up</A | |
306 ></TD | |
307 ><TD | |
308 WIDTH="33%" | |
309 ALIGN="right" | |
310 VALIGN="top" | |
311 >SDL_CDPause</TD | |
312 ></TR | |
313 ></TABLE | |
314 ></DIV | |
315 ></BODY | |
316 ></HTML | |
317 > |