Mercurial > sdl-ios-xcode
annotate docs/html/sdlinitsubsystem.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 | 55f1f1b3e27d |
children | 355632dca928 |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_InitSubSystem</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="General" | |
14 HREF="general.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_Init" | |
17 HREF="sdlinit.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_QuitSubSystem" | |
20 HREF="sdlquitsubsystem.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="sdlinit.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="sdlquitsubsystem.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="SDLINITSUBSYSTEM" | |
71 >SDL_InitSubSystem</A | |
72 ></H1 | |
73 ><DIV | |
74 CLASS="REFNAMEDIV" | |
75 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
76 NAME="AEN510" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_InitSubSystem -- Initialize subsystems</DIV | |
81 ><DIV | |
82 CLASS="REFSYNOPSISDIV" | |
83 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
84 NAME="AEN513" |
0 | 85 ></A |
86 ><H2 | |
87 >Synopsis</H2 | |
88 ><DIV | |
89 CLASS="FUNCSYNOPSIS" | |
90 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
91 NAME="AEN514" |
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_InitSubSystem</B | |
105 ></CODE | |
106 >(Uint32 flags);</CODE | |
107 ></P | |
108 ><P | |
109 ></P | |
110 ></DIV | |
111 ></DIV | |
112 ><DIV | |
113 CLASS="REFSECT1" | |
114 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
115 NAME="AEN520" |
0 | 116 ></A |
117 ><H2 | |
118 >Description</H2 | |
119 ><P | |
120 >After SDL has been initialized with <A | |
121 HREF="sdlinit.html" | |
122 ><TT | |
123 CLASS="FUNCTION" | |
124 >SDL_Init</TT | |
125 ></A | |
126 > you may initialize uninitialized subsystems with <TT | |
127 CLASS="FUNCTION" | |
128 >SDL_InitSubSystem</TT | |
129 >. The <TT | |
130 CLASS="PARAMETER" | |
131 ><I | |
132 >flags</I | |
133 ></TT | |
134 > parameter is the same as that used in <A | |
135 HREF="sdlinit.html" | |
136 ><TT | |
137 CLASS="FUNCTION" | |
138 >SDL_Init</TT | |
139 ></A | |
140 >.</P | |
141 ></DIV | |
142 ><DIV | |
143 CLASS="REFSECT1" | |
144 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
145 NAME="AEN529" |
0 | 146 ></A |
147 ><H2 | |
148 >Examples</H2 | |
149 ><PRE | |
150 CLASS="PROGRAMLISTING" | |
151 >/* Seperating Joystick and Video initialization. */ | |
152 SDL_Init(SDL_INIT_VIDEO); | |
153 . | |
154 . | |
155 SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF|SDL_FULLSCREEN); | |
156 . | |
157 /* Do Some Video stuff */ | |
158 . | |
159 . | |
160 /* Initialize the joystick subsystem */ | |
161 SDL_InitSubSystem(SDL_INIT_JOYSTICK); | |
162 | |
163 /* Do some stuff with video and joystick */ | |
164 . | |
165 . | |
166 . | |
167 /* Shut them both down */ | |
168 SDL_Quit();</PRE | |
169 ></DIV | |
170 ><DIV | |
171 CLASS="REFSECT1" | |
172 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
173 NAME="AEN532" |
0 | 174 ></A |
175 ><H2 | |
176 >Return Value</H2 | |
177 ><P | |
178 >Returns <SPAN | |
179 CLASS="RETURNVALUE" | |
180 >-1</SPAN | |
181 > on an error or <SPAN | |
182 CLASS="RETURNVALUE" | |
183 >0</SPAN | |
184 > on success.</P | |
185 ></DIV | |
186 ><DIV | |
187 CLASS="REFSECT1" | |
188 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
189 NAME="AEN537" |
0 | 190 ></A |
191 ><H2 | |
192 >See Also</H2 | |
193 ><P | |
194 ><A | |
195 HREF="sdlinit.html" | |
196 ><TT | |
197 CLASS="FUNCTION" | |
198 >SDL_Init</TT | |
199 ></A | |
200 >, | |
201 <A | |
202 HREF="sdlquit.html" | |
203 ><TT | |
204 CLASS="FUNCTION" | |
205 >SDL_Quit</TT | |
206 ></A | |
207 >, | |
208 <A | |
209 HREF="sdlquitsubsystem.html" | |
210 ><TT | |
211 CLASS="FUNCTION" | |
212 >SDL_QuitSubSystem</TT | |
213 ></A | |
214 ></P | |
215 ></DIV | |
216 ><DIV | |
217 CLASS="NAVFOOTER" | |
218 ><HR | |
219 ALIGN="LEFT" | |
220 WIDTH="100%"><TABLE | |
221 WIDTH="100%" | |
222 BORDER="0" | |
223 CELLPADDING="0" | |
224 CELLSPACING="0" | |
225 ><TR | |
226 ><TD | |
227 WIDTH="33%" | |
228 ALIGN="left" | |
229 VALIGN="top" | |
230 ><A | |
231 HREF="sdlinit.html" | |
232 >Prev</A | |
233 ></TD | |
234 ><TD | |
235 WIDTH="34%" | |
236 ALIGN="center" | |
237 VALIGN="top" | |
238 ><A | |
239 HREF="index.html" | |
240 >Home</A | |
241 ></TD | |
242 ><TD | |
243 WIDTH="33%" | |
244 ALIGN="right" | |
245 VALIGN="top" | |
246 ><A | |
247 HREF="sdlquitsubsystem.html" | |
248 >Next</A | |
249 ></TD | |
250 ></TR | |
251 ><TR | |
252 ><TD | |
253 WIDTH="33%" | |
254 ALIGN="left" | |
255 VALIGN="top" | |
256 >SDL_Init</TD | |
257 ><TD | |
258 WIDTH="34%" | |
259 ALIGN="center" | |
260 VALIGN="top" | |
261 ><A | |
262 HREF="general.html" | |
263 >Up</A | |
264 ></TD | |
265 ><TD | |
266 WIDTH="33%" | |
267 ALIGN="right" | |
268 VALIGN="top" | |
269 >SDL_QuitSubSystem</TD | |
270 ></TR | |
271 ></TABLE | |
272 ></DIV | |
273 ></BODY | |
274 ></HTML | |
275 > |