Package com.jogamp.openal.util
Class ALAudioSink
- java.lang.Object
-
- com.jogamp.openal.util.ALAudioSink
-
- All Implemented Interfaces:
AudioSink
public final class ALAudioSink extends Object implements AudioSink
OpenALAudioSinkimplementation.Besides given
AudioSinkfunctionality, implementation is fully functional regardingAudioFormatand all OpenAL parameter.
- All OpenAL parameter can be queried
- Instance can be constructed with an OpenAL device and context, see
#ALAudioSink(ALCdevice, ALCcontext) - Initialization can be performed with OpenAL paramters, see
#init(int, int, int, int, int, float, int, int, int)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.jogamp.common.av.AudioSink
AudioSink.AudioDataFrame, AudioSink.AudioFrame
-
-
Field Summary
-
Fields inherited from interface com.jogamp.common.av.AudioSink
DEBUG, DefaultFormat, DefaultFrameDuration, DefaultQueueSize, DefaultQueueSizeWithVideo
-
-
Constructor Summary
Constructors Constructor Description ALAudioSink()Create a new instance with a new defaultALCdeviceALAudioSink(Device alDevice)Create a new instance with an optional givenALCdeviceALAudioSink(String deviceName)Create a new instance with a new namedALCdevice
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()AudioSink.AudioFrameenqueueData(int pts, ByteBuffer bytes, int byteCount)voidflush()static ALgetAL()Return OpenAL globalAL.static ALCgetALC()Return OpenAL globalALC.intgetALChannelLayout()Return this instance's OpenAL channel layout, set after#init(AudioFormat, float, int).static ALExtgetALExt()Return OpenAL globalALExt.intgetALFormat()Return this instance's OpenAL format, set after#init(AudioFormat, float, int).intgetALSampleType()Return this instance's OpenAL sample type, set after#init(AudioFormat, float, int).floatgetAvgFrameDuration()AudioFormatgetChosenFormat()ContextgetContext()Return this instance's OpenALContext.floatgetDefaultLatency()DevicegetDevice()Return this instance's OpenALDevice.intgetEnqueuedFrameCount()intgetFrameCount()intgetFreeFrameCount()intgetLastBufferedPTS()floatgetLatency()AudioFormatgetNativeFormat()StringgetPerfString()floatgetPlaySpeed()AudioFormatgetPreferredFormat()PTSgetPTS()intgetQueuedByteCount()floatgetQueuedDuration()intgetQueuedFrameCount()SourcegetSource()Return this instance's OpenALSource.intgetSourceCount()booleangetUseSOFTEvents(boolean v)Returns whetherAL_SOFT_eventsis enabled, default ifhasSOFTEvents().floatgetVolume()booleanhasALCThreadLocalContext()Return whether OpenAL extensionALC_EXT_thread_local_contextis available.booleanhasEXTDouble()Return whether OpenAL extensionAL_EXT_DOUBLEis available.booleanhasEXTFloat32()Return whether OpenAL extensionAL_EXT_FLOAT32is available.booleanhasEXTMcFormats()Return whether OpenAL extensionAL_EXT_MCFORMATSis available.booleanhasSOFTBufferSamples()Return whether OpenAL extensionAL_SOFT_buffer_samplesis available.booleanhasSOFTEvents()Return whether OpenAL extensionAL_SOFT_eventsis available.booleaninit(int alChannelLayout, int alSampleType, int alFormat, int sampleRate, int sampleSize, int frameDurationHint, int queueSize)Initializes the sink using the given OpenAL audio parameter and streaming details.booleaninit(AudioFormat requestedFormat, int frameDurationHint, int queueSize)booleanisAvailable()static booleanisInitialized()booleanisPlaying()booleanisSupported(AudioFormat format)booleanmakeCurrent(boolean throwException)voidpause()voidplay()booleanrelease(boolean throwException)voidsetChannelLimit(int cc)booleansetPlaySpeed(float rate)voidsetUseSOFTEvents(boolean v)Enable or disableAL_SOFT_events, default is enabled ifhasSOFTEvents().booleansetVolume(float v)StringtoString()PTSupdateQueue()
-
-
-
Constructor Detail
-
ALAudioSink
public ALAudioSink() throws ALExceptionCreate a new instance with a new defaultALCdevice- Throws:
ALException- if the defaultALCdevicecouldn't be fully created including its context.
-
ALAudioSink
public ALAudioSink(String deviceName) throws ALException
Create a new instance with a new namedALCdevice- Parameters:
deviceName- name of- Throws:
ALException- if the defaultALCdevicecouldn't be fully created including its context.
-
ALAudioSink
public ALAudioSink(Device alDevice) throws ALException
Create a new instance with an optional givenALCdevice- Parameters:
alDevice- optional OpenALDevice, a default device is opened if null.- Throws:
ALException- if the defaultALCdevicecouldn't be fully created including its context.
-
-
Method Detail
-
isInitialized
public static boolean isInitialized()
-
hasSOFTBufferSamples
public final boolean hasSOFTBufferSamples()
Return whether OpenAL extensionAL_SOFT_buffer_samplesis available.
-
hasEXTMcFormats
public final boolean hasEXTMcFormats()
Return whether OpenAL extensionAL_EXT_MCFORMATSis available.
-
hasEXTFloat32
public final boolean hasEXTFloat32()
Return whether OpenAL extensionAL_EXT_FLOAT32is available.
-
hasEXTDouble
public final boolean hasEXTDouble()
Return whether OpenAL extensionAL_EXT_DOUBLEis available.
-
hasALCThreadLocalContext
public final boolean hasALCThreadLocalContext()
Return whether OpenAL extensionALC_EXT_thread_local_contextis available.
-
hasSOFTEvents
public final boolean hasSOFTEvents()
Return whether OpenAL extensionAL_SOFT_eventsis available.
-
setUseSOFTEvents
public final void setUseSOFTEvents(boolean v)
Enable or disableAL_SOFT_events, default is enabled ifhasSOFTEvents().
-
getUseSOFTEvents
public final boolean getUseSOFTEvents(boolean v)
Returns whetherAL_SOFT_eventsis enabled, default ifhasSOFTEvents().
-
getALChannelLayout
public final int getALChannelLayout()
Return this instance's OpenAL channel layout, set after#init(AudioFormat, float, int).
-
getALSampleType
public final int getALSampleType()
Return this instance's OpenAL sample type, set after#init(AudioFormat, float, int).
-
getALFormat
public final int getALFormat()
Return this instance's OpenAL format, set after#init(AudioFormat, float, int).
-
makeCurrent
public final boolean makeCurrent(boolean throwException)
- Specified by:
makeCurrentin interfaceAudioSink
-
release
public final boolean release(boolean throwException)
-
getPerfString
public final String getPerfString()
-
getSourceCount
public int getSourceCount()
- Specified by:
getSourceCountin interfaceAudioSink
-
getDefaultLatency
public float getDefaultLatency()
- Specified by:
getDefaultLatencyin interfaceAudioSink
-
getLatency
public float getLatency()
- Specified by:
getLatencyin interfaceAudioSink
-
getNativeFormat
public final AudioFormat getNativeFormat()
- Specified by:
getNativeFormatin interfaceAudioSink
-
getPreferredFormat
public final AudioFormat getPreferredFormat()
- Specified by:
getPreferredFormatin interfaceAudioSink
-
setChannelLimit
public final void setChannelLimit(int cc)
- Specified by:
setChannelLimitin interfaceAudioSink
-
isSupported
public final boolean isSupported(AudioFormat format)
- Specified by:
isSupportedin interfaceAudioSink
-
init
public final boolean init(AudioFormat requestedFormat, int frameDurationHint, int queueSize)
-
init
public final boolean init(int alChannelLayout, int alSampleType, int alFormat, int sampleRate, int sampleSize, int frameDurationHint, int queueSize)Initializes the sink using the given OpenAL audio parameter and streaming details.- Parameters:
alChannelLayout- OpenAL channel layoutalSampleType- OpenAL sample typealFormat- OpenAL formatsampleRate- sample rate, e.g. 44100sampleSize- sample size in bits, e.g. 16frameDurationHint- averageAudioSink.AudioFrameduration hint in milliseconds. Assists to adjust latency of the backend, as currently used for JOAL's ALAudioSink. A value below 30ms orAudioSink.DefaultFrameDurationmay increase the audio processing load. Assumed asAudioSink.DefaultFrameDuration, ifframeDuration < 1 ms.queueSize- queue size in milliseconds, seeAudioSink.DefaultQueueSize. Uses `frameDurationHint` to determine initialAudioSink.AudioFramequeue size.- Returns:
- true if successful, otherwise false
- See Also:
enqueueData(int, ByteBuffer, int),getAvgFrameDuration(),ALHelpers.getAudioFormat(int, int, int, int, int),#init(AudioFormat, float, int)
-
getChosenFormat
public final AudioFormat getChosenFormat()
- Specified by:
getChosenFormatin interfaceAudioSink
-
isAvailable
public final boolean isAvailable()
- Specified by:
isAvailablein interfaceAudioSink
-
updateQueue
public final PTS updateQueue()
- Specified by:
updateQueuein interfaceAudioSink
-
enqueueData
public final AudioSink.AudioFrame enqueueData(int pts, ByteBuffer bytes, int byteCount)
- Specified by:
enqueueDatain interfaceAudioSink
-
getPlaySpeed
public final float getPlaySpeed()
- Specified by:
getPlaySpeedin interfaceAudioSink
-
setPlaySpeed
public final boolean setPlaySpeed(float rate)
- Specified by:
setPlaySpeedin interfaceAudioSink
-
getEnqueuedFrameCount
public final int getEnqueuedFrameCount()
- Specified by:
getEnqueuedFrameCountin interfaceAudioSink
-
getFrameCount
public final int getFrameCount()
- Specified by:
getFrameCountin interfaceAudioSink
-
getQueuedFrameCount
public final int getQueuedFrameCount()
- Specified by:
getQueuedFrameCountin interfaceAudioSink
-
getFreeFrameCount
public final int getFreeFrameCount()
- Specified by:
getFreeFrameCountin interfaceAudioSink
-
getQueuedByteCount
public final int getQueuedByteCount()
- Specified by:
getQueuedByteCountin interfaceAudioSink
-
getQueuedDuration
public final float getQueuedDuration()
- Specified by:
getQueuedDurationin interfaceAudioSink
-
getAvgFrameDuration
public float getAvgFrameDuration()
- Specified by:
getAvgFrameDurationin interfaceAudioSink
-
getLastBufferedPTS
public final int getLastBufferedPTS()
- Specified by:
getLastBufferedPTSin interfaceAudioSink
-
-