Mercurial > sdl-ios-xcode
annotate docs/html/sdlcdstatus.html @ 765:4c2ba6161939
Editors Note: The original patch was modified to use SDL_Delay() instead of
nanosleep because nanosleep may not be portable to all systems
using SDL with the ALSA backend. This may be a moot point with
the switch to blocking writes anyway...
Date: Sat, 27 Dec 2003 21:47:36 +0100
From: Michel Daenzer
To: Debian Bug Tracking System
Subject: [SDL] Bug#225252: [PATCH] ALSA fixes
Package: libsdl1.2debian-all
Version: 1.2.6-2
Severity: normal
Tags: patch
For SDL 1.2.6, the ALSA backend was changed to call snd_pcm_open() with
SND_PCM_NONBLOCK. That's a good idea per se, however, it causes high CPU
usage, interrupted sound and stuttering in some games here. Taking a nanosleep
whenever snd_pcm_writei() returns -EAGAIN fixes this, but I think it's more
efficient to use blocking mode for the actual sound playback. Feedback from the
SDL and ALSA lists appreciated.
The patch also fixes the default ALSA device to be used.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 04 Jan 2004 15:40:50 +0000 |
parents | e5bc29de3f0a |
children | 355632dca928 |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_CDStatus</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="CD-ROM" | |
14 HREF="cdrom.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_CDOpen" | |
17 HREF="sdlcdopen.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_CDPlay" | |
20 HREF="sdlcdplay.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="sdlcdopen.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="sdlcdplay.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="SDLCDSTATUS" | |
71 >SDL_CDStatus</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="AEN6920" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_CDStatus -- Returns the current status of the given drive.</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="AEN6923" |
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="AEN6924" |
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 >CDstatus <B | |
103 CLASS="FSFUNC" | |
104 >SDL_CDStatus</B | |
105 ></CODE | |
106 >(SDL_CD *cdrom);</CODE | |
107 ></P | |
108 ><PRE | |
109 CLASS="FUNCSYNOPSISINFO" | |
110 >/* Given a status, returns true if there's a disk in the drive */ | |
111 #define CD_INDRIVE(status) ((int)status > 0)</PRE | |
112 ><P | |
113 ></P | |
114 ></DIV | |
115 ></DIV | |
116 ><DIV | |
117 CLASS="REFSECT1" | |
118 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
119 NAME="AEN6931" |
0 | 120 ></A |
121 ><H2 | |
122 >Description</H2 | |
123 ><P | |
124 >This function returns the current status of the given drive. Status is described like so: | |
125 <PRE | |
126 CLASS="PROGRAMLISTING" | |
127 >typedef enum { | |
128 CD_TRAYEMPTY, | |
129 CD_STOPPED, | |
130 CD_PLAYING, | |
131 CD_PAUSED, | |
132 CD_ERROR = -1 | |
133 } CDstatus;</PRE | |
134 ></P | |
135 ><P | |
136 >If the drive has a CD in it, the table of contents of the CD and current | |
137 play position of the CD will be stored in the SDL_CD structure.</P | |
138 ><P | |
139 >The macro <TT | |
140 CLASS="LITERAL" | |
141 >CD_INDRIVE</TT | |
142 > is provided for convenience, | |
143 and given a status returns true if there's a disk in the drive.</P | |
144 ><DIV | |
145 CLASS="NOTE" | |
146 ><BLOCKQUOTE | |
147 CLASS="NOTE" | |
148 ><P | |
149 ><B | |
150 >Note: </B | |
151 ><TT | |
152 CLASS="FUNCTION" | |
153 >SDL_CDStatus</TT | |
154 > also updates the <A | |
155 HREF="sdlcd.html" | |
156 ><SPAN | |
157 CLASS="STRUCTNAME" | |
158 >SDL_CD</SPAN | |
159 ></A | |
160 > structure passed to it.</P | |
161 ></BLOCKQUOTE | |
162 ></DIV | |
163 ></DIV | |
164 ><DIV | |
165 CLASS="REFSECT1" | |
166 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
167 NAME="AEN6943" |
0 | 168 ></A |
169 ><H2 | |
170 >Example</H2 | |
171 ><PRE | |
172 CLASS="PROGRAMLISTING" | |
173 >int playTrack(int track) | |
174 { | |
175 int playing = 0; | |
176 | |
177 if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) { | |
178 /* clamp to the actual number of tracks on the CD */ | |
179 if (track >= cdrom->numtracks) { | |
180 track = cdrom->numtracks-1; | |
181 } | |
182 | |
183 if ( SDL_CDPlayTracks(cdrom, track, 0, 1, 0) == 0 ) { | |
184 playing = 1; | |
185 } | |
186 } | |
187 return playing; | |
188 }</PRE | |
189 ></DIV | |
190 ><DIV | |
191 CLASS="REFSECT1" | |
192 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
193 NAME="AEN6946" |
0 | 194 ></A |
195 ><H2 | |
196 >See Also</H2 | |
197 ><P | |
198 ><A | |
199 HREF="sdlcd.html" | |
200 ><TT | |
201 CLASS="FUNCTION" | |
202 >SDL_CD</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="sdlcdopen.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="sdlcdplay.html" | |
238 >Next</A | |
239 ></TD | |
240 ></TR | |
241 ><TR | |
242 ><TD | |
243 WIDTH="33%" | |
244 ALIGN="left" | |
245 VALIGN="top" | |
246 >SDL_CDOpen</TD | |
247 ><TD | |
248 WIDTH="34%" | |
249 ALIGN="center" | |
250 VALIGN="top" | |
251 ><A | |
252 HREF="cdrom.html" | |
253 >Up</A | |
254 ></TD | |
255 ><TD | |
256 WIDTH="33%" | |
257 ALIGN="right" | |
258 VALIGN="top" | |
259 >SDL_CDPlay</TD | |
260 ></TR | |
261 ></TABLE | |
262 ></DIV | |
263 ></BODY | |
264 ></HTML | |
265 > |