aboutsummaryrefslogtreecommitdiffstats
path: root/doc/deployment/JOGL-DEPLOYMENT.html
blob: 1c504a1e4ec5e2a0735f88d671d182838a5608c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="../../../style.css" rel="stylesheet" type="text/css"/>
        <title>JOGL Deployment</title>
    </head>
    <body>
        <div id="container">
            <div id="header">
                <div id="slogan">.. bundle .. deploy</div>
                <div id="logo"><a href="http://jogamp.org/">JOGL Deployment</a></div>
            </div>
            <div id="menu">
                <ul>
                    <li><a href="http://jogamp.org/">Home</a></li>
                    <li><a href="../../../gluegen/www/">Gluegen</a></li>
                    <li><a href="../../../joal/www/">JOAL</a></li>
                    <li><a href="../../../jocl/www/">JOCL</a></li>
                    <li><a href="../../../jogl/www/">JOGL</a></li>
                    <li><a href="../../../demos/www/">Demos</a></li>
                    <li><a href="../../../wiki/">Wiki</a></li>
                    <li><a href="../../../deployment/jogl-next/javadoc_public/">JavaDoc</a></li>
                    <li><a href="../../../blog/">Blogs</a></li>
                    <li><a href="../../../forum.html">Forums</a></li>
                </ul>
            </div>
            <div id="main">
                <div id="text" class="fill">

                    <h1><a name="NApplets">New Applets</a></h1>

                    <p>
                    You may choose to use traditional <a href="http://java.sun.com/applets/">Java Applets</a> to deploy your 
                    in-browser applet and reference the JOGL resources.<p/>

                    <p>
                    This method simply requires a Java plugin and uses JogAmp's
                    <a href="../userguide/index.html#automatednativelibraryloading">build-in method to automatically load</a>
                    the <a href="#NativeJARFiles">native JAR files</a>.
                    </p>

                    <a href="http://jogamp.org/deployment/jogamp-current/jogl-demos/applet-gears-napplet.html">AWT/JOGL NApplet Example</a>:
                    <pre>
                        &lt;object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                              width="600" height="400"&gt;
                           &lt;param name="code" value="demos.applets.GearsApplet"&gt;
                           &lt;param name="archive" value="../jar/gluegen-rt.jar,
                                                           ../jar/jogl-all.jar,
                                                           jar/jogl-demos.jar"&gt;
                           &lt;comment&gt;
                             &lt;embed code="demos.applets.GearsApplet"
                                  width="600" height="400"
                                  type="application/x-java-applet;version=1.6"
                                  pluginspage="http://java.sun.com/javase/downloads/ea.jsp"
                                  archive="../jar/gluegen-rt.jar,
                                           ../jar/jogl-all.jar,
                                           jar/jogl-demos.jar"&gt;
                                &lt;noembed&gt;Sorry, no Java support detected.&lt;/noembed&gt;
                             &lt;/embed&gt;
                           &lt;/comment&gt;
                        &lt;/object&gt;
                    </pre>
                    <p>
                    NEWT/JOGL NApplet Examples:
                    <ul>
                        <li><a href="http://jausoft.com/jogamp/jogl-applet-runner-newt-gears-normal-napplet.html">Demo on jausoft.com and modules on jogamp.org</a></li>
                        <li><a href="http://jogamp.org/deployment/jogamp-current/jogl-applet-runner-newt-gears-normal-napplet.html">Demo and modules on jogamp.org</a></li>
                    </ul>
                    </p>

                    <h1><a name="JNLPFiles">JNLP Files</a></h1>

                    <p>
                    You may choose to use JNLP to deploy your application or in-browser applet
                    and reference the JOGL resources.<p/>

                    <p>
                    You have the choice to use <a href="http://jdk6.dev.java.net/plugin2/jnlp/">JNLP Applets</a>
                    or <a href="http://java.sun.com/products/javawebstart/">Java Webstart</a>.<p/>

                    <p>
                    You might want to have a look at our <a href="http://jogamp.org/deployment/jogamp-current/jogl-test-applets.html">Test page for JOGL Applets</a>. Here is a <a href="http://jogamp.org/deployment/jogamp-current/jogl-applet-runner-newt-gears-normal.html">documented example</a><p/>

                    Supported JNLP bases are:
                    <ul>
                        <li> <code><b> http://jogamp.org/deployment/jogamp-current/ </b></code> Current Version </li>
                        <li> <code><b> http://jogamp.org/deployment/jogamp-next/ </b></code> Next Version </li>
                        <li> <code><b> http://jogamp.org/deployment/v2.0-rc10/ </b></code> Specific Version </li>
                    </ul>

                    <h2>Desktop All in One</h2>

                    <h3>With AWT</h3>
                    <ul>
                        <li><code>jogl-all-awt.jnlp</code><br/>
                            <ul>
                                <li><code>gluegen-rt.jnlp</code></li>
                            </ul>
                        </li>
                    </ul>

                    <h3>Without AWT</h3>
                    <ul>
                        <li><code>jogl-all-noawt.jnlp</code><br/>
                            <ul>
                                <li><code>gluegen-rt.jnlp</code></li>
                            </ul>
                        </li>
                    </ul>

                    <h3>Mobile</h3>
                    <ul>
                        <li><code>jogl-all-mobile.jnlp</code><br/>
                            <ul>
                                <li><code>gluegen-rt.jnlp</code></li>
                            </ul>
                        </li>
                    </ul>
                    <p>
                        The above JNLP files will load the <a href="#GluegenJARs">GlueGen JARs</a>
                        as well as the <a href="#JOGLAllInOneJARs">JOGL All-In-One JARs</a>.
                    </p>

                    <hr/>
                    <h1><a name="JARFiles">JAR Files</a></h1>

                    <h2><a name="NativeJARFiles">Native JAR Files</a></h2>
                    All JAR files containing platform dependent native libraries 
                    contain the string <code>natives</code> and the 
                    <a href="#NativeJARFileNameConvention"><b><i>os.and.arch</i></b></a>
                    identifier in their name.

                    The actual native library files are <a href="#NativeLibraryFiles">listed below</a>.

                    <h3><a name="NativeJARFileNameConvention">Naming Convention</a></h3>
                    JogAmp's build system has the notion of <b><i>os.and.arch</i></b> string identifier,
                    to name platform dependent build artifacts.<br/> 
                    Currently used and supported names are:
                    <ul>
                        <li>freebsd-i586</li>
                        <li>freebsd-amd64</li>
                        <li>hpux-hppa</li>
                        <li>linux-amd64</li>
                        <li>linux-ia64</li>
                        <li>linux-i586</li>
                        <li>linux-armv6</li>
                        <li>linux-armv6hf</li>
                        <li>android-armv6</li>
                        <li>macosx-universal</li>
                        <li>solaris-sparc</li>
                        <li>solaris-sparcv9</li>
                        <li>solaris-amd64</li>
                        <li>solaris-i586</li>
                        <li>windows-amd64</li>
                        <li>windows-i586</li>
                    </ul>

                    <h2><a name="GluegenJARs">Gluegen JARs - Mandatory</a></h2>
                    <ul>
                        <li><code>gluegen-rt.jar</code><br/>
                            <ul>
                                <li><code>gluegen-rt-natives-<b><i>os.and.arch</i></b>.jar</code></li>
                            </ul>
                        </li>
                    </ul>

                    <h3><a name="JOGLAllInOneJARs">JOGL JARs - All-In-One</a></h3>

                    <p>
                        This might be the best solution
                        for desktop (applets and webstart).<br/>

                        It is much faster to download
                        a (maybe bigger) file once and cache
                        it for most purposes, than to download
                        tens of files where its cache might not
                        be reuseable.<br/>
                    </p>

                    <a name="JOGLAllInOneJARsAWT">With AWT</a>:
                    <ul>
                        <li><code>jogl-all.jar</code><br/>
                            <ul>
                                <li><code>jogl-all-natives-<b><i>os.and.arch</i></b>.jar</code></li>
                            </ul>
                        </li>
                    </ul>

                    <a name="JOGLAllInOneJARsNoAWT">Without AWT</a>:
                    <ul>
                        <li><code>jogl-all-noawt.jar</code><br/>
                            <ul>
                                <li><code>jogl-all-natives-<b><i>os.and.arch</i></b>.jar</code></li>
                            </ul>
                        </li>
                    </ul>

                    <a name="JOGLAllInOneJARsMobile">Mobile</a>:
                    <ul>
                        <li><code>jogl-all-mobile.jar</code><br/>
                            <ul>
                                <li><code>jogl-all-natives-<b><i>os.and.arch</i></b>.jar</code></li>
                            </ul>
                        </li>
                    </ul>

                    <a name="JOGLAllInOneJARsAndroid">Android</a>:
                    <ul>
                        <li><code>jogl-all-android.jar</code><br/>
                            <ul>
                                <li><code>jogl-all-natives-<b><i>os.and.arch</i></b>.jar</code></li>
                            </ul>
                        </li>
                    </ul>

                    <h3>Atomic Deployment </h3>

                    This is a fine tuned solution
                    where every byte counts.<br/>

                    It is also possible to use this
                    strategy as a starting point for
                    efficient manual deployment.<br/>

                    <h4>Cores</h4>
                    <ul>
                        <li>Mandatory:<br/>
                            <ul>
                                <li>nativewindow.jar</li>
                                <li>jogl.jar</li>
                            </ul></li>

                        <li>Newt (optional):<br/>
                            <ul>
                                <li>newt.jar</li>
                                <li>newt-ogl.jar  (to use NEWT with JOGL)</li>
                            </ul></li>
                    </ul>

                    <h4>Platform (mandatory)</h4>

                    Chose the same platform for all picks :)

                    <ul>
                        <li>NativeWindow [pick your platfrom, if available]:<br/>
                            <ul>
                                <li>nativewindow-os-x11.jar</li>
                            </ul></li>

                        <li>JOGL [pick your platform]:<br/>
                            <ul>
                                <li>jogl-os-x11.jar</li>
                                <li>jogl-os-win.jar</li>
                                <li>jogl-os-osx.jar</li>
                                <li>none</li>
                            </ul></li>

                        <li>Newt [pick your platform] (optional):<br/>
                            <ul>
                                <li>newt-driver-x11.jar</li>
                                <li>newt-driver-win.jar</li>
                                <li>newt-driver-osx.jar</li>
                                <li>newt-driver-kd.jar</li>
                                <li>newt-driver-bcm-vc.jar</li>
                                <li>newt-driver-bcm-old.jar</li>
                                <li>newt-driver-intelgdl.jar</li>
                                <li>none</li>
                            </ul></li>
                    </ul>

                    <h4>OpenGL Profile (mandatory)</h4>

                    Pick as many as you like, at least 1:

                    <ul>
                        <li>Embedded Device Profiles<br/>
                            <ul>
                                <li>jogl-glmobile.jar<br/>
                                    <ul>
                                        <li>jogl-glmobile-dbg.jar</li>
                                    </ul></li>
                            </ul></li>

                        <li>Desktop Profiles<br/>
                            <ul>
                                <li>jogl-gldesktop.jar<br/>
                                    <ul>
                                        <li>jogl-gldesktop-dbg.jar</li>
                                    </ul></li>
                            </ul></li>
                    </ul>


                    <h4>JOGL Toolkits/Misc (optional)</h4>
                    <ul>
                        <li>jogl-util.jar</li>
                        <li>jogl-util-gldesktop.jar</li>
                        <li>jogl-util-fixedfuncemu.jar</li>
                    </ul>


                    <h4>AWT (optional) </h4>

                    <ul>
                        <li> nativewindow-awt.jar</li>
                        <li> jogl-awt.jar</li>
                        <li> jogl-util-awt.jar (if using jogl-util)</li>
                        <li> newt-awt.jar (if using with NEWT)</li>
                    </ul>

                    <h4>GLU (optional) </h4>
                    <ul>
                        <li>jogl-glu-tess.jar</li>
                        <li>jogl-glu-mipmap.jar</li>
                        <li>jogl-glu-gldesktop.jar</li>
                    </ul>

                    <h2><a name="NativeLibraryFiles">Native Library Files</a></h2>

                    Gluegen native libraries:
                    <ul>
                        <li>libgluegen-rt.so</li>
                    </ul>

                    NativeWindow native libraries
                    <ul>
                        <li>libnativewindow_awt.so</li>
                        <li>libnativewindow_jvm.so</li>
                        <li>libnativewindow_x11.so</li>
                    </ul>

                    JOGL native libraries
                    <ul>
                        <li>libjogl_desktop.so</li>
                        <li>libjogl_mobile.so</li>
                        <li>libjogl_cg.so</li>
                    </ul>

                    NEWT native libraries
                    <ul>
                        <li>libnewt.so</li>
                    </ul>

                </div>
            </div>
            <div id="footer">
                <div id="footer_left">
                    <span>JogAmp.org</span>
                    by <a href="http://jogamp.org">http://jogamp.org</a>
                    is licensed under a <br/>
                    <a href="http://creativecommons.org/licenses/by/3.0/us/">Creative Commons Attribution 3.0 License</a>.
                </div>
            </div>
        </div>
    </body>
