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 TypeMethodDescriptionvoidcleanup()Shuts down the audio decoder thread and destroys the OpenAL context.voiddeleteAudioData(AudioData audioData) Deletes the OpenAL objects associated with the AudioData.voiddeleteFilter(Filter filter) Deletes the OpenAL filter object associated with the Filter.floatGets the current playback time (in seconds) for a source.voidInitializes the OpenAL context, enumerates channels, checks capabilities, and starts the audio decoder thread.voidpauseAll()Pauses all audio playback by pausing the OpenAL device context.voidpauseSource(AudioSource src) Pauses a playing audio source.voidplaySource(AudioSource src) Plays an audio source, allocating a persistent channel for it.voidPlays an audio source as a one-shot instance (non-looping buffer).voidResumes all audio playback by resuming the OpenAL device context.voidrun()Main loop for the audio decoder thread.voidConfigures the global reverb effect based on the Environment settings.voidsetListener(Listener listener) voidstopSource(AudioSource src) Stops a playing or paused audio source, releasing its channel.voidupdate(float tpf) Update the audio system.voidupdateInDecoderThread(float tpf) Internal update logic called from the decoder thread within the lock.voidupdateInRenderThread(float tpf) Internal update logic called from the render thread within the lock.voidupdateListenerParam(Listener listener, ListenerParam param) Updates a specific parameter for the listener.voidupdateSourceParam(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:
initializein 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:
cleanupin interfaceAudioRenderer
-
getSourcePlaybackTime
Gets the current playback time (in seconds) for a source. For streams, includes the time represented by already processed buffers.- Specified by:
getSourcePlaybackTimein 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:
updateSourceParamin interfaceAudioRenderer- Parameters:
src- The audio source.param- The parameter to update.
-
updateListenerParam
Updates a specific parameter for the listener.- Specified by:
updateListenerParamin interfaceAudioRenderer- Parameters:
listener- The listener object.param- The parameter to update.
-
setEnvironment
Configures the global reverb effect based on the Environment settings.- Specified by:
setEnvironmentin interfaceAudioRenderer- Parameters:
env- The Environment object.- See Also:
-
update
public void update(float tpf) Description copied from interface:AudioRendererUpdate the audio system. Must be called periodically.- Specified by:
updatein 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:
setListenerin 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:
pauseAllin 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:
resumeAllin 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:
playSourceInstancein 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:
playSourcein interfaceAudioRenderer- Parameters:
src- The audio source to play.
-
pauseSource
Pauses a playing audio source.- Specified by:
pauseSourcein 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:
stopSourcein interfaceAudioRenderer- Parameters:
src- The audio source to stop.
-
deleteFilter
Deletes the OpenAL filter object associated with the Filter.- Specified by:
deleteFilterin interfaceAudioRenderer- Parameters:
filter- The Filter object.
-
deleteAudioData
Deletes the OpenAL objects associated with the AudioData.- Specified by:
deleteAudioDatain interfaceAudioRenderer- Parameters:
audioData- The AudioData to delete.
-