Class ALAudioRenderer

java.lang.Object
com.jme3.audio.openal.ALAudioRenderer
All Implemented Interfaces:
AudioRenderer, Runnable

public class ALAudioRenderer extends Object implements AudioRenderer, Runnable
ALAudioRenderer is the backend implementation for OpenAL audio rendering.
  • Constructor Details

    • ALAudioRenderer

      public ALAudioRenderer(AL al, ALC alc, EFX efx)
      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 interface AudioRenderer
    • run

      public void run()
      Main loop for the audio decoder thread. Updates streaming sources.
      Specified by:
      run in interface Runnable
    • cleanup

      public void cleanup()
      Shuts down the audio decoder thread and destroys the OpenAL context.
      Specified by:
      cleanup in interface AudioRenderer
    • getSourcePlaybackTime

      public float getSourcePlaybackTime(AudioSource src)
      Gets the current playback time (in seconds) for a source. For streams, includes the time represented by already processed buffers.
      Specified by:
      getSourcePlaybackTime in interface AudioRenderer
      Parameters:
      src - The audio source.
      Returns:
      The playback time in seconds, or 0 if not playing or invalid.
    • updateSourceParam

      public void updateSourceParam(AudioSource src, AudioParam param)
      Updates a specific parameter for an audio source on its assigned channel.
      Specified by:
      updateSourceParam in interface AudioRenderer
      Parameters:
      src - The audio source.
      param - The parameter to update.
    • updateListenerParam

      public void updateListenerParam(Listener listener, ListenerParam param)
      Updates a specific parameter for the listener.
      Specified by:
      updateListenerParam in interface AudioRenderer
      Parameters:
      listener - The listener object.
      param - The parameter to update.
    • setEnvironment

      public void setEnvironment(Environment env)
      Configures the global reverb effect based on the Environment settings.
      Specified by:
      setEnvironment in interface AudioRenderer
      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 interface AudioRenderer
      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

      public void setListener(Listener listener)
      Specified by:
      setListener in interface AudioRenderer
      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 interface AudioRenderer
      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 interface AudioRenderer
      Throws:
      UnsupportedOperationException - if the extension is not supported.
    • playSourceInstance

      public void playSourceInstance(AudioSource src)
      Plays an audio source as a one-shot instance (non-looping buffer). A free channel is allocated temporarily.
      Specified by:
      playSourceInstance in interface AudioRenderer
      Parameters:
      src - The audio source to play.
    • playSource

      public void playSource(AudioSource src)
      Plays an audio source, allocating a persistent channel for it. Handles both buffers and streams. Can be paused and stopped.
      Specified by:
      playSource in interface AudioRenderer
      Parameters:
      src - The audio source to play.
    • pauseSource

      public void pauseSource(AudioSource src)
      Pauses a playing audio source.
      Specified by:
      pauseSource in interface AudioRenderer
      Parameters:
      src - The audio source to pause.
    • stopSource

      public void stopSource(AudioSource src)
      Stops a playing or paused audio source, releasing its channel. For streams, resets or closes the stream.
      Specified by:
      stopSource in interface AudioRenderer
      Parameters:
      src - The audio source to stop.
    • deleteFilter

      public void deleteFilter(Filter filter)
      Deletes the OpenAL filter object associated with the Filter.
      Specified by:
      deleteFilter in interface AudioRenderer
      Parameters:
      filter - The Filter object.
    • deleteAudioData

      public void deleteAudioData(AudioData audioData)
      Deletes the OpenAL objects associated with the AudioData.
      Specified by:
      deleteAudioData in interface AudioRenderer
      Parameters:
      audioData - The AudioData to delete.