Top Description Inners Fields Constructors Methods
org.lwjgl.openal

public final Class AL

extends Object
Class Inheritance
Imports
org.lwjgl.*, org.lwjgl.system.*, javax.annotation.*, java.util.*, java.util.function.*

This class must be used before any OpenAL function is called. It has the following responsibilities:

ALCapabilities creation

Instances of ALCapabilities can be created with the createCapabilities method. An OpenAL context must be current in the current thread or process before it is called. Calling this method is expensive, so ALCapabilities instances should be cached in user code.

Thread-local state

Before a function for a given OpenAL context can be called, the corresponding ALCapabilities instance must be made current in the current thread or process. The user is also responsible for clearing the current ALCapabilities instance when the context is destroyed or made current in another thread.

Note that OpenAL contexts are made current process-wide by default. Current thread-local contexts are only available if the ALC_EXT_thread_local_context extension is supported by the OpenAL implementation. OpenAL Soft, the implementation that LWJGL ships with, supports this extension and performs better when it is used.

See Also
ALC

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface
AL.ICD

Function pointer provider.

private static class
AL.ICDStatic

Write-once ICD.

Field Summary

Modifier and TypeField and Description
private static final ThreadLocal<ALCapabilities>
private static AL.ICD
private static ALCapabilities

Constructor Summary

AccessConstructor and Description
private
AL()

Method Summary

Modifier and TypeMethod and Description
private static ALCapabilities
public static ALCapabilities

Returns:

the ALCapabilities instance
createCapabilities
(ALCCapabilities
the ALCCapabilities of the device associated with the current context
alcCaps
)

Creates a new ALCapabilities instance for the OpenAL context that is current in the current thread or process.

public static ALCapabilities

Returns:

the ALCapabilities instance
createCapabilities
(ALCCapabilities
the ALCCapabilities of the device associated with the current context
alcCaps
,
IntFunction<PointerBuffer>
a function that allocates a PointerBuffer given a size. The buffer must be filled with zeroes. If null, LWJGL will allocate a GC-managed buffer internally.
bufferFactory
)

Creates a new ALCapabilities instance for the OpenAL context that is current in the current thread or process.

pack-priv static void
public static ALCapabilities
getCapabilities()

Returns the ALCapabilities for the OpenAL context that is current in the current thread or process.

pack-priv static ALCapabilities
pack-priv static void
init()

public static void
setCurrentProcess(ALCapabilities
the ALCapabilities to make current, or null
caps
)

Sets the specified ALCapabilities for the current process-wide OpenAL context.

public static void
setCurrentThread(ALCapabilities
the ALCapabilities to make current, or null
caps
)

Sets the specified ALCapabilities for the current OpenAL context in the current thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

capabilitiesTLSback to summary
private static final ThreadLocal<ALCapabilities> capabilitiesTLS
icdback to summary
private static AL.ICD icd
processCapsback to summary
private static ALCapabilities processCaps
Annotations
@Nullable

Constructor Detail

ALback to summary
private AL()

Method Detail

checkCapabilitiesback to summary
private static ALCapabilities checkCapabilities(ALCapabilities caps)
createCapabilitiesback to summary
public static ALCapabilities createCapabilities(ALCCapabilities alcCaps)

Creates a new ALCapabilities instance for the OpenAL context that is current in the current thread or process.

This method calls setCurrentProcess (or setCurrentThread if applicable) with the new instance before returning.

Parameters
alcCaps:ALCCapabilities

the ALCCapabilities of the device associated with the current context

Returns:ALCapabilities

the ALCapabilities instance

createCapabilitiesback to summary
public static ALCapabilities createCapabilities(ALCCapabilities alcCaps, IntFunction<PointerBuffer> bufferFactory)

Creates a new ALCapabilities instance for the OpenAL context that is current in the current thread or process.

Parameters
alcCaps:ALCCapabilities

the ALCCapabilities of the device associated with the current context

bufferFactory:IntFunction<PointerBuffer>

a function that allocates a PointerBuffer given a size. The buffer must be filled with zeroes. If null, LWJGL will allocate a GC-managed buffer internally.

Returns:ALCapabilities

the ALCapabilities instance

destroyback to summary
pack-priv static void destroy()
getCapabilitiesback to summary
public static ALCapabilities getCapabilities()

Returns the ALCapabilities for the OpenAL context that is current in the current thread or process.

Exceptions
IllegalStateException:
if no OpenAL context is current in the current thread or process
getICDback to summary
pack-priv static ALCapabilities getICD()
initback to summary
pack-priv static void init()
setCurrentProcessback to summary
public static void setCurrentProcess(ALCapabilities caps)

Sets the specified ALCapabilities for the current process-wide OpenAL context.

If the current thread had a context current (see setCurrentThread), those ALCapabilities are cleared. Any OpenAL functions called in the current thread, or any threads that have no context current, will use the specified ALCapabilities.

Parameters
caps:ALCapabilities

the ALCapabilities to make current, or null

setCurrentThreadback to summary
public static void setCurrentThread(ALCapabilities caps)

Sets the specified ALCapabilities for the current OpenAL context in the current thread.

Any OpenAL functions called in the current thread will use the specified ALCapabilities.

Parameters
caps:ALCapabilities

the ALCapabilities to make current, or null

org.lwjgl.openal back to summary

private Interface AL.ICD

Known Direct Implementers
org.lwjgl.openal.AL.ICDStatic

Function pointer provider.

Method Summary

Modifier and TypeMethod and Description
public ALCapabilities
get()

public default void

Method Detail

getback to summary
public ALCapabilities get()
Annotations
@Nullable
setback to summary
public default void set(ALCapabilities caps)
org.lwjgl.openal back to summary

private Class AL.ICDStatic

extends Object
implements ICD
Class Inheritance
All Implemented Interfaces
org.lwjgl.openal.AL.ICD

Write-once ICD.

This is the default implementation that skips the thread/process lookup. When a new ALCapabilities is set, we compare it to the write-once capabilities. If different function pointers are found, we fall back to the expensive lookup. This will never happen with the OpenAL-Soft implementation.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static ALCapabilities

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public ALCapabilities
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

tempCapsback to summary
private static ALCapabilities tempCaps
Annotations
@Nullable

Constructor Detail

ICDStaticback to summary
private ICDStatic()

Method Detail

getback to summary
public ALCapabilities get()

Implements org.lwjgl.openal.AL.ICD.get.

Annotations
@Override
setback to summary
public void set(ALCapabilities caps)

Overrides default org.lwjgl.openal.AL.ICD.set.

Annotations
@SuppressWarnings:AssignmentToStaticFieldFromInstanceMethod
@Override
org.lwjgl.openal back to summary

private final Class AL.ICDStatic.WriteOnce

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final ALCapabilities

Constructor Summary

AccessConstructor and Description
private

Field Detail

capsback to summary
pack-priv static final ALCapabilities caps

Constructor Detail

WriteOnceback to summary
private WriteOnce()