</html>
pan> { auto iter = std::find_if(context->EffectSlotList.begin(), context->EffectSlotList.end(), [](const ALeffectslotPtr &entry) noexcept -> bool { return !entry; } ); if(iter == context->EffectSlotList.end()) { if(UNLIKELY(device->AuxiliaryEffectSlotMax == context->EffectSlotList.size())) { slotlock.unlock(); alDeleteAuxiliaryEffectSlots(cur, effectslots); alSetError(context.get(), AL_OUT_OF_MEMORY, "Exceeding %u auxiliary effect slot limit", device->AuxiliaryEffectSlotMax); return; } context->EffectSlotList.emplace_back(nullptr); iter = context->EffectSlotList.end() - 1; } *iter = al::make_unique<ALeffectslot>(); ALenum err{InitEffectSlot(iter->get())}; if(err != AL_NO_ERROR) { *iter = nullptr; slotlock.unlock(); alDeleteAuxiliaryEffectSlots(cur, effectslots); alSetError(context.get(), err, "Effect slot object allocation failed"); return; } aluInitEffectPanning(iter->get()); auto id = static_cast<ALuint>(std::distance(context->EffectSlotList.begin(), iter) + 1); (*iter)->id = id; effectslots[cur] = id; } AddActiveEffectSlots(effectslots, n, context.get()); } AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots) { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; if(n < 0) SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Deleting %d effect slots", n); if(n == 0) return; std::lock_guard<std::mutex> _{context->EffectSlotLock}; auto effectslots_end = effectslots + n; auto bad_slot = std::find_if(effectslots, effectslots_end, [&context](ALuint id) -> bool { ALeffectslot *slot{LookupEffectSlot(context.get(), id)}; if(!slot) { alSetError(context.get(), AL_INVALID_NAME, "Invalid effect slot ID %u", id); return true; } if(ReadRef(&slot->ref) != 0) { alSetError(context.get(), AL_INVALID_NAME, "Deleting in-use effect slot %u", id); return true; } return false; } ); if(bad_slot != effectslots_end) return; // All effectslots are valid, remove and delete them RemoveActiveEffectSlots(effectslots, n, context.get()); std::for_each(effectslots, effectslots_end, [&context](ALuint id) noexcept -> void { context->EffectSlotList[id-1] = nullptr; } ); } AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot) { ContextRef context{GetContextRef()}; if(LIKELY(context)) { std::lock_guard<std::mutex> _{context->EffectSlotLock}; if(LookupEffectSlot(context.get(), effectslot) != nullptr) return AL_TRUE; } return AL_FALSE; } AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint value) { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; std::lock_guard<std::mutex> _{context->PropLock}; std::lock_guard<std::mutex> __{context->EffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(UNLIKELY(!slot)) SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); ALeffectslot *target{}; ALCdevice *device{}; ALenum err{}; switch(param) { case AL_EFFECTSLOT_EFFECT: device = context->Device; { std::lock_guard<std::mutex> ___{device->EffectLock}; ALeffect *effect{value ? LookupEffect(device, value) : nullptr}; if(!(value == 0 || effect != nullptr)) SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Invalid effect ID %u", value); err = InitializeEffect(context.get(), slot, effect); } if(err != AL_NO_ERROR) { alSetError(context.get(), err, "Effect initialization failed"); return; } break; case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: if(!(value == AL_TRUE || value == AL_FALSE)) SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Effect slot auxiliary send auto out of range"); slot->AuxSendAuto = value; break; case AL_EFFECTSLOT_TARGET_SOFT: target = (value ? LookupEffectSlot(context.get(), value) : nullptr); if(value && !target) SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Invalid effect slot target ID"); if(target) { ALeffectslot *checker{target}; while(checker && checker != slot) checker = checker->Target; if(checker) SETERR_RETURN(context.get(), AL_INVALID_OPERATION,, "Setting target of effect slot ID %u to %u creates circular chain", slot->id, target->id); } if(ALeffectslot *oldtarget{slot->Target}) { /* We must force an update if there was an existing effect slot * target, in case it's about to be deleted. */ if(target) IncrementRef(&target->ref); DecrementRef(&oldtarget->ref); slot->Target = target; UpdateEffectSlotProps(slot, context.get()); return; } if(target) IncrementRef(&target->ref); slot->Target = target; break; default: SETERR_RETURN(context.get(), AL_INVALID_ENUM,, "Invalid effect slot integer property 0x%04x", param); } DO_UPDATEPROPS(); } AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *values) { switch(param) { case AL_EFFECTSLOT_EFFECT: case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: case AL_EFFECTSLOT_TARGET_SOFT: alAuxiliaryEffectSloti(effectslot, param, values[0]); return; } ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; std::lock_guard<std::mutex> _{context->EffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(UNLIKELY(!slot)) SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); switch(param) { default: SETERR_RETURN(context.get(), AL_INVALID_ENUM,, "Invalid effect slot integer-vector property 0x%04x", param); } } AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat value) { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; std::lock_guard<std::mutex> _{context->PropLock}; std::lock_guard<std::mutex> __{context->EffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(UNLIKELY(!slot)) SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); switch(param) { case AL_EFFECTSLOT_GAIN: if(!(value >= 0.0f && value <= 1.0f)) SETERR_RETURN(context.get(), AL_INVALID_VALUE,, "Effect slot gain out of range"); slot->Gain = value; break; default: SETERR_RETURN(context.get(), AL_INVALID_ENUM,, "Invalid effect slot float property 0x%04x", param); } DO_UPDATEPROPS(); } AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *values) { switch(param) { case AL_EFFECTSLOT_GAIN: alAuxiliaryEffectSlotf(effectslot, param, values[0]); return; } ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; std::lock_guard<std::mutex> _{context->EffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(UNLIKELY(!slot)) SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); switch(param) { default: SETERR_RETURN(context.get(), AL_INVALID_ENUM,, "Invalid effect slot float-vector property 0x%04x", param); } } AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *value) { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; std::lock_guard<std::mutex> _{context->EffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(UNLIKELY(!slot)) SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); switch(param) { case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: *value = slot->AuxSendAuto; break; case AL_EFFECTSLOT_TARGET_SOFT: *value = slot->Target ? slot->Target->id : 0; break; default: SETERR_RETURN(context.get(), AL_INVALID_ENUM,, "Invalid effect slot integer property 0x%04x", param); } } AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *values) { switch(param) { case AL_EFFECTSLOT_EFFECT: case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: case AL_EFFECTSLOT_TARGET_SOFT: alGetAuxiliaryEffectSloti(effectslot, param, values); return; } ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; std::lock_guard<std::mutex> _{context->EffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(UNLIKELY(!slot)) SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); switch(param) { default: SETERR_RETURN(context.get(), AL_INVALID_ENUM,, "Invalid effect slot integer-vector property 0x%04x", param); } } AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *value) { ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; std::lock_guard<std::mutex> _{context->EffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(UNLIKELY(!slot)) SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); switch(param) { case AL_EFFECTSLOT_GAIN: *value = slot->Gain; break; default: SETERR_RETURN(context.get(), AL_INVALID_ENUM,, "Invalid effect slot float property 0x%04x", param); } } AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *values) { switch(param) { case AL_EFFECTSLOT_GAIN: alGetAuxiliaryEffectSlotf(effectslot, param, values); return; } ContextRef context{GetContextRef()}; if(UNLIKELY(!context)) return; std::lock_guard<std::mutex> _{context->EffectSlotLock}; ALeffectslot *slot = LookupEffectSlot(context.get(), effectslot); if(UNLIKELY(!slot)) SETERR_RETURN(context.get(), AL_INVALID_NAME,, "Invalid effect slot ID %u", effectslot); switch(param) { default: SETERR_RETURN(context.get(), AL_INVALID_ENUM,, "Invalid effect slot float-vector property 0x%04x", param); } } ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect) { ALenum newtype{effect ? effect->type : AL_EFFECT_NULL}; if(newtype != EffectSlot->Effect.Type) { EffectStateFactory *factory{getFactoryByType(newtype)}; if(!factory) { ERR("Failed to find factory for effect type 0x%04x\n", newtype); return AL_INVALID_ENUM; } EffectState *State{factory->create()}; if(!State) return AL_OUT_OF_MEMORY; FPUCtl mixer_mode{}; ALCdevice *Device{Context->Device}; std::unique_lock<std::mutex> statelock{Device->StateLock}; State->mOutBuffer = Device->Dry.Buffer; State->mOutChannels = Device->Dry.NumChannels; if(State->deviceUpdate(Device) == AL_FALSE) { statelock.unlock(); mixer_mode.leave(); State->DecRef(); return AL_OUT_OF_MEMORY; } mixer_mode.leave(); if(!effect) { EffectSlot->Effect.Type = AL_EFFECT_NULL; EffectSlot->Effect.Props = ALeffectProps{}; } else { EffectSlot->Effect.Type = effect->type; EffectSlot->Effect.Props = effect->Props; } EffectSlot->Effect.State->DecRef(); EffectSlot->Effect.State = State; } else if(effect) EffectSlot->Effect.Props = effect->Props; /* Remove state references from old effect slot property updates. */ ALeffectslotProps *props{Context->FreeEffectslotProps.load()}; while(props) { if(props->State) props->State->DecRef(); props->State = nullptr; props = props->next.load(std::memory_order_relaxed); } return AL_NO_ERROR; } void EffectState::IncRef() noexcept { auto ref = IncrementRef(&mRef); TRACEREF("%p increasing refcount to %u\n", this, ref); } void EffectState::DecRef() noexcept { auto ref = DecrementRef(&mRef); TRACEREF("%p decreasing refcount to %u\n", this, ref); if(ref == 0) delete this; } ALenum InitEffectSlot(ALeffectslot *slot) { EffectStateFactory *factory{getFactoryByType(slot->Effect.Type)}; if(!factory) return AL_INVALID_VALUE; slot->Effect.State = factory->create(); if(!slot->Effect.State) return AL_OUT_OF_MEMORY; slot->Effect.State->IncRef(); slot->Params.mEffectState = slot->Effect.State; return AL_NO_ERROR; } ALeffectslot::~ALeffectslot() { if(Target) DecrementRef(&Target->ref); Target = nullptr; ALeffectslotProps *props{Update.load()}; if(props) { if(props->State) props->State->DecRef(); TRACE("Freed unapplied AuxiliaryEffectSlot update %p\n", props); al_free(props); } if(Effect.State) Effect.State->DecRef(); if(Params.mEffectState) Params.mEffectState->DecRef(); } void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context) { /* Get an unused property container, or allocate a new one as needed. */ ALeffectslotProps *props{context->FreeEffectslotProps.load(std::memory_order_relaxed)}; if(!props) props = static_cast<ALeffectslotProps*>(al_calloc(16, sizeof(*props))); else { ALeffectslotProps *next; do { next = props->next.load(std::memory_order_relaxed); } while(context->FreeEffectslotProps.compare_exchange_weak(props, next, std::memory_order_seq_cst, std::memory_order_acquire) == 0); } /* Copy in current property values. */ props->Gain = slot->Gain; props->AuxSendAuto = slot->AuxSendAuto; props->Target = slot->Target; props->Type = slot->Effect.Type; props->Props = slot->Effect.Props; /* Swap out any stale effect state object there may be in the container, to * delete it. */ EffectState *oldstate{props->State}; slot->Effect.State->IncRef(); props->State = slot->Effect.State; /* Set the new container for updating internal parameters. */ props = slot->Update.exchange(props, std::memory_order_acq_rel); if(props) { /* If there was an unused update container, put it back in the * freelist. */ if(props->State) props->State->DecRef(); props->State = nullptr; AtomicReplaceHead(context->FreeEffectslotProps, props); } if(oldstate) oldstate->DecRef(); } void UpdateAllEffectSlotProps(ALCcontext *context) { std::lock_guard<std::mutex> _{context->EffectSlotLock}; ALeffectslotArray *auxslots{context->ActiveAuxSlots.load(std::memory_order_acquire)}; for(ALeffectslot *slot : *auxslots) { if(!slot->PropsClean.test_and_set(std::memory_order_acq_rel)) UpdateEffectSlotProps(slot, context); } }