Mercurial > sdl-ios-xcode
annotate docs/html/sdlseteventfilter.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_SetEventFilter</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="Event Functions." | |
14 HREF="eventfunctions.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_PushEvent" | |
17 HREF="sdlpushevent.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_GetEventFilter" | |
20 HREF="sdlgeteventfilter.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="sdlpushevent.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="sdlgeteventfilter.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="SDLSETEVENTFILTER" | |
71 >SDL_SetEventFilter</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="AEN5187" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_SetEventFilter -- Sets up a filter to process all events before they are posted | |
81 to the event queue.</DIV | |
82 ><DIV | |
83 CLASS="REFSYNOPSISDIV" | |
84 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
85 NAME="AEN5190" |
0 | 86 ></A |
87 ><H2 | |
88 >Synopsis</H2 | |
89 ><DIV | |
90 CLASS="FUNCSYNOPSIS" | |
91 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
92 NAME="AEN5191" |
0 | 93 ></A |
94 ><P | |
95 ></P | |
96 ><PRE | |
97 CLASS="FUNCSYNOPSISINFO" | |
98 >#include "SDL.h"</PRE | |
99 ><P | |
100 ><CODE | |
101 ><CODE | |
102 CLASS="FUNCDEF" | |
103 >void <B | |
104 CLASS="FSFUNC" | |
105 >SDL_SetEventFilter</B | |
106 ></CODE | |
107 >(SDL_EventFilter filter);</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="AEN5197" |
0 | 117 ></A |
118 ><H2 | |
119 >Description</H2 | |
120 ><P | |
121 >This function sets up a filter to process all events before they are posted | |
122 to the event queue. This is a very powerful and flexible feature. The filter | |
123 is prototyped as: | |
124 <PRE | |
125 CLASS="PROGRAMLISTING" | |
126 >typedef int (*SDL_EventFilter)(const SDL_Event *event);</PRE | |
127 > | |
128 If the filter returns <SPAN | |
129 CLASS="RETURNVALUE" | |
130 >1</SPAN | |
131 >, then the event will be | |
132 added to the internal queue. If it returns <SPAN | |
133 CLASS="RETURNVALUE" | |
134 >0</SPAN | |
135 >, | |
136 then the event will be dropped from the queue. This allows selective | |
137 filtering of dynamically.</P | |
138 ><P | |
139 >There is one caveat when dealing with the <TT | |
140 CLASS="LITERAL" | |
141 >SDL_QUITEVENT</TT | |
142 > event type. The | |
143 event filter is only called when the window manager desires to close the | |
144 application window. If the event filter returns 1, then the window will | |
145 be closed, otherwise the window will remain open if possible. | |
146 If the quit event is generated by an interrupt signal, it will bypass the | |
147 internal queue and be delivered to the application at the next event poll.</P | |
148 ><DIV | |
149 CLASS="NOTE" | |
150 ><BLOCKQUOTE | |
151 CLASS="NOTE" | |
152 ><P | |
153 ><B | |
154 >Note: </B | |
155 >Events pushed onto the queue with <A | |
156 HREF="sdlpushevent.html" | |
157 ><TT | |
158 CLASS="FUNCTION" | |
159 >SDL_PushEvent</TT | |
160 ></A | |
161 > or <A | |
162 HREF="sdlpeepevents.html" | |
163 ><TT | |
164 CLASS="FUNCTION" | |
165 >SDL_PeepEvents</TT | |
166 ></A | |
167 > do not get passed through the event filter.</P | |
168 ></BLOCKQUOTE | |
169 ></DIV | |
170 ><DIV | |
171 CLASS="NOTE" | |
172 ><BLOCKQUOTE | |
173 CLASS="NOTE" | |
174 ><P | |
175 ><B | |
176 >Note: </B | |
177 ><I | |
178 CLASS="EMPHASIS" | |
179 >Be Careful!</I | |
180 > The event filter function may run in a different thread so be careful what you do within it.</P | |
181 ></BLOCKQUOTE | |
182 ></DIV | |
183 ></DIV | |
184 ><DIV | |
185 CLASS="REFSECT1" | |
186 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
187 NAME="AEN5214" |
0 | 188 ></A |
189 ><H2 | |
190 >See Also</H2 | |
191 ><P | |
192 ><A | |
193 HREF="sdlevent.html" | |
194 ><SPAN | |
195 CLASS="STRUCTNAME" | |
196 >SDL_Event</SPAN | |
197 ></A | |
198 >, | |
199 <A | |
200 HREF="sdlgeteventfilter.html" | |
201 ><TT | |
202 CLASS="FUNCTION" | |
203 >SDL_GetEventFilter</TT | |
204 ></A | |
205 >, | |
206 <A | |
207 HREF="sdlpushevent.html" | |
208 ><TT | |
209 CLASS="FUNCTION" | |
210 >SDL_PushEvent</TT | |
211 ></A | |
212 ></P | |
213 ></DIV | |
214 ><DIV | |
215 CLASS="NAVFOOTER" | |
216 ><HR | |
217 ALIGN="LEFT" | |
218 WIDTH="100%"><TABLE | |
219 WIDTH="100%" | |
220 BORDER="0" | |
221 CELLPADDING="0" | |
222 CELLSPACING="0" | |
223 ><TR | |
224 ><TD | |
225 WIDTH="33%" | |
226 ALIGN="left" | |
227 VALIGN="top" | |
228 ><A | |
229 HREF="sdlpushevent.html" | |
230 >Prev</A | |
231 ></TD | |
232 ><TD | |
233 WIDTH="34%" | |
234 ALIGN="center" | |
235 VALIGN="top" | |
236 ><A | |
237 HREF="index.html" | |
238 >Home</A | |
239 ></TD | |
240 ><TD | |
241 WIDTH="33%" | |
242 ALIGN="right" | |
243 VALIGN="top" | |
244 ><A | |
245 HREF="sdlgeteventfilter.html" | |
246 >Next</A | |
247 ></TD | |
248 ></TR | |
249 ><TR | |
250 ><TD | |
251 WIDTH="33%" | |
252 ALIGN="left" | |
253 VALIGN="top" | |
254 >SDL_PushEvent</TD | |
255 ><TD | |
256 WIDTH="34%" | |
257 ALIGN="center" | |
258 VALIGN="top" | |
259 ><A | |
260 HREF="eventfunctions.html" | |
261 >Up</A | |
262 ></TD | |
263 ><TD | |
264 WIDTH="33%" | |
265 ALIGN="right" | |
266 VALIGN="top" | |
267 >SDL_GetEventFilter</TD | |
268 ></TR | |
269 ></TABLE | |
270 ></DIV | |
271 ></BODY | |
272 ></HTML | |
273 > |