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
OpenALAudioSink
implementation.Besides given
AudioSink
functionality, implementation is fully functional regardingAudioFormat
and 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, DefaultInitialQueueSize, DefaultQueueGrowAmount, DefaultQueueLimitAudioOnly, DefaultQueueLimitWithVideo
-
-
Constructor Summary
Constructors Constructor Description ALAudioSink()
Create a new instance with a new defaultALCdevice
ALAudioSink(Device alDevice)
Create a new instance with an optional givenALCdevice
ALAudioSink(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 void
destroy()
AudioSink.AudioFrame
enqueueData(int pts, ByteBuffer bytes, int byteCount)
void
flush()
static AL
getAL()
Return OpenAL globalAL
.static ALC
getALC()
Return OpenAL globalALC
.int
getALChannelLayout()
Return this instance's OpenAL channel layout, set after#init(AudioFormat, float, int, int, int)
.static ALExt
getALExt()
Return OpenAL globalALExt
.int
getALFormat()
Return this instance's OpenAL format, set after#init(AudioFormat, float, int, int, int)
.int
getALSampleType()
Return this instance's OpenAL sample type, set after#init(AudioFormat, float, int, int, int)
.float
getAvgFrameDuration()
AudioFormat
getChosenFormat()
Context
getContext()
Return this instance's OpenALContext
.float
getDefaultLatency()
Device
getDevice()
Return this instance's OpenALDevice
.int
getEnqueuedFrameCount()
int
getFrameCount()
int
getFreeFrameCount()
float
getLatency()
AudioFormat
getNativeFormat()
String
getPerfString()
float
getPlaySpeed()
AudioFormat
getPreferredFormat()
int
getPTS()
int
getQueuedByteCount()
int
getQueuedFrameCount()
float
getQueuedTime()
Source
getSource()
Return this instance's OpenALSource
.int
getSourceCount()
float
getVolume()
boolean
hasALCThreadLocalContext()
Return whether OpenAL extensionALC_EXT_thread_local_context
is available.boolean
hasEXTDouble()
Return whether OpenAL extensionAL_EXT_DOUBLE
is available.boolean
hasEXTFloat32()
Return whether OpenAL extensionAL_EXT_FLOAT32
is available.boolean
hasEXTMcFormats()
Return whether OpenAL extensionAL_EXT_MCFORMATS
is available.boolean
hasSOFTBufferSamples()
Return whether OpenAL extensionAL_SOFT_buffer_samples
is available.boolean
init(int alChannelLayout, int alSampleType, int alFormat, int sampleRate, int sampleSize, int frameDurationHint, int initialQueueSize, int queueGrowAmount, int queueLimit)
Initializes the sink using the given OpenAL audio parameter and streaming details.boolean
init(AudioFormat requestedFormat, int frameDuration, int initialQueueSize, int queueGrowAmount, int queueLimit)
boolean
isAvailable()
static boolean
isInitialized()
boolean
isPlaying()
boolean
isSupported(AudioFormat format)
boolean
makeCurrent(boolean throwException)
void
pause()
void
play()
boolean
release(boolean throwException)
void
setChannelLimit(int cc)
boolean
setPlaySpeed(float rate)
boolean
setVolume(float v)
String
toString()
-
-
-
Constructor Detail
-
ALAudioSink
public ALAudioSink() throws ALException
Create a new instance with a new defaultALCdevice
- Throws:
ALException
- if the defaultALCdevice
couldn'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 defaultALCdevice
couldn'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 defaultALCdevice
couldn'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_samples
is available.
-
hasEXTMcFormats
public final boolean hasEXTMcFormats()
Return whether OpenAL extensionAL_EXT_MCFORMATS
is available.
-
hasEXTFloat32
public final boolean hasEXTFloat32()
Return whether OpenAL extensionAL_EXT_FLOAT32
is available.
-
hasEXTDouble
public final boolean hasEXTDouble()
Return whether OpenAL extensionAL_EXT_DOUBLE
is available.
-
hasALCThreadLocalContext
public final boolean hasALCThreadLocalContext()
Return whether OpenAL extensionALC_EXT_thread_local_context
is available.
-
getALChannelLayout
public final int getALChannelLayout()
Return this instance's OpenAL channel layout, set after#init(AudioFormat, float, int, int, int)
.
-
getALSampleType
public final int getALSampleType()
Return this instance's OpenAL sample type, set after#init(AudioFormat, float, int, int, int)
.
-
getALFormat
public final int getALFormat()
Return this instance's OpenAL format, set after#init(AudioFormat, float, int, int, int)
.
-
makeCurrent
public final boolean makeCurrent(boolean throwException)
- Specified by:
makeCurrent
in interfaceAudioSink
-
release
public final boolean release(boolean throwException)
-
getPerfString
public final String getPerfString()
-
getSourceCount
public int getSourceCount()
- Specified by:
getSourceCount
in interfaceAudioSink
-
getDefaultLatency
public float getDefaultLatency()
- Specified by:
getDefaultLatency
in interfaceAudioSink
-
getLatency
public float getLatency()
- Specified by:
getLatency
in interfaceAudioSink
-
getNativeFormat
public final AudioFormat getNativeFormat()
- Specified by:
getNativeFormat
in interfaceAudioSink
-
getPreferredFormat
public final AudioFormat getPreferredFormat()
- Specified by:
getPreferredFormat
in interfaceAudioSink
-
setChannelLimit
public final void setChannelLimit(int cc)
- Specified by:
setChannelLimit
in interfaceAudioSink
-
isSupported
public final boolean isSupported(AudioFormat format)
- Specified by:
isSupported
in interfaceAudioSink
-
init
public final boolean init(AudioFormat requestedFormat, int frameDuration, int initialQueueSize, int queueGrowAmount, int queueLimit)
-
init
public final boolean init(int alChannelLayout, int alSampleType, int alFormat, int sampleRate, int sampleSize, int frameDurationHint, int initialQueueSize, int queueGrowAmount, int queueLimit)
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.AudioFrame
duration hint in milliseconds. Assists to shape theAudioSink.AudioFrame
initial queue size using `initialQueueSize`. Assists to adjust latency of the backend, as currently used for JOAL's ALAudioSink. A value below 30ms orAudioSink.DefaultFrameDuration
may increase the audio processing load. Assumed asAudioSink.DefaultFrameDuration
, ifframeDuration < 1 ms
.initialQueueSize
- initial queue size in milliseconds, seeAudioSink.DefaultInitialQueueSize
. Uses `frameDurationHint` to determine initialAudioSink.AudioFrame
queue size.queueGrowAmount
- queue grow size in milliseconds if queue is full, seeAudioSink.DefaultQueueGrowAmount
. UsesgetAvgFrameDuration()
to determineAudioSink.AudioFrame
queue growth amount.queueLimit
- maximum time in milliseconds the queue can hold (and grow), seeAudioSink.DefaultQueueLimitWithVideo
andAudioSink.DefaultQueueLimitAudioOnly
. UsesgetAvgFrameDuration()
to determineAudioSink.AudioFrame
queue limit.- Returns:
- true if successful, otherwise false
- See Also:
enqueueData(int, ByteBuffer, int)
,getAvgFrameDuration()
,ALHelpers.getAudioFormat(int, int, int, int, int)
,#init(AudioFormat, float, int, int, int)
-
getChosenFormat
public final AudioFormat getChosenFormat()
- Specified by:
getChosenFormat
in interfaceAudioSink
-
isAvailable
public final boolean isAvailable()
- Specified by:
isAvailable
in interfaceAudioSink
-
enqueueData
public final AudioSink.AudioFrame enqueueData(int pts, ByteBuffer bytes, int byteCount)
- Specified by:
enqueueData
in interfaceAudioSink
-
getPlaySpeed
public final float getPlaySpeed()
- Specified by:
getPlaySpeed
in interfaceAudioSink
-
setPlaySpeed
public final boolean setPlaySpeed(float rate)
- Specified by:
setPlaySpeed
in interfaceAudioSink
-
getEnqueuedFrameCount
public final int getEnqueuedFrameCount()
- Specified by:
getEnqueuedFrameCount
in interfaceAudioSink
-
getFrameCount
public final int getFrameCount()
- Specified by:
getFrameCount
in interfaceAudioSink
-
getQueuedFrameCount
public final int getQueuedFrameCount()
- Specified by:
getQueuedFrameCount
in interfaceAudioSink
-
getFreeFrameCount
public final int getFreeFrameCount()
- Specified by:
getFreeFrameCount
in interfaceAudioSink
-
getQueuedByteCount
public final int getQueuedByteCount()
- Specified by:
getQueuedByteCount
in interfaceAudioSink
-
getQueuedTime
public final float getQueuedTime()
- Specified by:
getQueuedTime
in interfaceAudioSink
-
getAvgFrameDuration
public float getAvgFrameDuration()
- Specified by:
getAvgFrameDuration
in interfaceAudioSink
-
-