Mercurial > sdl-ios-xcode
annotate docs/html/sdlpalette.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_Palette</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="Video" | |
14 HREF="video.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_Color" | |
17 HREF="sdlcolor.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_PixelFormat" | |
20 HREF="sdlpixelformat.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="sdlcolor.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="sdlpixelformat.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="SDLPALETTE" | |
71 >SDL_Palette</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="AEN2745" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_Palette -- Color palette for 8-bit pixel formats</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="AEN2748" |
0 | 85 ></A |
86 ><H2 | |
87 >Structure Definition</H2 | |
88 ><PRE | |
89 CLASS="PROGRAMLISTING" | |
90 >typedef struct{ | |
91 int ncolors; | |
92 SDL_Color *colors; | |
93 } SDL_Palette;</PRE | |
94 ></DIV | |
95 ><DIV | |
96 CLASS="REFSECT1" | |
97 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
98 NAME="AEN2751" |
0 | 99 ></A |
100 ><H2 | |
101 >Structure Data</H2 | |
102 ><DIV | |
103 CLASS="INFORMALTABLE" | |
104 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
105 NAME="AEN2753" |
0 | 106 ></A |
107 ><P | |
108 ></P | |
109 ><TABLE | |
110 BORDER="0" | |
111 CLASS="CALSTABLE" | |
112 ><TBODY | |
113 ><TR | |
114 ><TD | |
115 ALIGN="LEFT" | |
116 VALIGN="TOP" | |
117 ><TT | |
118 CLASS="STRUCTFIELD" | |
119 ><I | |
120 >ncolors</I | |
121 ></TT | |
122 ></TD | |
123 ><TD | |
124 ALIGN="LEFT" | |
125 VALIGN="TOP" | |
126 >Number of colors used in this palette</TD | |
127 ></TR | |
128 ><TR | |
129 ><TD | |
130 ALIGN="LEFT" | |
131 VALIGN="TOP" | |
132 ><TT | |
133 CLASS="STRUCTFIELD" | |
134 ><I | |
135 >colors</I | |
136 ></TT | |
137 ></TD | |
138 ><TD | |
139 ALIGN="LEFT" | |
140 VALIGN="TOP" | |
141 >Pointer to <A | |
142 HREF="sdlcolor.html" | |
143 ><SPAN | |
144 CLASS="STRUCTNAME" | |
145 >SDL_Color</SPAN | |
146 ></A | |
147 > structures that make up the palette.</TD | |
148 ></TR | |
149 ></TBODY | |
150 ></TABLE | |
151 ><P | |
152 ></P | |
153 ></DIV | |
154 ></DIV | |
155 ><DIV | |
156 CLASS="REFSECT1" | |
157 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
158 NAME="AEN2766" |
0 | 159 ></A |
160 ><H2 | |
161 >Description</H2 | |
162 ><P | |
163 >Each pixel in an 8-bit surface is an index into the <TT | |
164 CLASS="STRUCTFIELD" | |
165 ><I | |
166 >colors</I | |
167 ></TT | |
168 > field of the <SPAN | |
169 CLASS="STRUCTNAME" | |
170 >SDL_Palette</SPAN | |
171 > structure store in <A | |
172 HREF="sdlpixelformat.html" | |
173 ><SPAN | |
174 CLASS="STRUCTNAME" | |
175 >SDL_PixelFormat</SPAN | |
176 ></A | |
177 >. A <SPAN | |
178 CLASS="STRUCTNAME" | |
179 >SDL_Palette</SPAN | |
180 > should never need to be created manually. It is automatically created when SDL allocates a <SPAN | |
181 CLASS="STRUCTNAME" | |
182 >SDL_PixelFormat</SPAN | |
183 > for a surface. The colors values of a <A | |
184 HREF="sdlsurface.html" | |
185 ><SPAN | |
186 CLASS="STRUCTNAME" | |
187 >SDL_Surface</SPAN | |
188 ></A | |
189 >s palette can be set with the <A | |
190 HREF="sdlsetcolors.html" | |
191 ><TT | |
192 CLASS="FUNCTION" | |
193 >SDL_SetColors</TT | |
194 ></A | |
195 >.</P | |
196 ></DIV | |
197 ><DIV | |
198 CLASS="REFSECT1" | |
199 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
200 NAME="AEN2779" |
0 | 201 ></A |
202 ><H2 | |
203 >See Also</H2 | |
204 ><P | |
205 ><A | |
206 HREF="sdlcolor.html" | |
207 ><SPAN | |
208 CLASS="STRUCTNAME" | |
209 >SDL_Color</SPAN | |
210 ></A | |
211 >, | |
212 <A | |
213 HREF="sdlsurface.html" | |
214 ><SPAN | |
215 CLASS="STRUCTNAME" | |
216 >SDL_Surface</SPAN | |
217 ></A | |
218 >, | |
219 <A | |
220 HREF="sdlsetcolors.html" | |
221 ><TT | |
222 CLASS="FUNCTION" | |
223 >SDL_SetColors</TT | |
224 ></A | |
225 > | |
226 <A | |
227 HREF="sdlsetpalette.html" | |
228 ><TT | |
229 CLASS="FUNCTION" | |
230 >SDL_SetPalette</TT | |
231 ></A | |
232 ></P | |
233 ></DIV | |
234 ><DIV | |
235 CLASS="NAVFOOTER" | |
236 ><HR | |
237 ALIGN="LEFT" | |
238 WIDTH="100%"><TABLE | |
239 WIDTH="100%" | |
240 BORDER="0" | |
241 CELLPADDING="0" | |
242 CELLSPACING="0" | |
243 ><TR | |
244 ><TD | |
245 WIDTH="33%" | |
246 ALIGN="left" | |
247 VALIGN="top" | |
248 ><A | |
249 HREF="sdlcolor.html" | |
250 >Prev</A | |
251 ></TD | |
252 ><TD | |
253 WIDTH="34%" | |
254 ALIGN="center" | |
255 VALIGN="top" | |
256 ><A | |
257 HREF="index.html" | |
258 >Home</A | |
259 ></TD | |
260 ><TD | |
261 WIDTH="33%" | |
262 ALIGN="right" | |
263 VALIGN="top" | |
264 ><A | |
265 HREF="sdlpixelformat.html" | |
266 >Next</A | |
267 ></TD | |
268 ></TR | |
269 ><TR | |
270 ><TD | |
271 WIDTH="33%" | |
272 ALIGN="left" | |
273 VALIGN="top" | |
274 >SDL_Color</TD | |
275 ><TD | |
276 WIDTH="34%" | |
277 ALIGN="center" | |
278 VALIGN="top" | |
279 ><A | |
280 HREF="video.html" | |
281 >Up</A | |
282 ></TD | |
283 ><TD | |
284 WIDTH="33%" | |
285 ALIGN="right" | |
286 VALIGN="top" | |
287 >SDL_PixelFormat</TD | |
288 ></TR | |
289 ></TABLE | |
290 ></DIV | |
291 ></BODY | |
292 ></HTML | |
293 > |