Mercurial > sdl-ios-xcode
annotate docs/html/sdlpeepevents.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_PeepEvents</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="Event Functions." | |
14 HREF="eventfunctions.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_PumpEvents" | |
17 HREF="sdlpumpevents.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_PollEvent" | |
20 HREF="sdlpollevent.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="sdlpumpevents.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="sdlpollevent.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="SDLPEEPEVENTS" | |
71 >SDL_PeepEvents</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="AEN5037" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_PeepEvents -- Checks the event queue for messages and optionally returns them.</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="AEN5040" |
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="AEN5041" |
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_PeepEvents</B | |
105 ></CODE | |
106 >(SDL_Event *events, int numevents, SDL_eventaction action, Uint32 mask);</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="AEN5047" |
0 | 116 ></A |
117 ><H2 | |
118 >Description</H2 | |
119 ><P | |
120 >Checks the event queue for messages and optionally returns them.</P | |
121 ><P | |
122 >If <TT | |
123 CLASS="PARAMETER" | |
124 ><I | |
125 >action</I | |
126 ></TT | |
127 > is <TT | |
128 CLASS="LITERAL" | |
129 >SDL_ADDEVENT</TT | |
130 >, up to | |
131 <TT | |
132 CLASS="PARAMETER" | |
133 ><I | |
134 >numevents</I | |
135 ></TT | |
136 > events will be added to the back of the event | |
137 queue.</P | |
138 ><P | |
139 >If <TT | |
140 CLASS="PARAMETER" | |
141 ><I | |
142 >action</I | |
143 ></TT | |
144 > is <TT | |
145 CLASS="LITERAL" | |
146 >SDL_PEEKEVENT</TT | |
147 >, up to | |
148 <TT | |
149 CLASS="PARAMETER" | |
150 ><I | |
151 >numevents</I | |
152 ></TT | |
153 > events at the front of the event queue, | |
154 matching <A | |
155 HREF="sdlevent.html" | |
156 ><TT | |
157 CLASS="PARAMETER" | |
158 ><I | |
159 >mask</I | |
160 ></TT | |
161 ></A | |
162 >, | |
163 will be returned and will not be removed from the queue.</P | |
164 ><P | |
165 >If <TT | |
166 CLASS="PARAMETER" | |
167 ><I | |
168 >action</I | |
169 ></TT | |
170 > is <TT | |
171 CLASS="LITERAL" | |
172 >SDL_GETEVENT</TT | |
173 >, up to | |
174 <TT | |
175 CLASS="PARAMETER" | |
176 ><I | |
177 >numevents</I | |
178 ></TT | |
179 > events at the front of the event queue, | |
180 matching <A | |
181 HREF="sdlevent.html" | |
182 ><TT | |
183 CLASS="PARAMETER" | |
184 ><I | |
185 >mask</I | |
186 ></TT | |
187 ></A | |
188 >, | |
189 will be returned and will be removed from the queue.</P | |
190 ><P | |
191 >This function is thread-safe.</P | |
192 ></DIV | |
193 ><DIV | |
194 CLASS="REFSECT1" | |
195 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
196 NAME="AEN5067" |
0 | 197 ></A |
198 ><H2 | |
199 >Return Value</H2 | |
200 ><P | |
201 >This function returns the number of events actually stored, or | |
202 <SPAN | |
203 CLASS="RETURNVALUE" | |
204 >-1</SPAN | |
205 > if there was an error. </P | |
206 ></DIV | |
207 ><DIV | |
208 CLASS="REFSECT1" | |
209 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
210 NAME="AEN5071" |
0 | 211 ></A |
212 ><H2 | |
213 >See Also</H2 | |
214 ><P | |
215 ><A | |
216 HREF="sdlevent.html" | |
217 ><SPAN | |
218 CLASS="STRUCTNAME" | |
219 >SDL_Event</SPAN | |
220 ></A | |
221 >, | |
222 <A | |
223 HREF="sdlpollevent.html" | |
224 ><TT | |
225 CLASS="FUNCTION" | |
226 >SDL_PollEvent</TT | |
227 ></A | |
228 >, | |
229 <A | |
230 HREF="sdlpushevent.html" | |
231 ><TT | |
232 CLASS="FUNCTION" | |
233 >SDL_PushEvent</TT | |
234 ></A | |
235 ></P | |
236 ></DIV | |
237 ><DIV | |
238 CLASS="NAVFOOTER" | |
239 ><HR | |
240 ALIGN="LEFT" | |
241 WIDTH="100%"><TABLE | |
242 WIDTH="100%" | |
243 BORDER="0" | |
244 CELLPADDING="0" | |
245 CELLSPACING="0" | |
246 ><TR | |
247 ><TD | |
248 WIDTH="33%" | |
249 ALIGN="left" | |
250 VALIGN="top" | |
251 ><A | |
252 HREF="sdlpumpevents.html" | |
253 >Prev</A | |
254 ></TD | |
255 ><TD | |
256 WIDTH="34%" | |
257 ALIGN="center" | |
258 VALIGN="top" | |
259 ><A | |
260 HREF="index.html" | |
261 >Home</A | |
262 ></TD | |
263 ><TD | |
264 WIDTH="33%" | |
265 ALIGN="right" | |
266 VALIGN="top" | |
267 ><A | |
268 HREF="sdlpollevent.html" | |
269 >Next</A | |
270 ></TD | |
271 ></TR | |
272 ><TR | |
273 ><TD | |
274 WIDTH="33%" | |
275 ALIGN="left" | |
276 VALIGN="top" | |
277 >SDL_PumpEvents</TD | |
278 ><TD | |
279 WIDTH="34%" | |
280 ALIGN="center" | |
281 VALIGN="top" | |
282 ><A | |
283 HREF="eventfunctions.html" | |
284 >Up</A | |
285 ></TD | |
286 ><TD | |
287 WIDTH="33%" | |
288 ALIGN="right" | |
289 VALIGN="top" | |
290 >SDL_PollEvent</TD | |
291 ></TR | |
292 ></TABLE | |
293 ></DIV | |
294 ></BODY | |
295 ></HTML | |
296 > |