Mercurial > sdl-ios-xcode
annotate docs/html/sdlsemvalue.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_SemValue</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="Multi-threaded Programming" | |
14 HREF="thread.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_SemPost" | |
17 HREF="sdlsempost.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_CreateCond" | |
20 HREF="sdlcreatecond.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="sdlsempost.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="sdlcreatecond.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="SDLSEMVALUE" | |
71 >SDL_SemValue</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="AEN7830" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_SemValue -- Return the current value of a semaphore.</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="AEN7833" |
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="AEN7834" |
0 | 92 ></A |
93 ><P | |
94 ></P | |
95 ><PRE | |
96 CLASS="FUNCSYNOPSISINFO" | |
97 >#include "SDL.h" | |
98 #include "SDL/SDL_thread.h"</PRE | |
99 ><P | |
100 ><CODE | |
101 ><CODE | |
102 CLASS="FUNCDEF" | |
103 >Uint32 <B | |
104 CLASS="FSFUNC" | |
105 >SDL_SemValue</B | |
106 ></CODE | |
107 >(SDL_sem *sem);</CODE | |
108 ></P | |
109 ><P | |
110 ></P | |
111 ></DIV | |
112 ></DIV | |
113 ><DIV | |
114 CLASS="REFSECT1" | |
115 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
116 NAME="AEN7840" |
0 | 117 ></A |
118 ><H2 | |
119 >Description</H2 | |
120 ><P | |
121 ><TT | |
122 CLASS="FUNCTION" | |
123 >SDL_SemValue()</TT | |
124 > returns the current semaphore value from | |
125 the semaphore pointed to by <TT | |
126 CLASS="PARAMETER" | |
127 ><I | |
128 >sem</I | |
129 ></TT | |
130 >.</P | |
131 ></DIV | |
132 ><DIV | |
133 CLASS="REFSECT1" | |
134 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
135 NAME="AEN7845" |
0 | 136 ></A |
137 ><H2 | |
138 >Return Value</H2 | |
139 ><P | |
140 >Returns current value of the semaphore.</P | |
141 ></DIV | |
142 ><DIV | |
143 CLASS="REFSECT1" | |
144 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
145 NAME="AEN7848" |
0 | 146 ></A |
147 ><H2 | |
148 >Examples</H2 | |
149 ><P | |
150 ><PRE | |
151 CLASS="PROGRAMLISTING" | |
152 > sem_value = SDL_SemValue(my_sem);</PRE | |
153 ></P | |
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="AEN7852" |
0 | 159 ></A |
160 ><H2 | |
161 >See Also</H2 | |
162 ><P | |
163 ><A | |
164 HREF="sdlcreatesemaphore.html" | |
165 ><TT | |
166 CLASS="FUNCTION" | |
167 >SDL_CreateSemaphore</TT | |
168 ></A | |
169 >, | |
170 <A | |
171 HREF="sdldestroysemaphore.html" | |
172 ><TT | |
173 CLASS="FUNCTION" | |
174 >SDL_DestroySemaphore</TT | |
175 ></A | |
176 >, | |
177 <A | |
178 HREF="sdlsemwait.html" | |
179 ><TT | |
180 CLASS="FUNCTION" | |
181 >SDL_SemWait</TT | |
182 ></A | |
183 >, | |
184 <A | |
185 HREF="sdlsemtrywait.html" | |
186 ><TT | |
187 CLASS="FUNCTION" | |
188 >SDL_SemTryWait</TT | |
189 ></A | |
190 >, | |
191 <A | |
192 HREF="sdlsemwaittimeout.html" | |
193 ><TT | |
194 CLASS="FUNCTION" | |
195 >SDL_SemWaitTimeout</TT | |
196 ></A | |
197 >, | |
198 <A | |
199 HREF="sdlsempost.html" | |
200 ><TT | |
201 CLASS="FUNCTION" | |
202 >SDL_SemPost</TT | |
203 ></A | |
204 ></P | |
205 ></DIV | |
206 ><DIV | |
207 CLASS="NAVFOOTER" | |
208 ><HR | |
209 ALIGN="LEFT" | |
210 WIDTH="100%"><TABLE | |
211 WIDTH="100%" | |
212 BORDER="0" | |
213 CELLPADDING="0" | |
214 CELLSPACING="0" | |
215 ><TR | |
216 ><TD | |
217 WIDTH="33%" | |
218 ALIGN="left" | |
219 VALIGN="top" | |
220 ><A | |
221 HREF="sdlsempost.html" | |
222 >Prev</A | |
223 ></TD | |
224 ><TD | |
225 WIDTH="34%" | |
226 ALIGN="center" | |
227 VALIGN="top" | |
228 ><A | |
229 HREF="index.html" | |
230 >Home</A | |
231 ></TD | |
232 ><TD | |
233 WIDTH="33%" | |
234 ALIGN="right" | |
235 VALIGN="top" | |
236 ><A | |
237 HREF="sdlcreatecond.html" | |
238 >Next</A | |
239 ></TD | |
240 ></TR | |
241 ><TR | |
242 ><TD | |
243 WIDTH="33%" | |
244 ALIGN="left" | |
245 VALIGN="top" | |
246 >SDL_SemPost</TD | |
247 ><TD | |
248 WIDTH="34%" | |
249 ALIGN="center" | |
250 VALIGN="top" | |
251 ><A | |
252 HREF="thread.html" | |
253 >Up</A | |
254 ></TD | |
255 ><TD | |
256 WIDTH="33%" | |
257 ALIGN="right" | |
258 VALIGN="top" | |
259 >SDL_CreateCond</TD | |
260 ></TR | |
261 ></TABLE | |
262 ></DIV | |
263 ></BODY | |
264 ></HTML | |
265 > |