Package com.jogamp.openal.sound3d
Class Context
- java.lang.Object
-
- com.jogamp.openal.sound3d.Context
-
public final class Context extends Object
This class provides a Sound3D Context associated with a specified device.- Author:
- Athomas Goldberg, Sven Gothel, et al.
-
-
Field Summary
Fields Modifier and Type Field Description boolean
hasALC_thread_local_context
-
Constructor Summary
Constructors Constructor Description Context(ALCcontext realContext, Device device)
Creates a new Context for a givenALCcontext
for the specified device.Context(Device device, int[] attributes)
Creates a new Context for a specified device including nativeALCcontext
creation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
create(int[] attributes)
Creates the internalALCcontext
instance ifgetALContext()
is nullvoid
destroy()
destroys this context freeing its resources.int
getALCError()
ReturnALC.alcGetError(ALCdevice)
usinggetDevice()
.ALCcontext
getALContext()
Returns the OpenALALCcontext
.static Context
getCurrentContext()
Returns this thread current context.Device
getDevice()
Gets the device associated with this context.int
getLockCount()
Return the lock count of this context, i.e.boolean
isValid()
Returns whethergetALContext()
is valid, i.e.boolean
makeCurrent(boolean throwException)
Makes the audio context current on the calling thread.boolean
recreate(int[] attributes)
Recreates the internalALCcontext
instance, i.e.boolean
release(boolean throwException)
Releases control of this audio context from the current thread, if implementation utilizes context locking.void
suspend()
Suspend this contextString
toString()
-
-
-
Constructor Detail
-
Context
public Context(ALCcontext realContext, Device device)
Creates a new Context for a givenALCcontext
for the specified device.- Parameters:
realContext
-ALCcontext
instance, maybe nulldevice
- The device the Context belongs to, must be valid
-
Context
public Context(Device device, int[] attributes)
Creates a new Context for a specified device including nativeALCcontext
creation.- Parameters:
device
- The device the Context is being created for, must be valid.attributes
- list ofALCcontext
attributes for context creation, maybe empty or null
-
-
Method Detail
-
create
public boolean create(int[] attributes)
Creates the internalALCcontext
instance ifgetALContext()
is null- Parameters:
attributes
- lost ofALCcontext
attributes for context creation- Returns:
- true if the internal context has been successfully created, otherwise false
-
recreate
public boolean recreate(int[] attributes)
Recreates the internalALCcontext
instance, i.e. destroys it first ifgetALContext()
not null.Context is made current again if it was current before.
- Parameters:
attributes
- lost ofALCcontext
attributes for context creation- Returns:
- true if the internal context has been successfully recreated and made current again if was current before, otherwise false
-
getALContext
public ALCcontext getALContext()
Returns the OpenALALCcontext
.
-
isValid
public boolean isValid()
Returns whethergetALContext()
is valid, i.e. not null, e.g. notdestroy()
'ed.
-
getALCError
public int getALCError()
ReturnALC.alcGetError(ALCdevice)
usinggetDevice()
.
-
destroy
public void destroy()
destroys this context freeing its resources.
-
getCurrentContext
public static Context getCurrentContext()
Returns this thread current context. If no context is current, returns null.- Returns:
- the context current on this thread, or null if no context is current.
- See Also:
#makeCurrent()
,#release()
-
getLockCount
public int getLockCount()
Return the lock count of this context, i.e. 0 if not locked, 1 if locked once, >1 for recursive locks.
-
makeCurrent
public boolean makeCurrent(boolean throwException) throws ALException
Makes the audio context current on the calling thread.Recursive call to
#makeCurrent()
and hence#release()
are supported.At any point in time one context can only be current on one thread, and one thread can only have one context current.
- Parameters:
throwException
- if true, throws ALException ifgetALContext()
is null, current thread holds another context or failed to natively make current- Returns:
- true if
getALContext()
is valid, current thread holds no other context and context successfully made current, otherwise false - Throws:
ALException
- See Also:
#release()
-
release
public boolean release(boolean throwException) throws ALException
Releases control of this audio context from the current thread, if implementation utilizes context locking.Recursive call to
#makeCurrent()
and hence#release()
are supported.If native release fails, internal lock is not released.
- Parameters:
throwException
- if true, throws ALException if context has not been previously made current on current thread or native release failed.- Returns:
- true if context has previously been made current on the current thread and successfully released, otherwise false
- Throws:
ALException
- See Also:
#makeCurrent()
-
suspend
public void suspend()
Suspend this context
-
getDevice
public Device getDevice()
Gets the device associated with this context.- Returns:
- the device associated with this context.
-
-