Package com.jme3.audio.openal
Class ALAudioRenderer
java.lang.Object
com.jme3.audio.openal.ALAudioRenderer
- All Implemented Interfaces:
AudioRenderer
,Runnable
ALAudioRenderer is the backend implementation for OpenAL audio rendering.
-
Constructor Summary
ConstructorsConstructorDescriptionALAudioRenderer
(AL al, ALC alc, EFX efx) Creates a new ALAudioRenderer instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
Shuts down the audio decoder thread and destroys the OpenAL context.void
deleteAudioData
(AudioData audioData) Deletes the OpenAL objects associated with the AudioData.void
deleteFilter
(Filter filter) Deletes the OpenAL filter object associated with the Filter.float
Gets the current playback time (in seconds) for a source.void
Initializes the OpenAL context, enumerates channels, checks capabilities, and starts the audio decoder thread.void
pauseAll()
Pauses all audio playback by pausing the OpenAL device context.void
pauseSource
(AudioSource src) Pauses a playing audio source.void
playSource
(AudioSource src) Plays an audio source, allocating a persistent channel for it.void
Plays an audio source as a one-shot instance (non-looping buffer).void
Resumes all audio playback by resuming the OpenAL device context.void
run()
Main loop for the audio decoder thread.void
Configures the global reverb effect based on the Environment settings.void
setListener
(Listener listener) void
stopSource
(AudioSource src) Stops a playing or paused audio source, releasing its channel.void
update
(float tpf) Update the audio system.void
updateInDecoderThread
(float tpf) Internal update logic called from the decoder thread within the lock.void
updateInRenderThread
(float tpf) Internal update logic called from the render thread within the lock.void
updateListenerParam
(Listener listener, ListenerParam param) Updates a specific parameter for the listener.void
updateSourceParam
(AudioSource src, AudioParam param) Updates a specific parameter for an audio source on its assigned channel.
-
Constructor Details
-
ALAudioRenderer
Creates a new ALAudioRenderer instance.- Parameters:
al
- The OpenAL interface.alc
- The OpenAL Context interface.efx
- The OpenAL Effects Extension interface.
-
-
Method Details
-
initialize
public void initialize()Initializes the OpenAL context, enumerates channels, checks capabilities, and starts the audio decoder thread.- Specified by:
initialize
in interfaceAudioRenderer
-
run
public void run()Main loop for the audio decoder thread. Updates streaming sources. -
cleanup
public void cleanup()Shuts down the audio decoder thread and destroys the OpenAL context.- Specified by:
cleanup
in interfaceAudioRenderer
-
getSourcePlaybackTime
Gets the current playback time (in seconds) for a source. For streams, includes the time represented by already processed buffers.- Specified by:
getSourcePlaybackTime
in interfaceAudioRenderer
- Parameters:
src
- The audio source.- Returns:
- The playback time in seconds, or 0 if not playing or invalid.
-
updateSourceParam
Updates a specific parameter for an audio source on its assigned channel.- Specified by:
updateSourceParam
in interfaceAudioRenderer
- Parameters:
src
- The audio source.param
- The parameter to update.
-
updateListenerParam
Updates a specific parameter for the listener.- Specified by:
updateListenerParam
in interfaceAudioRenderer
- Parameters:
listener
- The listener object.param
- The parameter to update.
-
setEnvironment
Configures the global reverb effect based on the Environment settings.- Specified by:
setEnvironment
in interfaceAudioRenderer
- Parameters:
env
- The Environment object.- See Also:
-
update
public void update(float tpf) Description copied from interface:AudioRenderer
Update the audio system. Must be called periodically.- Specified by:
update
in interfaceAudioRenderer
- Parameters:
tpf
- Time per frame.
-
updateInRenderThread
public void updateInRenderThread(float tpf) Internal update logic called from the render thread within the lock. Checks source statuses and reclaims finished channels.- Parameters:
tpf
- Time per frame (currently unused).
-
updateInDecoderThread
public void updateInDecoderThread(float tpf) Internal update logic called from the decoder thread within the lock. Fills streaming buffers and restarts starved sources. Deletes unused objects.- Parameters:
tpf
- Time per frame (currently unused).
-
setListener
- Specified by:
setListener
in interfaceAudioRenderer
- Parameters:
listener
- The listener camera, all 3D sounds will be oriented around the listener.
-
pauseAll
public void pauseAll()Pauses all audio playback by pausing the OpenAL device context. Requires ALC_SOFT_pause_device extension.- Specified by:
pauseAll
in interfaceAudioRenderer
- Throws:
UnsupportedOperationException
- if the extension is not supported.
-
resumeAll
public void resumeAll()Resumes all audio playback by resuming the OpenAL device context. Requires ALC_SOFT_pause_device extension.- Specified by:
resumeAll
in interfaceAudioRenderer
- Throws:
UnsupportedOperationException
- if the extension is not supported.
-
playSourceInstance
Plays an audio source as a one-shot instance (non-looping buffer). A free channel is allocated temporarily.- Specified by:
playSourceInstance
in interfaceAudioRenderer
- Parameters:
src
- The audio source to play.
-
playSource
Plays an audio source, allocating a persistent channel for it. Handles both buffers and streams. Can be paused and stopped.- Specified by:
playSource
in interfaceAudioRenderer
- Parameters:
src
- The audio source to play.
-
pauseSource
Pauses a playing audio source.- Specified by:
pauseSource
in interfaceAudioRenderer
- Parameters:
src
- The audio source to pause.
-
stopSource
Stops a playing or paused audio source, releasing its channel. For streams, resets or closes the stream.- Specified by:
stopSource
in interfaceAudioRenderer
- Parameters:
src
- The audio source to stop.
-
deleteFilter
Deletes the OpenAL filter object associated with the Filter.- Specified by:
deleteFilter
in interfaceAudioRenderer
- Parameters:
filter
- The Filter object.
-
deleteAudioData
Deletes the OpenAL objects associated with the AudioData.- Specified by:
deleteAudioData
in interfaceAudioRenderer
- Parameters:
audioData
- The AudioData to delete.
-