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 booleanhasALC_thread_local_context
-
Constructor Summary
Constructors Constructor Description Context(ALCcontext realContext, Device device)Creates a new Context for a givenALCcontextfor the specified device.Context(Device device, int[] attributes)Creates a new Context for a specified device including nativeALCcontextcreation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancreate(int[] attributes)Creates the internalALCcontextinstance ifgetALContext()is nullvoiddestroy()destroys this context freeing its resources.intgetALCError()ReturnALC.alcGetError(ALCdevice)usinggetDevice().ALCcontextgetALContext()Returns the OpenALALCcontext.static ContextgetCurrentContext()Returns this thread current context.DevicegetDevice()Gets the device associated with this context.intgetLockCount()Return the lock count of this context, i.e.booleanisDebugAvail()Returns whether `AL_EXT_debug` is available for the current context.booleanisValid()Returns whethergetALContext()is valid, i.e.booleanmakeCurrent(boolean throwException)Makes the audio context current on the calling thread.booleanrecreate(int[] attributes)Recreates the internalALCcontextinstance, i.e.booleanrelease(boolean throwException)Releases control of this audio context from the current thread, if implementation utilizes context locking.voidsuspend()Suspend this contextStringtoString()booleantryMakeCurrent(boolean throwException, long timeoutMS)
-
-
-
Constructor Detail
-
Context
public Context(ALCcontext realContext, Device device)
Creates a new Context for a givenALCcontextfor the specified device.- Parameters:
realContext-ALCcontextinstance, 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 nativeALCcontextcreation.- Parameters:
device- The device the Context is being created for, must be valid.attributes- list ofALCcontextattributes for context creation, maybe empty or null
-
-
Method Detail
-
isDebugAvail
public boolean isDebugAvail()
Returns whether `AL_EXT_debug` is available for the current context.- See Also:
Device.isDebugAvail()
-
create
public boolean create(int[] attributes)
Creates the internalALCcontextinstance ifgetALContext()is null- Parameters:
attributes- lost ofALCcontextattributes for context creation- Returns:
- true if the internal context has been successfully created, otherwise false
-
recreate
public boolean recreate(int[] attributes)
Recreates the internalALCcontextinstance, i.e. destroys it first ifgetALContext()not null.Context is made current again if it was current before.
- Parameters:
attributes- lost ofALCcontextattributes 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.
-
tryMakeCurrent
public boolean tryMakeCurrent(boolean throwException, long timeoutMS) throws RuntimeException- Throws:
RuntimeException
-
makeCurrent
public boolean makeCurrent(boolean throwException) throws ALExceptionMakes 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 ALExceptionReleases 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.
-
-