Mercurial > sdl-ios-xcode
annotate docs/html/sdluserevent.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_UserEvent</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="SDL Event Structures." | |
14 HREF="eventstructures.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_SysWMEvent" | |
17 HREF="sdlsyswmevent.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_QuitEvent" | |
20 HREF="sdlquitevent.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="sdlsyswmevent.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="sdlquitevent.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="SDLUSEREVENT" | |
71 >SDL_UserEvent</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="AEN4181" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_UserEvent -- A user-defined event type</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="AEN4184" |
0 | 85 ></A |
86 ><H2 | |
87 >Structure Definition</H2 | |
88 ><PRE | |
89 CLASS="PROGRAMLISTING" | |
90 >typedef struct{ | |
91 Uint8 type; | |
92 int code; | |
93 void *data1; | |
94 void *data2; | |
95 } SDL_UserEvent;</PRE | |
96 ></DIV | |
97 ><DIV | |
98 CLASS="REFSECT1" | |
99 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
100 NAME="AEN4187" |
0 | 101 ></A |
102 ><H2 | |
103 >Structure Data</H2 | |
104 ><DIV | |
105 CLASS="INFORMALTABLE" | |
106 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
107 NAME="AEN4189" |
0 | 108 ></A |
109 ><P | |
110 ></P | |
111 ><TABLE | |
112 BORDER="0" | |
113 CLASS="CALSTABLE" | |
114 ><TBODY | |
115 ><TR | |
116 ><TD | |
117 ALIGN="LEFT" | |
118 VALIGN="TOP" | |
119 ><TT | |
120 CLASS="STRUCTFIELD" | |
121 ><I | |
122 >type</I | |
123 ></TT | |
124 ></TD | |
125 ><TD | |
126 ALIGN="LEFT" | |
127 VALIGN="TOP" | |
128 ><TT | |
129 CLASS="LITERAL" | |
130 >SDL_USEREVENT</TT | |
131 > through to <TT | |
132 CLASS="LITERAL" | |
133 >SDL_NUMEVENTS-1</TT | |
134 ></TD | |
135 ></TR | |
136 ><TR | |
137 ><TD | |
138 ALIGN="LEFT" | |
139 VALIGN="TOP" | |
140 ><TT | |
141 CLASS="STRUCTFIELD" | |
142 ><I | |
143 >code</I | |
144 ></TT | |
145 ></TD | |
146 ><TD | |
147 ALIGN="LEFT" | |
148 VALIGN="TOP" | |
149 >User defined event code</TD | |
150 ></TR | |
151 ><TR | |
152 ><TD | |
153 ALIGN="LEFT" | |
154 VALIGN="TOP" | |
155 ><TT | |
156 CLASS="STRUCTFIELD" | |
157 ><I | |
158 >data1</I | |
159 ></TT | |
160 ></TD | |
161 ><TD | |
162 ALIGN="LEFT" | |
163 VALIGN="TOP" | |
164 >User defined data pointer</TD | |
165 ></TR | |
166 ><TR | |
167 ><TD | |
168 ALIGN="LEFT" | |
169 VALIGN="TOP" | |
170 ><TT | |
171 CLASS="STRUCTFIELD" | |
172 ><I | |
173 >data2</I | |
174 ></TT | |
175 ></TD | |
176 ><TD | |
177 ALIGN="LEFT" | |
178 VALIGN="TOP" | |
179 >User defined data pointer</TD | |
180 ></TR | |
181 ></TBODY | |
182 ></TABLE | |
183 ><P | |
184 ></P | |
185 ></DIV | |
186 ></DIV | |
187 ><DIV | |
188 CLASS="REFSECT1" | |
189 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
190 NAME="AEN4210" |
0 | 191 ></A |
192 ><H2 | |
193 >Description</H2 | |
194 ><P | |
195 ><SPAN | |
196 CLASS="STRUCTNAME" | |
197 >SDL_UserEvent</SPAN | |
198 > is in the <TT | |
199 CLASS="STRUCTFIELD" | |
200 ><I | |
201 >user</I | |
202 ></TT | |
203 > member of the structure <A | |
204 HREF="sdlevent.html" | |
205 ><SPAN | |
206 CLASS="STRUCTNAME" | |
207 >SDL_Event</SPAN | |
208 ></A | |
209 >. This event is unique, it is never created by SDL but only by the user. The event can be pushed onto the event queue using <A | |
210 HREF="sdlpushevent.html" | |
211 ><TT | |
212 CLASS="FUNCTION" | |
213 >SDL_PushEvent</TT | |
214 ></A | |
215 >. The contents of the structure members or completely up to the programmer, the only requirement is that <TT | |
216 CLASS="STRUCTFIELD" | |
217 ><I | |
218 >type</I | |
219 ></TT | |
220 > is a value from <TT | |
221 CLASS="LITERAL" | |
222 >SDL_USEREVENT</TT | |
223 > to <TT | |
224 CLASS="LITERAL" | |
225 >SDL_NUMEVENTS-1</TT | |
226 > (inclusive).</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="AEN4222" |
0 | 232 ></A |
233 ><H2 | |
234 >Examples</H2 | |
235 ><P | |
236 ><PRE | |
237 CLASS="PROGRAMLISTING" | |
238 >SDL_Event event; | |
239 | |
240 event.type = SDL_USEREVENT; | |
241 event.user.code = my_event_code; | |
242 event.user.data1 = significant_data; | |
243 event.user.data2 = 0; | |
244 SDL_PushEvent(&event);</PRE | |
245 ></P | |
246 ></DIV | |
247 ><DIV | |
248 CLASS="REFSECT1" | |
249 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
250 NAME="AEN4226" |
0 | 251 ></A |
252 ><H2 | |
253 >See Also</H2 | |
254 ><P | |
255 ><A | |
256 HREF="sdlevent.html" | |
257 ><SPAN | |
258 CLASS="STRUCTNAME" | |
259 >SDL_Event</SPAN | |
260 ></A | |
261 >, | |
262 <A | |
263 HREF="sdlpushevent.html" | |
264 ><TT | |
265 CLASS="FUNCTION" | |
266 >SDL_PushEvent</TT | |
267 ></A | |
268 ></P | |
269 ></DIV | |
270 ><DIV | |
271 CLASS="NAVFOOTER" | |
272 ><HR | |
273 ALIGN="LEFT" | |
274 WIDTH="100%"><TABLE | |
275 WIDTH="100%" | |
276 BORDER="0" | |
277 CELLPADDING="0" | |
278 CELLSPACING="0" | |
279 ><TR | |
280 ><TD | |
281 WIDTH="33%" | |
282 ALIGN="left" | |
283 VALIGN="top" | |
284 ><A | |
285 HREF="sdlsyswmevent.html" | |
286 >Prev</A | |
287 ></TD | |
288 ><TD | |
289 WIDTH="34%" | |
290 ALIGN="center" | |
291 VALIGN="top" | |
292 ><A | |
293 HREF="index.html" | |
294 >Home</A | |
295 ></TD | |
296 ><TD | |
297 WIDTH="33%" | |
298 ALIGN="right" | |
299 VALIGN="top" | |
300 ><A | |
301 HREF="sdlquitevent.html" | |
302 >Next</A | |
303 ></TD | |
304 ></TR | |
305 ><TR | |
306 ><TD | |
307 WIDTH="33%" | |
308 ALIGN="left" | |
309 VALIGN="top" | |
310 >SDL_SysWMEvent</TD | |
311 ><TD | |
312 WIDTH="34%" | |
313 ALIGN="center" | |
314 VALIGN="top" | |
315 ><A | |
316 HREF="eventstructures.html" | |
317 >Up</A | |
318 ></TD | |
319 ><TD | |
320 WIDTH="33%" | |
321 ALIGN="right" | |
322 VALIGN="top" | |
323 >SDL_QuitEvent</TD | |
324 ></TR | |
325 ></TABLE | |
326 ></DIV | |
327 ></BODY | |
328 ></HTML | |
329 > |